Home > Services > DXCore Services – Refactoring

DXCore Services – Refactoring

December 20th, 2011

The Refactoring DXCore service provides methods and properties for refactoring support such as finding all required elements, an element’s declaration, its references, type name, etc.

Methods of this service:

Method name

Description

CalculateRequiredParameters( LanguageElement, SourceRange) Calculates parameters that should be passed into the selected range of the code if the code is extracted from the given method or property accessor.
CanShowSmartTagAsync( AsyncAvailabilityEventArgs) Returns true if there’s at least one refactoring provider available.
ClearFromFakeElement(String) Removes all injected fake elements in the given file specified by its path.
CollectAssignments(LanguageElement) Collects all assignments to the given local variable.
CollectExpressions( LanguageElement) Collects all expressions in the given scope.
CollectExpressions( LanguageElement, Boolean) Collects all expressions in the given scope. The boolean parameter specifies whether this method should drill down into the expression nodes.
CollectExpressionsInNodes( NodeList, Boolean) Collects all expressions in the given node list collection.
CollectLocalDeclarations( LanguageElement) Collects all local declarations within the given language element. Local declaration may be a Const, a Variable, an Initialized Variable or a Param.
FindAllDefineDirectives( LanguageElement) Finds all DefineDirectives within the given scope.
FindAllDelegateCreationExpressions( LanguageElement, String) Finds all delegate initializations by the specified method name within the given scope.
FindAllFieldReferences( LanguageElement, LanguageElement) Finds all references to a field declaration by the specified name within the given scope. The language elements passed to this method should be determined through a call that either guarantees a parse will happen if needed, or the element was acquired directly after calling CodeRush. Language. ParseIfNeeded().
FindAllLanguageElements( LanguageElement, LanguageElementType) Finds all language elements of the specified type within the given scope.
FindAllLanguageElements( LanguageElement, LanguageElementType, Boolean) Finds all language elements of the specified type within the given scope. The boolean parameter specifies whether this method should drill down into the language element that has been added into the result collection.
FindAllLocalDeclarations( LanguageElement) Finds all local declarations within the given scope.
FindAllLocalReferences( LanguageElement, LanguageElement) Finds all references to the local declaration specified by its name within the given scope. The language elements passed to this method should be determined through a call that either guarantees a parse will happen if needed, or the element was acquired directly after calling CodeRush. Language. ParseIfNeeded().
FindAllMethodReferences( LanguageElement, LanguageElement) Finds all references to the method specified by its name within the given scope.
FindAllNamespaceReferences( LanguageElement) Finds all NamespaceReferences (with nested NamespaceReferences) within the given scope.
FindAllNamespaceReferences( LanguageElement, Boolean) Finds all NamespaceReferences within the given scope.
FindAllObjectCreationExpressions( LanguageElement, String, Int32) Finds all ObjectCreationExpressions specified by its ObjectName propety and parameters count within the given scope.
FindAllPrimitiveExpressions( LanguageElement, String) Finds all PrimitiveExpressions specified by its name within the given scope.
FindAllReferences(IElement, IElement) Searches for references to the specifed declaration within the given scope.
FindAllRelationalOperations( LanguageElement) Finds all RelationalOperations within the given scope.
FindAllReturnStatements( LanguageElement) Finds all ReturnStatements within the given scope.
FindAllReturnStatements( LanguageElement, Boolean) Finds all ReturnStatements within the given scope.
FindAllTypeDeclarations( LanguageElement) Finds all TypeDeclarations within the given scope.
FindAllTypeDeclarations( LanguageElement, Boolean) Finds all TypeDeclarations within the given scope.
FindAllTypeDeclarations( LanguageElement, Boolean, Boolean) Finds all TypeDeclarations within the given scope.
FindAllTypeReferenceExpressions( LanguageElement) Finds all TypeReferenceExpressions specified by its level within the given scope.
FindAllTypeReferenceExpressions( LanguageElement, Int32) Finds all TypeReferenceExpressions specified by its level within the given scope.
FindAllTypeReferenceExpressions( LanguageElement, Int32, Boolean) Finds all TypeReferenceExpressions specified by its level within the given scope.
FindFieldDeclaration(LanguageElement) Finds field declaration for the specified element reference.
FindLocalDeclaration(LanguageElement) Finds local declaration for the specified element reference.
FindLocalDeclaration(LanguageElement, String) Finds local declaration with the given name, starting from the specified element reference.
Get(String) Returns the refactoring provider with the given name.
GetAvailability(String) Returns the availability of the specified refactoring.
GetElementExpression(LanguageElement) Returns the expression of the given element.
GetElementExpressionTypeName( LanguageElement) Returns the type name of the given element expression.
GetElementExpressionTypeName( LanguageElement, Boolean) Returns the type name of the given element expression. The boolen parameter specifies whether the resulting type name should be simplified.
GetElementType(LanguageElement) Return the type of the given element. Note that it is hidden from Intellisense.
GetElementTypeName(LanguageElement) Returns the type name of the given element. Note that it is hidden from Intellisense.
GetElementTypeName(LanguageElement, Boolean) Returns the type name of the given element. Note that it is hidden from Intellisense.
GetExpressionFullTypeName(Expression) Returns the full type name of the given expression. Note that it is hidden from Intellisense.
GetExpressionType(Expression) Returns the type of the given expression. Note that it is hidden from Intellisense.
GetExpressionTypeFromContext( Expression) Returns the type name of the given expression by analyzing the context of the expression.
GetExpressionTypeFromContext( Expression, Boolean) Returns the type name of the given expression by analyzing the context of the expression.
GetExpressionTypeFromContext( LanguageElement) Returns the type name that the given element expression should match by analyzing expression context.
GetExpressionTypeFromContext( LanguageElement, Boolean) Returns the type name that the given element expression should match by analyzing expression context.
GetExpressionTypeName(Expression) Returns the type name of the given expression. Note that it is hidden from Intellisense.
GetLanguageElement(IElement) Gets the LanguageElement instance from the given IElement instance. This method will return null, if the IElement instance doesn’t have corresponding LanguageElement available (e.g., when IElement instance is declared inside a referenced assembly).
GetLanguageElementCollection( IElementCollection) Gets the LanguageElementCollection instance from the given IElementCollection instance. This method will return an empty collection, if the IElementCollection instance doesn’t have corresponding elements available.
GetUniqueName(LanguageElement, LanguageElement, String) Returns a unique element name in the given scope. Note that it is hidden from Intellisense.
GetUniqueName(LanguageElement, LanguageElementType, String) Returns a unique element name in the given scope. Note that it is hidden from Intellisense.
GetUniqueName(LanguageElement, String) Returns a unique element name in the given scope. Note that it is hidden from Intellisense.
GetUniqueName(LanguageElementType, String) Returns a unique element name in the given scope. Note that it is hidden from Intellisense.
GetUniqueNameInsideScope( LanguageElement, String) Returns a unique element name.
GetUniqueNameInsideScope( LanguageElement, String, Boolean) Returns a unique element name.
HasExpression(LanguageElement) Checks if the passed element has an expression. This method will return true for the following elements: if, while, do and initialized variable element.
HideSmartTag Hides the smart tag if it is active.
InjectFakeElement(String, SourcePoint, LanguageElement) Injects the fake element into the source tree.
InjectFakeElement(String, SourcePoint, LanguageElement, LanguageElementType, LanguageElementType[]) Injects the fake element into the source tree.
IsAvailable(String) Returns true if the specified refactoring provider is available.
ProcessInnerTypes(LanguageElement, LanguageElement) Converts simple type references to full type references taking into account nested types of the active type. Note that it is hidden from Intellisense.
ResolveShortTypesToFullTypesIfNeeded( LanguageElement, LanguageElement, LanguageElement) Converts short type names to full type names in the target element that can be located in a different type. For example, “String” -> “System.String” if “System” namespace isn’t referenced. Note that it is hidden from Intellisense.
SimplifyExpression(Expression) Simplifies the given expression.

Properties:

Property name

Description

Active Gets the currently active refactoring.
ActivePicker Gets the currently active target picker.
AvailableRefactorings Returns a list of all available refactorings in the current context.
CanShowSmartTag Return true if there’s at least one refactoring provider available.
IsActive Returns true if a refactoring is active.
IsMenuActive Returns true if the refactoring menu is active.
IsSmartTagActive Returns true if the smart tag is active.
PickerIsActive Returns true if the current target picker is active.
Providers Returns an array of all registered refactorings.
SuppressActionHints Gets or sets the value that controls the refactoring action hints availability.
—–
Products: DXCore
Versions: 11.2 and up
VS IDEs: any
Updated: Dec/20/2011
ID: D137

Similar Posts: