In This Article

TokenTagger Class

An ITagger<T> implementation that provides ITokenTag and IClassificationTag objects based on a language's ILexer.

public class TokenTagger : TaggerBase<ITokenTag>, ITagger<ITokenTag>, ITagger<IClassificationTag>, ITaggerBase, IOrderable, IKeyedObject
Inheritance:
Object TaggerBase<ITokenTag> Object
Derived:
CSharpTokenTagger JavaScriptTokenTagger PythonTokenTagger VBTokenTagger XmlTokenTagger
Implements:
ITagger<ITokenTag> ITagger<IClassificationTag> ITaggerBase IOrderable IKeyedObject

Constructors

TokenTagger(ICodeDocument)

Initializes a new instance of the TokenTagger class.

public TokenTagger(ICodeDocument document)
Parameter Type Description
document ICodeDocument

The document to which this manager is attached.

Methods

ClassifyToken(IToken)

Returns an IClassificationType for the specified IToken, if one is appropriate.

public virtual IClassificationType ClassifyToken(IToken token)
Parameter Type Description
token IToken

The IToken to examine.

Returns

IClassificationType:

An IClassificationType for the specified IToken, if one is appropriate.

Remarks

The default implementation of this method automatically returns the classification type if the token is an IMergableToken.

GetTags(NormalizedTextSnapshotRangeCollection, Object)

Returns the tag ranges that intersect with the specified normalized snapshot ranges.

public override IEnumerable<TagSnapshotRange<ITokenTag>> GetTags(NormalizedTextSnapshotRangeCollection snapshotRanges, object parameter)
Parameter Type Description
snapshotRanges NormalizedTextSnapshotRangeCollection

The collection of normalized snapshot ranges.

parameter Object

An optional parameter that provides contextual information about the tag request.

Returns

IEnumerable<TagSnapshotRange<ITokenTag>>:

The tag ranges that intersect with the specified normalized snapshot ranges.

GetTokens(ILexer, TextSnapshotRange, Object, Boolean, out Int32)

Returns the ITokenSet containing the tokens that were parsed for the specified TextSnapshotRange.

protected ITokenSet GetTokens(ILexer lexer, TextSnapshotRange desiredSnapshotRange, object parseContext, bool canUpdateLineContexts, out int invalidateThroughOffset)
Parameter Type Description
lexer ILexer

The ILexer to use for token generation.

desiredSnapshotRange TextSnapshotRange

The TextSnapshotRange that should be examined.

parseContext Object

An optional object that may be used to help provide context information when resuming incremental parsing.

canUpdateLineContexts Boolean

Whether line contexts can be updated.

invalidateThroughOffset Int32

Returns the offset through which tokens were invalidated.

Returns

ITokenSet:

The ITokenSet containing the tokens that were parsed for the specified TextSnapshotRange.

OnClosed()

Occurs when the tagger is closed.

protected override void OnClosed()

RaiseTagsChanged(TagsChangedEventArgs)

Raises the TagsChanged event.

public void RaiseTagsChanged(TagsChangedEventArgs e)
Parameter Type Description
e TagsChangedEventArgs

A TagsChangedEventArgs that contains the event data.

Explicit Interface Implementations

ITagger<IClassificationTag>.GetTags(NormalizedTextSnapshotRangeCollection, Object)

Returns the tag ranges that intersect with the specified normalized snapshot ranges.

IEnumerable<TagSnapshotRange<IClassificationTag>> ITagger<IClassificationTag>.GetTags(NormalizedTextSnapshotRangeCollection snapshotRanges, object parameter)
Parameter Type Description
snapshotRanges NormalizedTextSnapshotRangeCollection

The collection of normalized snapshot ranges.

parameter Object

An optional parameter that provides contextual information about the tag request.

Returns

IEnumerable<TagSnapshotRange<IClassificationTag>>:

The tag ranges that intersect with the specified normalized snapshot ranges.

Inherited Members