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 a new instance of the TokenSet
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 a new instance of the TokenSet
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
Gets the count of tokens that are stored in the token set.
FirstToken
Gets the first IToken in the set.
FirstTokenExtendsBack
Gets 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
Gets the last IToken in the set.
LastTokenExtendsForward
Gets whether the LastToken extends forward to another token set.
public bool LastTokenExtendsForward { get; }
Property Value
ParseContext
Gets 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:
An optional object that may be used to help provide context information when resuming incremental parsing near the end of this token set.
TextRange
Gets the TextRange for which tokens in this set are available.
public TextRange TextRange { get; set; }
Property Value
this[int]
Gets 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
Methods
GetEnumerator()
Retrieves an IEnumerator
object for the entire collection.
public IEnumerator<IToken> GetEnumerator()
Returns
- IEnumerator<IToken>:
An
IEnumerator
object for the entire collection
Remarks
Enumerators are intended to be used only to read data in the collection. Enumerators cannot be used to modify the underlying collection.
The enumerator does not have exclusive access to the collection.
When an enumerator is instantiated, it takes a snapshot of the current state of the collection.
If changes are made to the collection, such as adding, modifying or deleting elements, the
snapshot gets out of sync and the enumerator throws an InvalidOperationException
.
Two enumerators instantiated from the same collection at the same time can have
different snapshots of the collection.
IndexOf(int, int)
Returns the index of the IToken in the set that contains the specified offset, if any.
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, |