Hello,
I have a syntax language class that needs to have DynamicLexicalPatternGroup's created and added to the language at run time that will be populated by a number DynamicLexicalPattern keywords that are accessed at run time.
In my test project I have added the code below in the syntax language constructor which I assume is an OK location to do so. If I watch postLexer the new pattern group has been added but when I view my sample text none of the lexical patterns are highlighted in red as I have specified, what am I missing?
Thanks
I have a syntax language class that needs to have DynamicLexicalPatternGroup's created and added to the language at run time that will be populated by a number DynamicLexicalPattern keywords that are accessed at run time.
In my test project I have added the code below in the syntax language constructor which I assume is an OK location to do so. If I watch postLexer the new pattern group has been added but when I view my sample text none of the lexical patterns are highlighted in red as I have specified, what am I missing?
Thanks
public PostSyntaxLanguage() :
base("Mastercam Post Language")
{
// Create a classification type provider and register its classification types
PostClassificationTypeProvider classificationTypeProvider = new PostClassificationTypeProvider();
classificationTypeProvider.RegisterAll();
ClassificationType systemClassificationType = new ClassificationType("System", "ClassificationType for system tokens");
classificationTypeProvider.Registry.Register(systemClassificationType, new HighlightingStyle(System.Windows.Media.Brushes.Red));
PostLexer postLexer = new PostLexer(classificationTypeProvider);
foreach (DynamicLexicalState s in postLexer.LexicalStates)
{
switch (s.Key)
{
case "Default":
DynamicLexicalPatternGroup systemPatternGroup = new DynamicLexicalPatternGroup(DynamicLexicalPatternType.Explicit, "System", systemClassificationType);
systemPatternGroup.CaseSensitivity = ActiproSoftware.Text.CaseSensitivity.Sensitive;
// Add some test data (TODO: pull in live list)
systemPatternGroup.Patterns.Add(new DynamicLexicalPattern("ToolTableDescription"));
systemPatternGroup.Patterns.Add(new DynamicLexicalPattern("ToolTableMillDiameter"));
systemPatternGroup.Patterns.Add(new DynamicLexicalPattern("PToolTableMillIteration"));
systemPatternGroup.Patterns.Add(new DynamicLexicalPattern("ToolTableLatheInsertName"));
systemPatternGroup.Patterns.Add(new DynamicLexicalPattern("ToolTableLatheInsertName"));
s.LexicalPatternGroups.Add(systemPatternGroup);
break;
}
}
// Register an ILexer service that can tokenize text
this.RegisterService<ILexer>(postLexer);
// Register an ICodeDocumentTaggerProvider service that creates a token tagger for
// each document using the language
this.RegisterService(new PostTokenTaggerProvider(classificationTypeProvider));
}