Partilhar via


SyntaxTrivia Struct

Definition

Represents a trivia in the syntax tree.

public value class SyntaxTrivia : IEquatable<Microsoft::CodeAnalysis::SyntaxTrivia>
[System.Diagnostics.DebuggerDisplay("{GetDebuggerDisplay(), nq}")]
public readonly struct SyntaxTrivia : IEquatable<Microsoft.CodeAnalysis.SyntaxTrivia>
[<System.Diagnostics.DebuggerDisplay("{GetDebuggerDisplay(), nq}")>]
type SyntaxTrivia = struct
Public Structure SyntaxTrivia
Implements IEquatable(Of SyntaxTrivia)
Inheritance
SyntaxTrivia
Attributes
Implements

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.

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.

HasStructure

Determines whether this trivia is a structured trivia.

IsDirective

Determines whether this trivia represents a preprocessor directive.

Language

The language name that this trivia is syntax of.

RawKind

An integer representing the language specific kind of this trivia.

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.

SpanStart

Same as accessing Start on Span.

SyntaxTree

SyntaxTree which contains current SyntaxTrivia.

Token

The parent token that contains this token in its LeadingTrivia or TrailingTrivia collection.

Methods

CopyAnnotationsTo(SyntaxTrivia)

Copies all SyntaxAnnotations, if any, from this SyntaxTrivia instance and attaches them to a new instance based on trivia.

Equals(Object)

Determines whether the supplied SyntaxTrivia is equal to this SyntaxTrivia.

Equals(SyntaxTrivia)

Determines whether the supplied SyntaxTrivia is equal to this SyntaxTrivia.

GetAnnotations(String)

Get all the annotations of the specified annotation kind.

GetAnnotations(String[])

Get all the annotations of the specified annotation kinds.

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.

GetHashCode()

Serves as hash function for SyntaxTrivia.

GetLocation()

Get the location of this trivia.

GetStructure()

Returns the child non-terminal node representing the syntax tree structure under this structured trivia.

HasAnnotation(SyntaxAnnotation)

Determines whether this trivia has the specific annotation.

HasAnnotations(String)

Determines where this trivia has annotations of the specified annotation kind.

HasAnnotations(String[])

Determines where this trivia has any annotations of the specified annotation kinds.

IsEquivalentTo(SyntaxTrivia)

Determines if this trivia is equivalent to the specified trivia.

IsPartOfStructuredTrivia()

Determines whether this trivia is a descendant of a structured trivia.

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.

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.

WithAdditionalAnnotations(IEnumerable<SyntaxAnnotation>)

Creates a new SyntaxTrivia with the specified annotations.

WithAdditionalAnnotations(SyntaxAnnotation[])

Creates a new SyntaxTrivia with the specified annotations.

WithoutAnnotations(IEnumerable<SyntaxAnnotation>)

Creates a new SyntaxTrivia without the specified annotations.

WithoutAnnotations(String)

Creates a new SyntaxTrivia without annotations of the specified kind.

WithoutAnnotations(SyntaxAnnotation[])

Creates a new SyntaxTrivia without the specified annotations.

WriteTo(TextWriter)

Writes the full text of this trivia to the specified TextWriter.

Operators

Equality(SyntaxTrivia, SyntaxTrivia)

Determines whether two SyntaxTrivias are equal.

Inequality(SyntaxTrivia, SyntaxTrivia)

Determines whether two SyntaxTrivias are unequal.

Extension Methods

Kind(SyntaxTrivia)

Returns SyntaxKind for SyntaxTrivia from RawKind property.

IsKind(SyntaxTrivia, SyntaxKind)

Determines if SyntaxTrivia is of a specified kind.

Kind(SyntaxTrivia)

Returns SyntaxKind for SyntaxTrivia from RawKind property.

IsKind(SyntaxTrivia, SyntaxKind)

Determines if SyntaxTrivia is of a specified kind.

Applies to