In This Article

IToken Interface

Represents the base requirements for a token that has been assigned to a span of text by a lexer.

public interface IToken

Properties

EndOffset

The offset after the last character in the token.

int EndOffset { get; }

Property Value

int

EndPosition

The TextPosition after the last character in the token.

TextPosition EndPosition { get; }

Property Value

TextPosition

Id

The ID assigned to the token.

int Id { get; }

Property Value

int

Key

The key assigned to the token.

string? Key { get; }

Property Value

string

Length

The absolute length of the token.

int Length { get; set; }

Property Value

int

Remarks

The setter for this property is for internal use only. Altering its value will corrupt the ITextDocumentIToken collection.

LexicalStateId

The ID assigned to the lexical state that contains the token.

int LexicalStateId { get; }

Property Value

int

PositionRange

A TextPositionRange that specifies the text position range of the token.

TextPositionRange PositionRange { get; }

Property Value

TextPositionRange

StartOffset

The offset of the first character in the token.

int StartOffset { get; set; }

Property Value

int

StartPosition

The TextPosition of the first character in the token.

TextPosition StartPosition { get; }

Property Value

TextPosition

TextRange

A TextRange that specifies the text range of the token.

TextRange TextRange { get; }

Property Value

TextRange

Methods

Contains(TextPosition)

Returns whether the IToken contains the specified TextPosition.

bool Contains(TextPosition position)
Parameter Type Description
position TextPosition

The TextPosition to examine.

Returns

bool:

true if the IToken contains the specified TextPosition; otherwise, false.

Remarks

This method returns false if the position falls on the EndPosition position since this method indicates if the position is encompassed by the IToken.

Contains(int)

Returns whether the IToken contains the specified offset.

bool Contains(int offset)
Parameter Type Description
offset int

The offset to examine.

Returns

bool:

true if the IToken contains the specified offset; otherwise, false.

Remarks

This method returns false if the offset falls on the EndOffset offset since this method indicates if the offset is encompassed by the IToken.

Extension Methods