DXCore Services – TextExpansions
Text Expansions DXCore service provides methods and properties for expanding dynamic text containing encoded text commands and/or string providers. CodeRush Templates is an example of such a feature. Note that the service is hidden from Intellisense.
One of the most important methods is “Insert” (with various overloads), which allows you to expand the text you prepared. All Insert methods return the SourceRange of the expanded text. For example, when you expand the “ai” template in CSharp (to create a new auto-implemented property), the following text is being expanded:
«?ScopeProperty(true)»«TypeLink(“«?Get(Type)»”)» «BlockAnchor»«FieldStart(Property name)»«Link(PropertyName)»«FieldEnd»«Caret» {get; set;}«Target»
You can use this service when developing DXCore plug-ins with different refactoring/code providers, which need insertion of complex text expansion.
Here are methods:
Name | Description |
BeginExpansion | Marks the beginning of a dynamic text insertion session. This call is needed to correctly process all encoded text commands. If you call this method, be sure to call EndExpansion. Note that Insert methods do not need to call this method, because Insert methods call it automatically. |
CancelExpansion | Cancels the text expansion session if one is currently active. |
EndExpansion | Marks the end of a dynamic text insertion action. |
Insert(String) | Inserts text containing encoded text commands at the active editor caret point. |
Insert(String, Boolean) | Inserts text containing encoded text commands at the active editor caret point. Specifies whether to format the expanded text. |
Insert(TextDocument, SourcePoint, String) | Inserts text containing encoded text commands at the specified point. Specifies whether to format the expanded text. |
Insert(String, Boolean, Boolean) | Inserts text containing encoded text commands at the active editor caret point. Specifies whether to format the expanded text and whether the expansion can be cancelled. |
Insert(TextDocument, SourcePoint, String, Boolean) | Inserts text containing encoded text commands at the specified point and text document. Specifies whether to format the expanded text. |
Insert(TextDocument, SourcePoint, String, Boolean, Boolean) | Inserts text containing encoded text commands at the specified point and text document. Specifies whether to format the expanded text and whether the expansion can be cancelled. |
Insert(TextDocument, SourcePoint[], String[], Boolean, Boolean) | Inserts multiple text expansions at the specified text coordinates in the specified text document. Specifies whether to format the expanded text and whether the expansion can be cancelled. |
Properties:
Name | Description |
IsExpanding | Returns true if the text expansion is currently being expanding. |
Variables | Provides get/set access to string variables used during expansion. String variables can be added by text expansions using the Set StringProvider, and queried using the Get StringProvider (as well as being set and retrieved programmatically through this property). |