Struct SyntaxTokenList
Represents a read-only list of SyntaxToken.
Inherited Members
Namespace: Loretta.CodeAnalysis
Assembly: Loretta.CodeAnalysis.dll
Syntax
public readonly struct SyntaxTokenList
Constructors
| Improve this Doc View SourceSyntaxTokenList(SyntaxToken)
Creates a new token list with the provided token as its only element.
Declaration
public SyntaxTokenList(SyntaxToken token)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | token |
SyntaxTokenList(SyntaxToken[])
Creates a list of tokens.
Declaration
public SyntaxTokenList(params SyntaxToken[] tokens)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken[] | tokens | An array of tokens. |
SyntaxTokenList(IEnumerable<SyntaxToken>)
Creates a list of tokens.
Declaration
public SyntaxTokenList(IEnumerable<SyntaxToken> tokens)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable<SyntaxToken> | tokens |
Properties
| Improve this Doc View SourceCount
Returns the number of tokens in the list.
Declaration
public readonly int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
FullSpan
The absolute span of the list elements in characters, including the leading and trailing trivia of the first and last elements.
Declaration
public readonly TextSpan FullSpan { get; }
Property Value
Type | Description |
---|---|
TextSpan |
Item[Int32]
Gets the token at the specified index.
Declaration
public readonly SyntaxToken this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the token to get. |
Property Value
Type | Description |
---|---|
SyntaxToken | The token at the specified index. |
Span
The absolute span of the list elements in characters, not including the leading and trailing trivia of the first and last elements.
Declaration
public readonly TextSpan Span { get; }
Property Value
Type | Description |
---|---|
TextSpan |
Methods
| Improve this Doc View SourceAdd(SyntaxToken)
Creates a new SyntaxTokenList with the specified token added to the end.
Declaration
public readonly SyntaxTokenList Add(SyntaxToken token)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | token | The token to add. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
AddRange(IEnumerable<SyntaxToken>)
Creates a new SyntaxTokenList with the specified tokens added to the end.
Declaration
public readonly SyntaxTokenList AddRange(IEnumerable<SyntaxToken> tokens)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.IEnumerable<SyntaxToken> | tokens | The tokens to add. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
Any()
Tests whether the list is non-empty.
Declaration
public readonly bool Any()
Returns
Type | Description |
---|---|
System.Boolean | True if the list contains any tokens. |
Create(SyntaxToken)
Create a new Token List
Declaration
public static SyntaxTokenList Create(SyntaxToken token)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | token | Element of the return Token List |
Returns
Type | Description |
---|---|
SyntaxTokenList |
Equals(SyntaxTokenList)
Declaration
public readonly bool Equals(SyntaxTokenList other)
Parameters
Type | Name | Description |
---|---|---|
SyntaxTokenList | other |
Returns
Type | Description |
---|---|
System.Boolean |
Equals(Object)
Compares this SyntaxTokenList with the obj
for equality.
Declaration
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean | True if the two objects are equal. |
Overrides
First()
Returns the first token in the list.
Declaration
public readonly SyntaxToken First()
Returns
Type | Description |
---|---|
SyntaxToken | The first token in the list. |
GetEnumerator()
Returns an enumerator for the tokens in the SyntaxTokenList
Declaration
public readonly SyntaxTokenList.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
SyntaxTokenList.Enumerator |
GetHashCode()
Serves as a hash function for the SyntaxTokenList
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
IndexOf(SyntaxToken)
Retuns the index of the provided token in this list.
Declaration
public readonly int IndexOf(SyntaxToken tokenInList)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | tokenInList |
Returns
Type | Description |
---|---|
System.Int32 | -1 if not found. |
Insert(Int32, SyntaxToken)
Creates a new SyntaxTokenList with the specified token insert at the index.
Declaration
public readonly SyntaxTokenList Insert(int index, SyntaxToken token)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index to insert the new token. |
SyntaxToken | token | The token to insert. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
InsertRange(Int32, IEnumerable<SyntaxToken>)
Creates a new SyntaxTokenList with the specified tokens insert at the index.
Declaration
public readonly SyntaxTokenList InsertRange(int index, IEnumerable<SyntaxToken> tokens)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index to insert the new tokens. |
System.Collections.IEnumerable<SyntaxToken> | tokens | The tokens to insert. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
Last()
Returns the last token in the list.
Declaration
public readonly SyntaxToken Last()
Returns
Type | Description |
---|---|
SyntaxToken | The last token in the list. |
Remove(SyntaxToken)
Creates a new SyntaxTokenList with the specified token removed.
Declaration
public readonly SyntaxTokenList Remove(SyntaxToken tokenInList)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | tokenInList | The token to remove. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
RemoveAt(Int32)
Creates a new SyntaxTokenList with the token at the specified index removed.
Declaration
public readonly SyntaxTokenList RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the token to remove. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
Replace(SyntaxToken, SyntaxToken)
Creates a new SyntaxTokenList with the specified token replaced with a new token.
Declaration
public readonly SyntaxTokenList Replace(SyntaxToken tokenInList, SyntaxToken newToken)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | tokenInList | The token to replace. |
SyntaxToken | newToken | The new token. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
ReplaceRange(SyntaxToken, IEnumerable<SyntaxToken>)
Creates a new SyntaxTokenList with the specified token replaced with new tokens.
Declaration
public readonly SyntaxTokenList ReplaceRange(SyntaxToken tokenInList, IEnumerable<SyntaxToken> newTokens)
Parameters
Type | Name | Description |
---|---|---|
SyntaxToken | tokenInList | The token to replace. |
System.Collections.IEnumerable<SyntaxToken> | newTokens | The new tokens. |
Returns
Type | Description |
---|---|
SyntaxTokenList |
Reverse()
Returns a list which contains all elements of SyntaxTokenList in reversed order.
Declaration
public readonly SyntaxTokenList.Reversed Reverse()
Returns
Type | Description |
---|---|
SyntaxTokenList.Reversed | SyntaxTokenList.Reversed which contains all elements of SyntaxTokenList in reversed order |
ToFullString()
Returns the full string representation of the tokens in this list including the first token's leading trivia and the last token's trailing trivia.
Declaration
public readonly string ToFullString()
Returns
Type | Description |
---|---|
System.String | The full string representation of the tokens in this list including the first token's leading trivia and the last token's trailing trivia. |
ToString()
Returns the string representation of the tokens in this list, not including the first token's leading trivia and the last token's trailing trivia.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
System.String | The string representation of the tokens in this list, not including the first token's leading trivia and the last token's trailing trivia. |
Overrides
Operators
| Improve this Doc View SourceEquality(SyntaxTokenList, SyntaxTokenList)
Compares left
and right
for equality.
Declaration
public static bool operator ==(SyntaxTokenList left, SyntaxTokenList right)
Parameters
Type | Name | Description |
---|---|---|
SyntaxTokenList | left | |
SyntaxTokenList | right |
Returns
Type | Description |
---|---|
System.Boolean | True if the two SyntaxTokenLists are equal. |
Inequality(SyntaxTokenList, SyntaxTokenList)
Compares left
and right
for inequality.
Declaration
public static bool operator !=(SyntaxTokenList left, SyntaxTokenList right)
Parameters
Type | Name | Description |
---|---|---|
SyntaxTokenList | left | |
SyntaxTokenList | right |
Returns
Type | Description |
---|---|
System.Boolean | True if the two SyntaxTokenLists are not equal. |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
readonly IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |