Delen via


SyntaxEditor Class

Definition

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.

Extension Methods

AddAttribute(SyntaxEditor, SyntaxNode, SyntaxNode)
AddAttributeArgument(SyntaxEditor, SyntaxNode, SyntaxNode)
AddBaseType(SyntaxEditor, SyntaxNode, SyntaxNode)
AddInterfaceType(SyntaxEditor, SyntaxNode, SyntaxNode)
AddMember(SyntaxEditor, SyntaxNode, SyntaxNode)
AddParameter(SyntaxEditor, SyntaxNode, SyntaxNode)
AddReturnAttribute(SyntaxEditor, SyntaxNode, SyntaxNode)
InsertMembers(SyntaxEditor, SyntaxNode, Int32, IEnumerable<SyntaxNode>)
InsertParameter(SyntaxEditor, SyntaxNode, Int32, SyntaxNode)
SetAccessibility(SyntaxEditor, SyntaxNode, Accessibility)
SetExpression(SyntaxEditor, SyntaxNode, SyntaxNode)
SetGetAccessorStatements(SyntaxEditor, SyntaxNode, IEnumerable<SyntaxNode>)
SetModifiers(SyntaxEditor, SyntaxNode, DeclarationModifiers)
SetName(SyntaxEditor, SyntaxNode, String)
SetSetAccessorStatements(SyntaxEditor, SyntaxNode, IEnumerable<SyntaxNode>)
SetStatements(SyntaxEditor, SyntaxNode, IEnumerable<SyntaxNode>)
SetType(SyntaxEditor, SyntaxNode, SyntaxNode)
SetTypeConstraint(SyntaxEditor, SyntaxNode, String, SpecialTypeConstraintKind, IEnumerable<SyntaxNode>)
SetTypeParameters(SyntaxEditor, SyntaxNode, IEnumerable<String>)

Applies to