Hi,
I'm moving to version 4.0 from version 3.1.
In 3.1 I used a SemanticParser in the following way:
I created a new SemanticParser class that implements the PostParse Method and changes the HighlightingStyle of some specific tokens.In the main class when the language is loaded an event is thrown and I set the semantic parser :
The result was that any change in the text goes to the PostParse method and change the HighlightStyle of some tokens.
I understood that in version 4.0 there is no SemanticParser anymore and it was replaced in "DynamicSyntaxLanguage".
I made some changes in my old semantic parser class to support the changes:I am trying to do the following in the main class like before but the Language object does not have the SemanticParser property anymore:
What should I do in order to support the previous behaviour?
What code is parallel to this in 4.0 ?
Regards,
Dan
I'm moving to version 4.0 from version 3.1.
In 3.1 I used a SemanticParser in the following way:
I created a new SemanticParser class that implements the PostParse Method and changes the HighlightingStyle of some specific tokens.
public class SemanticHTTPRequestParser : SemanticDefaultParser
{
...
public override void PostParse(Document document, DocumentModification modification)
{
...
private HighlightingStyle requestLineBoldItemsHighlightingStyle = new HighlightingStyle("RequestLineBoldItemsKey", "RequestLineBoldItems", Color.Black, Color.WhiteSmoke, true, false, false);
...
Token token = document.Tokens.GetTokenAtOffset(document.Lines[lineNumber].StartOffset + charIndex);
if (token != null)
{
token.CustomHighlightingStyle = requestErrorMessageHighlightingStyle;
token.Modified = true;
}
...
}
...
}
private void syntaxEditorControl_DocumentSyntaxLanguageLoading(object sender, SyntaxLanguageEventArgs e)
{
e.Language.SemanticParser = semanticHTTPRequestParser; //already created in the Ctor.
}
I understood that in version 4.0 there is no SemanticParser anymore and it was replaced in "DynamicSyntaxLanguage".
I made some changes in my old semantic parser class to support the changes:
public class SemanticHTTPRequestParser : DynamicSyntaxLanguage
{
...
private HighlightingStyle requestLineBoldItemsHighlightingStyle = new HighlightingStyle("RequestLineBoldItemsKey", "RequestLineBoldItems", Color.Black, Color.WhiteSmoke, DefaultableBoolean.True, DefaultableBoolean.True, HighlightingStyleLineStyle.DashDot);
...
protected override void OnDocumentTextChanged(Document document, DocumentModificationEventArgs e)
{
IToken token = document.Tokens.GetTokenAtOffset(document.Lines[lineNumber].StartOffset + charIndex);
if (token != null)
{
DynamicToken dynamicToken = token as DynamicToken;
if(dynamicToken !=null)
{
dynamicToken.CustomHighlightingStyle = requestLineBoldItemsHighlightingStyle;
}
}
}
}
private void syntaxEditorControl_DocumentSyntaxLanguageLoading(object sender, SyntaxLanguageEventArgs e)
{
e.Language.SemanticParser = semanticHTTPRequestParser; //already created in the Ctor.
}
What code is parallel to this in 4.0 ?
Regards,
Dan
Dan Oren