SyntaxEditor Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An editor for making changes to a syntax tree. The editor works by giving a list of changes to perform to a particular tree in order. Changes are given a SyntaxNode they will apply to in the original tree the editor is created for. The semantics of application are as follows:
public ref class SyntaxEditor
public class SyntaxEditor
type SyntaxEditor = class
Public Class SyntaxEditor
- Inheritance
-
SyntaxEditor
- Derived
Remarks
The above editing strategy makes it an error for a client of the editor to add a change that updates a parent node and then adds a change that updates a child node (unless the parent change is certain to contain the child), and attempting this will throw at runtime. If a client ever needs to update both a child and a parent, it should add the child change first, and then the parent change. And the parent change should pass an appropriate 'compute' callback so it will see the results of the child change.
If a client wants to make a replacement, then find the valueSyntaxNode put into the tree, that can be done by adding a dedicated annotation to that node and then looking it back up in the 'current' node passed to a 'compute' callback.
Constructors
SyntaxEditor(SyntaxNode, HostWorkspaceServices) |
Creates a new SyntaxEditor instance. |
SyntaxEditor(SyntaxNode, SolutionServices) |
Creates a new SyntaxEditor instance. |
SyntaxEditor(SyntaxNode, Workspace) |
Obsolete.
Creates a new SyntaxEditor instance. |
Properties
Generator |
A SyntaxGenerator to use to create and change SyntaxNode's. |
OriginalRoot |
The SyntaxNode that was specified when the SyntaxEditor was constructed. |
Methods
GetChangedRoot() |
Returns the changed root node. |
InsertAfter(SyntaxNode, IEnumerable<SyntaxNode>) |
Insert the new nodes after the specified node already existing in the tree. |
InsertAfter(SyntaxNode, SyntaxNode) |
Insert the new node after the specified node already existing in the tree. |
InsertBefore(SyntaxNode, IEnumerable<SyntaxNode>) |
Insert the new nodes before the specified node already existing in the tree. |
InsertBefore(SyntaxNode, SyntaxNode) |
Insert the new node before the specified node already existing in the tree. |
RemoveNode(SyntaxNode, SyntaxRemoveOptions) |
Remove the node from the tree. |
RemoveNode(SyntaxNode) |
Remove the node from the tree. |
ReplaceNode(SyntaxNode, Func<SyntaxNode,SyntaxGenerator,SyntaxNode>) |
Replace the specified node with a node produced by the function. |
ReplaceNode(SyntaxNode, SyntaxNode) |
Replace the specified node with a different node. |
TrackNode(SyntaxNode) |
Makes sure the node is tracked, even if it is not changed. |