Hi,
I've taken your previous advice and started to work on a very simple extension of the CsharpLanguage (add-on).
In a nutshell, i am trying to add ASP directive state into c#.
1) The state change works (so i correctly switchs to "TplState")
2) The highlighting works too.
3) My problem is that IsTemplateScopeEnded NEVER gets called.
Probably i am doing something wrong but i can't see it.
Below is the Example derived language:
I've taken your previous advice and started to work on a very simple extension of the CsharpLanguage (add-on).
In a nutshell, i am trying to add ASP directive state into c#.
1) The state change works (so i correctly switchs to "TplState")
2) The highlighting works too.
3) My problem is that IsTemplateScopeEnded NEVER gets called.
Probably i am doing something wrong but i can't see it.
Below is the Example derived language:
using System;
using System.Collections.Generic;
using System.Text;
using ActiproSoftware.SyntaxEditor.Addons.CSharp;
using ActiproSoftware.SyntaxEditor;
using ActiproSoftware.SyntaxEditor.Addons.Dynamic;
using System.Collections;
using System.Drawing;
namespace TestApplication
{
public class MyCSharp : CSharpSyntaxLanguage
{
public ILexicalState GwTemplateState
{
get
{
return LexicalStates["TplState"];
}
}
public MyCSharp()
{
IsUpdating = true;
HighlightingStyles.Add(new HighlightingStyle("TplDirectiveDelimiterStyle", null, Color.Black, Color.Yellow));
// Create a new lexical state
int number = LexicalStates.Count + 1 ;
DefaultLexicalState tplState = new DefaultLexicalState(number, "TplState");
tplState.DefaultHighlightingStyle = HighlightingStyles["TplDirectiveDelimiterStyle"];
tplState.LexicalScopes.Add(new ProgrammaticLexicalScope( IsTemplateScopeStarted , IsTemplateScopeEnded));
LexicalStates.Add(tplState);
DefaultLexicalState.ChildLexicalStates.Add(tplState);
IsUpdating = false;
}
public MatchType IsTemplateScopeStarted(ITextBufferReader reader, ILexicalScope lexicalScope, ref ITokenLexicalParseData lexicalParseData)
{
// If the character is a letter or digit...
if (reader.Peek() == '<')
{
reader.Read();
if (reader.Peek() == '%')
{
reader.Read();
//lexicalParseData = new GwTemplateStartToken(this, GwTemplateState);
lexicalParseData = new LexicalScopeAndIDTokenLexicalParseData(lexicalScope, 201);
return MatchType.ExactMatch;
}
reader.ReadReverse();
}
return MatchType.NoMatch;
}
public MatchType IsTemplateScopeEnded(ITextBufferReader reader, ILexicalScope lexicalScope, ref ITokenLexicalParseData lexicalParseData)
{
// If the character is a letter or digit...
if (reader.Read() == '%')
{
if (reader.Read() == '>')
{
//lexicalParseData = new LexicalStateAndIDTokenLexicalParseData(DefaultLexicalState, byte.Parse("0"));
lexicalParseData = new GwTemplateEndToken(this, DefaultLexicalState);
return MatchType.ExactMatch;
}
else
{
reader.ReadReverse();
reader.ReadReverse();
return MatchType.NoMatch;
}
}
else
{
reader.ReadReverse();
return MatchType.NoMatch;
}
}
}
}