In This Article

TokenBase Class

Represents the base class for an IToken implementation.

public abstract class TokenBase : IToken
Inheritance:
object object
Derived:
MergeableToken
Implements:
IToken

Constructors

TokenBase(int, int, TextPosition, TextPosition)

Represents the base class for an IToken implementation.

protected TokenBase(int startOffset, int length, TextPosition startPosition, TextPosition endPosition)
Parameter Type Description
startOffset int

The start offset of the token.

length int

The length of the token.

startPosition TextPosition

The TextPosition of the first character in the token.

endPosition TextPosition

The TextPosition after the last character in the token.

Properties

EndOffset

The offset after the last character in the token.

public int EndOffset { get; }

Property Value

int

EndPosition

The TextPosition after the last character in the token.

public TextPosition EndPosition { get; }

Property Value

TextPosition

Id

The ID assigned to the token.

public abstract int Id { get; }

Property Value

int

Key

The key assigned to the token.

public virtual string? Key { get; }

Property Value

string

Length

The absolute length of the token.

public 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.

public virtual int LexicalStateId { get; }

Property Value

int

PositionRange

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

public TextPositionRange PositionRange { get; }

Property Value

TextPositionRange

StartOffset

The offset of the first character in the token.

public int StartOffset { get; set; }

Property Value

int

StartPosition

The TextPosition of the first character in the token.

public TextPosition StartPosition { get; }

Property Value

TextPosition

TextRange

A TextRange that specifies the text range of the token.

public TextRange TextRange { get; }

Property Value

TextRange

Methods

Contains(TextPosition)

Returns whether the IToken contains the specified TextPosition.

public 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.

public 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.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)
Parameter Type Description
obj object

The object to compare with the current object.

Returns

bool:

true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int:

A hash code for the current object.

ToString()

Returns the string representation of this object.

public override string ToString()

Returns

string:

The string representation of this object.

ToString(string)

Creates and returns a string representation of the current object.

public string ToString(string tokenDescription)
Parameter Type Description
tokenDescription string

The description of the IToken.

Returns

string

Inherited Members

Extension Methods