
In the documentation, it states that to register a TokenTaggerProvider, we should use a line similar to
language.RegisterService(new TokenTaggerProvider<EcmaScriptTokenTagger>());
We register the service inside of the XxxLanguageWithParser class
public class XxxSyntaxLanguageWithParser : XxxSyntaxLanguage
{
public XxxSyntaxLanguageWithParser()
{
RegisterService<IParser>(new XxxParser());
RegisterService<ITokenIdProvider>(new XxxTokenId());
// ...
RegisterService(new TokenTaggerProvider<IdentifierHighlightingClassificationTagger>());
}
}
When we run this code, our token tagger is never instantiated. If we update the code to include removal of the generated TokenTaggerProvider which is automatically registered in the XxxSyntaxLangage ctor, our implementation is used.
XxxSyntaxLanguage:
[System.CodeDom.Compiler.GeneratedCodeAttribute("LanguageDesigner", "12.2.573.0")]
public partial class XxxSyntaxLanguage : SyntaxLanguage {
/// <summary>
/// Initializes a new instance of the <c>XxxSyntaxLanguage</c> class.
/// </summary>
public XxxSyntaxLanguage () :
base("Yyy Xxx Language") {
// Create a classification type provider and register its classification types
XxxClassificationTypeProvider classificationTypeProvider = new XxxClassificationTypeProvider();
classificationTypeProvider.RegisterAll();
// Register an ILexer service that can tokenize text
this.RegisterService<ILexer>(new XxxLexer(classificationTypeProvider));
// Register an ICodeDocumentTaggerProvider service that creates a token tagger for
// each document using the language
this.RegisterService(new XxxTokenTaggerProvider(classificationTypeProvider));
// Register an IExampleTextProvider service that provides example text
this.RegisterService<IExampleTextProvider>(new XxxExampleTextProvider());
}
}
XxxSyntaxLanguageWithParser:
public class XxxSyntaxLanguageWithParser : XxxSyntaxLanguage
{
public XxxSyntaxLanguageWithParser()
{
UnregisterService<XxxTokenTaggerProvider>();
RegisterService<IParser>(new XxxParser());
RegisterService<ITokenIdProvider>(new XxxTokenId());
// ...
RegisterService(new TokenTaggerProvider<IdentifierHighlightingClassificationTagger>());
}
}
The XxxTokenTaggerProvider does not derive from TokenTaggerProvider{T}.
- Why do we have to remove the underlying provider to use our own when they are different implementations?
- Are we supposed to implement all of our token tagging in the supplied XxxClassificationTypeProvider via a partial class?
- As far as we can see, we are doing what the documentation says for registration. Are we doing something wrong?