In This Article

TokenSet Class

Stores token data for a range of text.

public class TokenSet : ITokenSet, ITextRangeProvider
Inheritance:
object object
Implements:
ITokenSet ITextRangeProvider

Constructors

TokenSet(TextRange, IEnumerable<IToken>?, object?)

Initializes an instance of the class.

public TokenSet(TextRange textRange, IEnumerable<IToken>? tokens, object? parseContext)
Parameter Type Description
textRange TextRange

The TextRange for which tokens in this set are available.

tokens IEnumerable<IToken>

The enumerable collection of tokens to add to the set.

parseContext object

An optional object that may be used to help provide context information when resuming incremental parsing near the end of this token set.

TokenSet(TextRange, IEnumerable<TagSnapshotRange<ITokenTag>>?, object?)

Initializes an instance of the class.

public TokenSet(TextRange textRange, IEnumerable<TagSnapshotRange<ITokenTag>>? tagRanges, object? parseContext)
Parameter Type Description
textRange TextRange

The TextRange for which tokens in this set are available.

tagRanges IEnumerable<TagSnapshotRange<ITokenTag>>

The enumerable collection of token tag ranges to add to the set.

parseContext object

An optional object that may be used to help provide context information when resuming incremental parsing near the end of this token set.

Properties

Count

The count of tokens that are stored in the token set.

public int Count { get; }

Property Value

int

FirstToken

The first IToken in the set.

public IToken? FirstToken { get; }

Property Value

IToken

FirstTokenExtendsBack

Indicates whether the FirstToken extends back to another token set.

public bool FirstTokenExtendsBack { get; }

Property Value

bool:

true if the FirstToken extends back to another token set; otherwise, false.

LastToken

The last IToken in the set.

public IToken? LastToken { get; }

Property Value

IToken

LastTokenExtendsForward

Indicates whether the LastToken extends forward to another token set.

public bool LastTokenExtendsForward { get; }

Property Value

bool:

true if the LastToken extends forward to another token set; otherwise, false.

ParseContext

An optional object that may be used to help provide context information when resuming incremental parsing near the end of this token set.

public object? ParseContext { get; }

Property Value

object

TextRange

A TextRange that specifies the text range of the object.

public TextRange TextRange { get; }

Property Value

TextRange

this[int]

An IToken in the token set.

public IToken this[int index] { get; }
Parameter Type Description
index int

The index of the IToken to return.

Property Value

IToken

Methods

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<IToken> GetEnumerator()

Returns

IEnumerator<IToken>:

An enumerator that can be used to iterate through the collection.

IndexOf(int, int)

Returns the index of the IToken in the set that contains the specified offset; otherwise, -1.

public int IndexOf(int offset, int hintIndex)
Parameter Type Description
offset int

The offset for which to search.

hintIndex int

The hint index at which to begin searching; otherwise, -1.

Returns

int

Inherited Members

Extension Methods