Struct SyntaxTrivia
Represents a trivia in the syntax tree.
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Assembly: cs.temp.dll.dll
Syntax
public readonly struct SyntaxTrivia
Properties
ContainsDiagnostics
Determines whether this trivia has any diagnostics on it. If this trivia is a structured trivia then the
returned value will indicate whether this trivia or any of its descendant nodes, tokens or trivia have any
diagnostics on them.
Declaration
public readonly bool ContainsDiagnostics { get; }
Property Value
Type |
Description |
System.Boolean |
|
FullSpan
The absolute span of this trivia in characters. If this trivia is a structured trivia then the returned span
will include spans of any leading or trailing trivia present on the child non-terminal node of this trivia.
Declaration
public readonly TextSpan FullSpan { get; }
Property Value
Type |
Description |
TextSpan |
|
HasStructure
Determines whether this trivia is a structured trivia.
Declaration
public readonly bool HasStructure { get; }
Property Value
Type |
Description |
System.Boolean |
|
IsDirective
Determines whether this trivia represents a preprocessor directive.
Declaration
public readonly bool IsDirective { get; }
Property Value
Type |
Description |
System.Boolean |
|
Language
The language name that this trivia is syntax of.
Declaration
public readonly string Language { get; }
Property Value
Type |
Description |
System.String |
|
RawKind
An integer representing the language specific kind of this trivia.
Declaration
public readonly int RawKind { get; }
Property Value
Type |
Description |
System.Int32 |
|
Span
The absolute span of this trivia in characters. If this trivia is a structured trivia then the returned span
will not include spans of any leading or trailing trivia present on the child non-terminal node of this
trivia.
Declaration
public readonly TextSpan Span { get; }
Property Value
Type |
Description |
TextSpan |
|
SpanStart
Same as accessing on Span.
Declaration
public readonly int SpanStart { get; }
Property Value
Type |
Description |
System.Int32 |
|
SyntaxTree
SyntaxTree which contains current SyntaxTrivia.
Declaration
public readonly SyntaxTree SyntaxTree { get; }
Property Value
Token
The parent token that contains this token in its LeadingTrivia or TrailingTrivia collection.
Declaration
public readonly SyntaxToken Token { get; }
Property Value
Methods
CopyAnnotationsTo(SyntaxTrivia)
Copies all SyntaxAnnotations, if any, from this SyntaxTrivia instance and attaches them to a new instance based on trivia
.
Declaration
public readonly SyntaxTrivia CopyAnnotationsTo(SyntaxTrivia trivia)
Parameters
Returns
Equals(SyntaxTrivia)
Declaration
public readonly bool Equals(SyntaxTrivia other)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Equals(Object)
Declaration
public override readonly bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.ValueType.Equals(System.Object)
GetAnnotations(String)
Get all the annotations of the specified annotation kind.
Declaration
public readonly IEnumerable<SyntaxAnnotation> GetAnnotations(string annotationKind)
Parameters
Type |
Name |
Description |
System.String |
annotationKind |
|
Returns
GetAnnotations(String[])
Get all the annotations of the specified annotation kinds.
Declaration
public readonly IEnumerable<SyntaxAnnotation> GetAnnotations(params string[] annotationKinds)
Parameters
Type |
Name |
Description |
System.String[] |
annotationKinds |
|
Returns
GetDiagnostics()
Gets a list of all the diagnostics associated with this trivia.
This method does not filter diagnostics based on #pragmas and compiler options
like nowarn, warnaserror etc.
Declaration
public readonly IEnumerable<Diagnostic> GetDiagnostics()
Returns
GetHashCode()
Declaration
public override readonly int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.ValueType.GetHashCode()
GetLocation()
Get the location of this trivia.
Declaration
public readonly Location GetLocation()
Returns
GetStructure()
Returns the child non-terminal node representing the syntax tree structure under this structured trivia.
Declaration
public readonly SyntaxNode GetStructure()
Returns
Type |
Description |
SyntaxNode |
The child non-terminal node representing the syntax tree structure under this structured
trivia.
|
HasAnnotation(SyntaxAnnotation)
Determines whether this trivia has the specific annotation.
Declaration
public readonly bool HasAnnotation(SyntaxAnnotation annotation)
Parameters
Returns
Type |
Description |
System.Boolean |
|
HasAnnotations(String)
Determines where this trivia has annotations of the specified annotation kind.
Declaration
public readonly bool HasAnnotations(string annotationKind)
Parameters
Type |
Name |
Description |
System.String |
annotationKind |
|
Returns
Type |
Description |
System.Boolean |
|
HasAnnotations(String[])
Determines where this trivia has any annotations of the specified annotation kinds.
Declaration
public readonly bool HasAnnotations(params string[] annotationKinds)
Parameters
Type |
Name |
Description |
System.String[] |
annotationKinds |
|
Returns
Type |
Description |
System.Boolean |
|
IsEquivalentTo(SyntaxTrivia)
Determines if this trivia is equivalent to the specified trivia.
Declaration
public readonly bool IsEquivalentTo(SyntaxTrivia trivia)
Parameters
Returns
Type |
Description |
System.Boolean |
|
IsPartOfStructuredTrivia()
Determines whether this trivia is a descendant of a structured trivia.
Declaration
public readonly bool IsPartOfStructuredTrivia()
Returns
Type |
Description |
System.Boolean |
|
ToFullString()
Returns the full string representation of this trivia. If this trivia is structured trivia then the returned string will
include any leading or trailing trivia present on the StructuredTriviaSyntax node of this trivia.
Declaration
public readonly string ToFullString()
Returns
Type |
Description |
System.String |
The full string representation of this trivia.
|
ToString()
Returns the string representation of this trivia. If this trivia is structured trivia then the returned string
will not include any leading or trailing trivia present on the StructuredTriviaSyntax node of this trivia.
Declaration
public override readonly string ToString()
Returns
Type |
Description |
System.String |
The string representation of this trivia.
|
Overrides
System.ValueType.ToString()
WithAdditionalAnnotations(IEnumerable<SyntaxAnnotation>)
Creates a new SyntaxTrivia with the specified annotations.
Declaration
public readonly SyntaxTrivia WithAdditionalAnnotations(IEnumerable<SyntaxAnnotation> annotations)
Parameters
Returns
WithAdditionalAnnotations(SyntaxAnnotation[])
Creates a new SyntaxTrivia with the specified annotations.
Declaration
public readonly SyntaxTrivia WithAdditionalAnnotations(params SyntaxAnnotation[] annotations)
Parameters
Returns
WithoutAnnotations(IEnumerable<SyntaxAnnotation>)
Creates a new SyntaxTrivia without the specified annotations.
Declaration
public readonly SyntaxTrivia WithoutAnnotations(IEnumerable<SyntaxAnnotation> annotations)
Parameters
Returns
WithoutAnnotations(SyntaxAnnotation[])
Creates a new SyntaxTrivia without the specified annotations.
Declaration
public readonly SyntaxTrivia WithoutAnnotations(params SyntaxAnnotation[] annotations)
Parameters
Returns
WithoutAnnotations(String)
Creates a new SyntaxTrivia without annotations of the specified kind.
Declaration
public readonly SyntaxTrivia WithoutAnnotations(string annotationKind)
Parameters
Type |
Name |
Description |
System.String |
annotationKind |
|
Returns
WriteTo(TextWriter)
Writes the full text of this trivia to the specified TextWriter.
Declaration
public readonly void WriteTo(TextWriter writer)
Parameters
Type |
Name |
Description |
System.IO.TextWriter |
writer |
|
Operators
Equality(SyntaxTrivia, SyntaxTrivia)
Declaration
public static bool operator ==(SyntaxTrivia left, SyntaxTrivia right)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Inequality(SyntaxTrivia, SyntaxTrivia)
Declaration
public static bool operator !=(SyntaxTrivia left, SyntaxTrivia right)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Implements
IEquatable<>