Udostępnij za pośrednictwem


SyntaxTree Class

Definition

The parsed representation of a source document.

public ref class SyntaxTree abstract
public abstract class SyntaxTree
type SyntaxTree = class
Public MustInherit Class SyntaxTree
Inheritance
SyntaxTree
Derived

Constructors

SyntaxTree()

Fields

EmptyDiagnosticOptions

Cached value for empty DiagnosticOptions.

Properties

DiagnosticOptions
Obsolete.

Option to specify custom behavior for each warning in this tree.

Encoding

The text encoding of the source document.

FilePath

The path of the source document file.

HasCompilationUnitRoot

Returns true if this syntax tree has a root with SyntaxKind "CompilationUnit".

Length

The length of the text of the syntax tree.

Options

The options used by the parser to produce the syntax tree.

OptionsCore

The options used by the parser to produce the syntax tree.

Methods

GetChangedSpans(SyntaxTree)

Returns a list of the changed regions between this tree and the specified tree. The list is conservative for performance reasons. It may return larger regions than what has actually changed.

GetChanges(SyntaxTree)

Gets a list of text changes that when applied to the old tree produce this tree.

GetDiagnostics(CancellationToken)

Gets a list of all the diagnostics in the syntax tree. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

GetDiagnostics(SyntaxNode)

Gets a list of all the diagnostics in the sub tree that has the specified node as its root. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

GetDiagnostics(SyntaxNodeOrToken)

Gets a list of all the diagnostics in either the sub tree that has the specified node as its root or associated with the token and its related trivia. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

GetDiagnostics(SyntaxToken)

Gets a list of all the diagnostics associated with the token and any related trivia. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

GetDiagnostics(SyntaxTrivia)

Gets a list of all the diagnostics associated with the trivia. This method does not filter diagnostics based on #pragmas and compiler options like nowarn, warnaserror etc.

GetLineMappings(CancellationToken)

Returns empty sequence if there are no line mapping directives in the tree. Otherwise, returns a sequence of pairs of spans: each describing a mapping of a span of the tree between two consecutive #line directives. If the first directive is not on the first line the first pair describes mapping of the span preceding the first directive. The last pair of the sequence describes mapping of the span following the last #line directive.

GetLineSpan(TextSpan, CancellationToken)

Gets the location in terms of path, line and column for a given span.

GetLineVisibility(Int32, CancellationToken)

Returns the visibility for the line at the given position.

GetLocation(TextSpan)

Gets a location for the specified text span.

GetMappedLineSpan(TextSpan, CancellationToken)

Gets the location in terms of path, line and column after applying source line mapping directives (#line in C# or #ExternalSource in VB).

GetReference(SyntaxNode)

Gets a SyntaxReference for a specified syntax node. SyntaxReferences can be used to regain access to a syntax node without keeping the entire tree and source text in memory.

GetRoot(CancellationToken)

Gets the root node of the syntax tree, causing computation if necessary.

GetRootAsync(CancellationToken)

Gets the root node of the syntax tree asynchronously.

GetRootAsyncCore(CancellationToken)

Gets the root node of the syntax tree asynchronously.

GetRootCore(CancellationToken)

Gets the root node of the syntax tree, causing computation if necessary.

GetText(CancellationToken)

Gets the text of the source document.

GetTextAsync(CancellationToken)

Gets the text of the source document asynchronously.

HasHiddenRegions()

Are there any hidden regions in the tree?

IsEquivalentTo(SyntaxTree, Boolean)

Determines if two trees are the same, disregarding trivia differences.

ToString()

Returns a String that represents the entire source text of this SyntaxTree.

TryGetRoot(SyntaxNode)

Gets the root of the syntax tree if it is available.

TryGetRootCore(SyntaxNode)

Gets the root of the syntax tree if it is available.

TryGetText(SourceText)

Gets the syntax tree's text if it is available.

WithChangedText(SourceText)

Create a new syntax tree based off this tree using a new source text.

If the new source text is a minor change from the current source text an incremental parse will occur reusing most of the current syntax tree internal data. Otherwise, a full parse will occur using the new source text.

WithDiagnosticOptions(ImmutableDictionary<String,ReportDiagnostic>)
Obsolete.

Returns a new tree whose DiagnosticOptions are the specified value and other properties are copied from the current tree.

WithFilePath(String)

Returns a new tree whose FilePath is the specified node and other properties are copied from the current tree.

WithRootAndOptions(SyntaxNode, ParseOptions)

Returns a new tree whose root and options are as specified and other properties are copied from the current tree.

Extension Methods

GetCompilationUnitRoot(SyntaxTree, CancellationToken)
GetCompilationUnitRoot(SyntaxTree)

Gets the root CompilationUnitSyntax for a specified SyntaxTree.

Applies to