Archive

Posts Tagged ‘Code Samples’

How to manage the refactoring provider appearance and sub menus in the Popup menu

September 30th, 2011 Comments off

The Refactor!/CodeRush Popup menu shows available refactoring and code operations in the current context. When you develop a DXCore plug-in with a refactoring provider component, you might need to tweak its appearance in the popup menu. We will see how to change the caption of a refactoring menu item and the text of the hint describing a refactoring operation. Also, we will learn how to add and manage sub menu items for the popup menu.

Read more…

How to get the declaring element (declaration) from a reference using DXCore

August 29th, 2011 Comments off

Once you have a reference to an element and would like to get its declaration, simply call the GetDeclaration() method of a reference of the Expression type (all references have the Expression base type).

Read more…

How to implement the Sync Edit feature from Delphi IDE inside Visual Studio IDE using DXCore

June 22nd, 2011 Comments off

According to the Embarcadero’s docwiki:

Sync Edit mode in Delphi allows you to change all occurrences of an identifier when you change one instance of that identifier. When you enter Sync Edit mode, you can tab to each highlighted identifier in your current Code Editor window.

The difference of the Sync Edit feature in Delphi from the usual Rename refactoring from Refactor! (for example) is that a declaration of an identifier may not exist. In this case the Rename is simple not available.

Read more…

How to use DXCore SmartTagProvider control and create your own Popup menu entry

May 23rd, 2011 Comments off

Here’s what the standard Refactor!/Code! and “Jump toPopup menu looks like:

Refactor! Code! Jump to Popup menu

Read more…

How to detect if DXCore is loaded from another add-in

January 17th, 2011 Comments off

Note, this article has been moved to the official DevExpress Support Center site. Please refer to the moved article as it might have further updates or additional comments. Thank you.

Here is a sample code illustrating how to detect if the DXCore is installed and loaded from another add-in (without static dependencies on the DXCore assemblies) using reflection. This could be helpful if your add-in functionality somehow intersects with the DXCore’s.

From inside a usual DXCore plug-in, you can detect if the DXCore is loaded by calling the “CodeRush.IsLoaded” property. In case you are not going to reference the DXCore assemblies inside your add-in, this sample might help.

Read more…

How to perform an existing refactoring from another one

December 25th, 2010 12 comments

Refactor! Pro has numerous refactorings which perform a single task. What if we could run several refactorings at once?

For example, there is a support for optimizing namespace references added to the Move Type to File refactoring: after the new file is created, the Optimize Namespace References refactoring does its job. Here are other examples of refactoring (code provider) combinations, which can be performed:

  • Introduce Local and Promote to Parameter will create a new refactoring, called something like “Introduce Parameter”.
  • Declare Class (Struct) and Declare Method (Property) will create a new multi-declare code provider, which will declare everything at once.
  • Introduce Parameter Object and Move Type to File will add a new option for the first refactoring to create a new file.
  • And so much more…

Read more…

How to show and dock a tool window automatically on Visual Studio start-up

November 15th, 2010 5 comments

If you’d like to show your tool window from a DXCore-based ToolWindow plug-in, you have to create another standard plug-in that will do this. You can add an additional DXCore standard plug-in project item into your solution, where the tool window is located. In the new plug-in, you need to handle the DXCoreLoaded event and manually add a code that opens and shows a tool window.

Read more…