I have integrated the WPF Syntax Editor into my solution and everything is great but when I add a new DynamicLexicalPattern to an existing DynamicLexicalPatternGroup that pattern is added and seems fine using the debugger, but the patten doesn't get highlighted in the editor.
Details:
1. I have an DynamicLexicalPatternGroup defined in the definitions file.
2. I initialize it via code, by clearing the DynamicLexicalPatternGroup and adding hundreds of patterns to it.
3. The patterns added to it work fine and get highlighted.
4. At a later stage (a user imports a library) and new patterns need to be highlighted, so I fetch the existing DynamicLexicalPatternGroup and add another pattern to it, either using Add or Insert.
5. When looking in the debugger the new pattern is indeed added to the group and seems just like all of the other patterns.
6. But the new pattern doesn't get highlighted.
Code:
// Code was cleared from irrelevant lines.
void InitPatterns()
{
DynamicLexer dynamicLexer = (DynamicLexer)this.GetLexer();
DynamicLexicalPatternGroup functionPatternGroup = dynamicLexer.LexicalStates["Default"].LexicalPatternGroups["Function"];
functionPatternGroup.Patterns.Clear();
// Gets my functions whose identifiers need to be added.
List<MyFunctions> funcs= IQLanguageDB.AllLibraries;
// Iterate over all of the functions.
for (int i = 0; i < funcs.Count; i++)
{
DynamicLexicalPattern pattern = new DynamicLexicalPattern(funcs[i].Identifier);
functionPatternGroup.Patterns.Add(pattern);
}
}
// Code was cleared from irrelevant lines.
void AddAnotherFunction(string functionIdentifier)
{
DynamicLexer dynamicLexer = (DynamicLexer)this.GetLexer();
DynamicLexicalPatternGroup functionPatternGroup = dynamicLexer.LexicalStates["Default"].LexicalPatternGroups["Function"];
DynamicLexicalPattern pattern = new DynamicLexicalPattern(functionIdentifier);
functionPatternGroup.Patterns.Add(pattern);
}
Summary:
InitPatterns works but only if I run it once, if I run it twice then the words are no longer highlighted. AddAnotherFunction sometimes works one time but doesn't work again, meaning words do get add to the pattern group but they don't get highlighted.
Please help!
Details:
1. I have an DynamicLexicalPatternGroup defined in the definitions file.
2. I initialize it via code, by clearing the DynamicLexicalPatternGroup and adding hundreds of patterns to it.
3. The patterns added to it work fine and get highlighted.
4. At a later stage (a user imports a library) and new patterns need to be highlighted, so I fetch the existing DynamicLexicalPatternGroup and add another pattern to it, either using Add or Insert.
5. When looking in the debugger the new pattern is indeed added to the group and seems just like all of the other patterns.
6. But the new pattern doesn't get highlighted.
Code:
// Code was cleared from irrelevant lines.
void InitPatterns()
{
DynamicLexer dynamicLexer = (DynamicLexer)this.GetLexer();
DynamicLexicalPatternGroup functionPatternGroup = dynamicLexer.LexicalStates["Default"].LexicalPatternGroups["Function"];
functionPatternGroup.Patterns.Clear();
// Gets my functions whose identifiers need to be added.
List<MyFunctions> funcs= IQLanguageDB.AllLibraries;
// Iterate over all of the functions.
for (int i = 0; i < funcs.Count; i++)
{
DynamicLexicalPattern pattern = new DynamicLexicalPattern(funcs[i].Identifier);
functionPatternGroup.Patterns.Add(pattern);
}
}
// Code was cleared from irrelevant lines.
void AddAnotherFunction(string functionIdentifier)
{
DynamicLexer dynamicLexer = (DynamicLexer)this.GetLexer();
DynamicLexicalPatternGroup functionPatternGroup = dynamicLexer.LexicalStates["Default"].LexicalPatternGroups["Function"];
DynamicLexicalPattern pattern = new DynamicLexicalPattern(functionIdentifier);
functionPatternGroup.Patterns.Add(pattern);
}
Summary:
InitPatterns works but only if I run it once, if I run it twice then the words are no longer highlighted. AddAnotherFunction sometimes works one time but doesn't work again, meaning words do get add to the pattern group but they don't get highlighted.
Please help!