
In my completion provider i am trying to get a token of the ITextReader:
The reader is filled with text, but i cant get ANY token from it. I am using a mergable lexer to get my tokens:
It uses our Antlr lexer:)
Syntax highlighting works fine, even i made a squiggle. ( i have implemented a parser too showing errors)
I thought the Mergable Lexer would create the tokens and store them somewhere. Maybe i should store them myself? Or should i attach the lexer to the reader somehow?
Regards
Martin
[Modified at 02/03/2010 07:14 AM]
// Get a snapshot reader and use it to see which token we're at
ITextSnapshotReader reader = view.GetReader();
IToken token = reader.Token;
// Quit if we are in a comment
if ((token != null && ( token.Id == Mediator.SL_COMMENT || token.Id == Mediator.ML_COMMENT)) )
return false;
if (token == null) { // TODO : doesnt work ever
reader.ReadCharacterReverse();
reader.GoToNextToken();
token = reader.Token;
}
BlaiseLexer lexer = new Meta.Parsing.BlaiseLexer();
string text = reader.GetSubstring(reader.Offset , reader.Length-reader.Offset);
Antlr.Runtime.IToken t = null;
lexer.LoadText(text, "");
t = lexer.NextToken();
if (t.Text != null) {
reader.Offset += t.Text.Length;
}
int tokenId = t.Type;
if (tokenId != IDE.Language.Mediator.Invalid) {
LexicalStateTokenData lsd = new LexicalStateTokenData(lexicalState, tokenId);
return new MergableLexerResult(ActiproSoftware.Text.RegularExpressions.MatchType.ExactMatch, lsd);
} else
return MergableLexerResult.NoMatch;
Syntax highlighting works fine, even i made a squiggle. ( i have implemented a parser too showing errors)
I thought the Mergable Lexer would create the tokens and store them somewhere. Maybe i should store them myself? Or should i attach the lexer to the reader somehow?
Regards
Martin
[Modified at 02/03/2010 07:14 AM]