Class SyntaxTree
The parsed representation of a source document.
Inheritance
System.Object
SyntaxTree
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Loretta.CodeAnalysis.dll
Syntax
public abstract class SyntaxTree
Properties
|
Improve this Doc
View Source
Encoding
The text encoding of the source document.
Declaration
public abstract Encoding Encoding { get; }
Property Value
Type |
Description |
System.Text.Encoding |
|
|
Improve this Doc
View Source
FilePath
The path of the source document file.
Declaration
public abstract string FilePath { get; }
Property Value
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
HasCompilationUnitRoot
Returns true if this syntax tree has a root with SyntaxKind "CompilationUnit".
Declaration
public abstract bool HasCompilationUnitRoot { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Length
The length of the text of the syntax tree.
Declaration
public abstract int Length { get; }
Property Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
Options
The options used by the parser to produce the syntax tree.
Declaration
public ParseOptions Options { get; }
Property Value
Methods
|
Improve this Doc
View Source
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.
Declaration
public abstract IList<TextSpan> GetChangedSpans(SyntaxTree syntaxTree)
Parameters
Returns
|
Improve this Doc
View Source
GetChanges(SyntaxTree)
Gets a list of text changes that when applied to the old tree produce this tree.
Declaration
public abstract IList<TextChange> GetChanges(SyntaxTree oldTree)
Parameters
Type |
Name |
Description |
SyntaxTree |
oldTree |
The old tree.
|
Returns
|
Improve this Doc
View Source
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.
Declaration
public abstract IEnumerable<Diagnostic> GetDiagnostics(CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
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.
Declaration
public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxNode node)
Parameters
Returns
|
Improve this Doc
View Source
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.
Declaration
public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxNodeOrToken nodeOrToken)
Parameters
Returns
|
Improve this Doc
View Source
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.
Declaration
public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxToken token)
Parameters
Returns
|
Improve this Doc
View Source
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.
Declaration
public abstract IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia)
Parameters
Returns
|
Improve this Doc
View Source
GetLineSpan(TextSpan, CancellationToken)
Gets the location in terms of path, line and column for a given span.
Declaration
public abstract FileLinePositionSpan GetLineSpan(TextSpan span, CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
TextSpan |
span |
Span within the tree.
|
CancellationToken |
cancellationToken |
Cancellation token.
|
Returns
|
Improve this Doc
View Source
GetLocation(TextSpan)
Gets a location for the specified text span.
Declaration
public abstract Location GetLocation(TextSpan span)
Parameters
Returns
|
Improve this Doc
View Source
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.
Declaration
public abstract SyntaxReference GetReference(SyntaxNode node)
Parameters
Returns
|
Improve this Doc
View Source
GetRoot(CancellationToken)
Gets the root node of the syntax tree, causing computation if necessary.
Declaration
public SyntaxNode GetRoot(CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
GetRootAsync(CancellationToken)
Gets the root node of the syntax tree asynchronously.
Declaration
public Task<SyntaxNode> GetRootAsync(CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
GetText(CancellationToken)
Gets the text of the source document.
Declaration
public abstract SourceText GetText(CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
GetTextAsync(CancellationToken)
Gets the text of the source document asynchronously.
Declaration
public virtual Task<SourceText> GetTextAsync(CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
IsEquivalentTo(SyntaxTree, Boolean)
Determines if two trees are the same, disregarding trivia differences.
Declaration
public abstract bool IsEquivalentTo(SyntaxTree tree, bool topLevel = false)
Parameters
Type |
Name |
Description |
SyntaxTree |
tree |
The tree to compare against.
|
System.Boolean |
topLevel |
If true then the trees are equivalent if the contained nodes and tokens declaring
metadata visible symbolic information are equivalent, ignoring any differences of nodes inside method bodies
or initializer expressions, otherwise all nodes and tokens must be equivalent.
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
ToString()
Returns a System.String that represents the entire source text of this SyntaxTree.
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.Object.ToString()
|
Improve this Doc
View Source
TryGetRoot(out SyntaxNode)
Gets the root of the syntax tree if it is available.
Declaration
public bool TryGetRoot(out SyntaxNode root)
Parameters
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
TryGetText(out SourceText)
Gets the syntax tree's text if it is available.
Declaration
public abstract bool TryGetText(out SourceText text)
Parameters
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
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.
Declaration
public abstract SyntaxTree WithChangedText(SourceText newText)
Parameters
Returns
|
Improve this Doc
View Source
WithFilePath(String)
Returns a new tree whose FilePath is the specified node and other properties are copied from the current tree.
Declaration
public abstract SyntaxTree WithFilePath(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
|
Returns
|
Improve this Doc
View Source
WithRootAndOptions(SyntaxNode, ParseOptions)
Returns a new tree whose root and options are as specified and other properties are copied from the current tree.
Declaration
public abstract SyntaxTree WithRootAndOptions(SyntaxNode root, ParseOptions options)
Parameters
Returns
Extension Methods