Home > Services > DXCore Services – Templates

DXCore Services – Templates

April 22nd, 2011

The Templates DXCore service provides CodeRush Code Templates APIs and some additional text expansion services. Using this service, you can programmatically create your own templates and/or modify the existing ones.

Methods of this service:

Method Name Description
AddCategory (String, String) Adds new templates category with the given name.
AddTemplate (String, String, String) Adds new template to the specified category for the given language.
ExpandAtCursor(Boolean) Expands the template at the cursor. Returns true if expansion was successful. Returns false if the template wasn’t found, if code is selected, or if the expansion was cancelled by a text command or a plug-in.
ExpandTemplate(String) Expands the template specified by its name. Returns true if expansion was successful. Returns false if the template wasn’t found, if code is selected, or if the expansion was cancelled by a text command or a plug-in.
FillCommandMenu (MenuItem, EventHandler, Hashtable) Fills a menu item’s submenu with all TextCommands. Sorted by the command name. Used by Editor | Templates options page.
FillStringProviderMenu (MenuItem, EventHandler, Hashtable, String) Fills a menu item’s submenu with all StringProviders for the specified language. Sorted by the provider name. Used by Editor | Templates options page.
FilterTemplates(String) Filters the Primary and Secondary template lists based on the specified programming language.
Find(String, Boolean) Finds a specified template in the list.
FindCategory(String) Returns a template category by its path.
FindTemplate (String, String, String) Searches for the specified template inside the given category for the given language.
GetCategories(String) Returns all root template categories for the specified language.
GetExpansion (TemplateData, String, Boolean) Gets the template expansion text based on the specified TemplateData instance. Nested templates are recursively expanded, while StringProviders and TextCommands are left in place. This method is ideal for documenting template expansions.
GetPossibleTemplateNames (String) Returns a collection of possible template names matching the given text. This method doesn’t check any context or if a template exists.
GetRegExAliasArray(String) Retrieve an ArrayList containing all RegEx aliases (system and regular) for the specified language. Sorted by the RegEx name.
GetStringProviders(String) Retrieve an array containing all StringProviders for the specified language. Sorted by the provider name.
GetTemplateAtCursor (Boolean, Template, TemplateData) Gets the Template and TemplateItem corresponding to the text to the left of the cursor. Multiple template possibilities are evaluated. The best (longest) template with matching context wins.
GetTextCommands Retrieve an array containing all TextCommands. Sorted by the command name.
Reload Reloads the language-neutral and language-specific template lists and divides them into two categories; one that responds to the primary template expansion key, and the other which responds to the secondary expansion key (available through the Primary and Secondary TemplateList properties).
RemoveCategory (String, String, String) Removes the category from the specified parent for the given language.
RemoveTemplate (String, String, String) Removes the template from the specified category for the given language.
RenameCategory (String, String, String, String) Renames the category in the specified parent for the given language.
RenameTemplate (String, String, String, String) Renames the template in the specified category for the given language.
Save Saves all templates.
SelectRegExAlias(String) Creates a dialog which allows you to select a particular RegEx alias and return its instance.
SelectStringProvider(String) Creates a dialog which allows you to select a particular string provider and return its instance.
SelectTextCommand Creates a dialog which allows you to select a particular text commands and return its instance.

Properties:

Property Name Description
CheckingAvailability Returns true if we’re in the process of checking template availability. Some contexts (e.g., OnEmptyLine) are satisfied differently if this is true.
ExpandingOnEmptyLine Returns true if the line is empty when stripped of the template text.
ForEachElement The IElement associated with a ForEach template expansion. As the ForEach TextCommand expands, for each IElement this property will be set.
LeftText Returns the document text to the left of the currently expanding template.
PossibleTemplateAtCursor Returns true if there is a possible template at the cursor.
Primary Returns a list of templates triggered by the primary key (typically the Space key).
RightText Returns the document text to the right of the currently expanding template.
Secondary Returns a list of templates triggered by the secondary key (typically the Shift+Space key).
TemplateStoragePath Gets the path (rooted from the CodeRush settings path) where templates are stored.
—–
Products: DXCore
Versions: 12.1 and up
VS IDEs: any
Updated: Jun/09/2012
ID: D078

Similar Posts: