SyntaxTree Class
A parsed document: its text, the tree over it, and the diagnostics the parser produced.
public abstract class SyntaxTreeRemarks
Only a handful of members are left to a language: the text, the root, and how to make a new tree from either. Everything else here is answered from the immutable nodes alone.
Constructors
| Name | Description |
|---|---|
| SyntaxTree() |
SyntaxTree()
protected SyntaxTree()No documentation is available.
Properties
| Name | Description |
|---|---|
| FilePath | Gets the path the text came from, or null when it did not come from a file. |
| Length |
FilePath
Length
SyntaxTree.csMethods
| Name | Description |
|---|---|
| GetChangedSpans(SyntaxTree) | Gets the ranges of this tree that differ from oldTree. |
| GetChanges(SyntaxTree) | Describes how oldTree would have to change to become this one. |
| GetDiagnostics() | Gets every diagnostic in the tree, in source order. |
| GetDiagnostics(SyntaxNode) | Gets the diagnostics at or below node. |
| GetDiagnostics(SyntaxToken) | Gets the diagnostics on token and the trivia around it. |
| GetDiagnostics(SyntaxTrivia) | Gets the diagnostics on trivia. |
| GetLineSpan(TextSpan) | Converts span to line and character positions. |
| GetLocation(TextSpan) | Pairs span with the text it indexes into. |
| GetRoot() | Gets the root of the tree. |
| GetRootCore() | Gets the root of the tree. A language overrides this and offers its own typed GetRoot. |
| GetText() | Gets the text this tree was parsed from. |
| IsEquivalentTo(SyntaxTree?) | Determines whether the two trees have the same structure and text. |
| ToString() | |
| WithChangedText(SourceText) | Returns a tree over newText. |
| WithChangedTextCore(SourceText) | Returns a tree over newText. |
| WithRoot(SyntaxNode) | Returns a tree whose root is root and whose text is the text of that root. |
| WithRootCore(SyntaxNode) | Returns a tree whose root is root. |
GetChangedSpans(SyntaxTree)
SyntaxTree.csGets the ranges of this tree that differ from oldTree.
public virtual IReadOnlyList<TextSpan> GetChangedSpans(SyntaxTree oldTree)GetChanges(SyntaxTree)
SyntaxTree.csDescribes how oldTree would have to change to become this one.
public virtual IReadOnlyList<TextChange> GetChanges(SyntaxTree oldTree)GetDiagnostics overloads
GetDiagnostics()
SyntaxTree.csGets every diagnostic in the tree, in source order.
public virtual IReadOnlyList<Diagnostic> GetDiagnostics()Returns
Remarks
A language that keeps its diagnostics in a list of its own rather than on the nodes overrides this, so that a caller holding the tree through this type still sees them.
GetDiagnostics(SyntaxNode)
SyntaxTree.csGets the diagnostics at or below node.
public virtual IEnumerable<Diagnostic> GetDiagnostics(SyntaxNode node)GetDiagnostics(SyntaxToken)
SyntaxTree.csGets the diagnostics on token and the trivia around it.
public virtual IEnumerable<Diagnostic> GetDiagnostics(SyntaxToken token)GetDiagnostics(SyntaxTrivia)
SyntaxTree.csGets the diagnostics on trivia.
public virtual IEnumerable<Diagnostic> GetDiagnostics(SyntaxTrivia trivia)GetLineSpan(TextSpan)
SyntaxTree.csConverts span to line and character positions.
public virtual LinePositionSpan GetLineSpan(TextSpan span)GetLocation(TextSpan)
SyntaxTree.csGetRoot()
SyntaxTree.csGetRootCore()
Gets the root of the tree. A language overrides this and offers its own typed GetRoot.
protected abstract SyntaxNode GetRootCore()Returns
GetText()
Gets the text this tree was parsed from.
public abstract SourceText GetText()Returns
Remarks
The same instance every time: diagnostics compare the text they point into by reference, so a tree that returned a new one each call would produce diagnostics that never compare equal.
IsEquivalentTo(SyntaxTree?)
SyntaxTree.csDetermines whether the two trees have the same structure and text.
public virtual bool IsEquivalentTo(SyntaxTree? other)ToString()
SyntaxTree.csWithChangedText(SourceText)
SyntaxTree.csReturns a tree over newText.
public SyntaxTree WithChangedText(SourceText newText)WithChangedTextCore(SourceText)
Returns a tree over newText.
protected abstract SyntaxTree WithChangedTextCore(SourceText newText)WithRoot(SyntaxNode)
SyntaxTree.csReturns a tree whose root is root and whose text is the text of that root.
public SyntaxTree WithRoot(SyntaxNode root)WithRootCore(SyntaxNode)
Returns a tree whose root is root.
protected abstract SyntaxTree WithRootCore(SyntaxNode root)