
This seems like it should be a fairly basic and straight forward answer, but it is eluding me.
I have defined my own language. It has 3 pattern groups defined, we'll call it Pattern A, B, and Whitespace. Grammatically they will be presented as A + Whitespace + B.
The A pattern group has some Regex patterns, the B pattern group has some Explicit patterns.
In my SyntaxEditor, I am listening to SyntaxEditor.DocumentTextChanged. At that point I want to parse my A into a property and parse my B into a property. So I have two parse methods passing in the CurrentSnapshot.
I get a reader from that snapshot and then look at the tokens. The token for A matches and I get A. When it goes to parse the rest of the snapshot for B, it reads each character as a Token (a default token) rather than reading the entire token that matches one of the explicit patterns. Below is my code that I'm using to parse the snapshot for Pattern B.
private void parsePatternB(ITextSnapshot snapshot)
{
_myStuff = null;
var reader = snapshot.GetReader(0);
var token = reader.Token;
if (token.Id == TokenId.MyStuff)
{
_myStuff = reader.TokenText;
}
else
{
while (reader.GoToNextToken())
{
token = reader.Token;
if (token.Id != TokenId.MyStuff)
{
continue;
}
_myStuff= reader.TokenText;
break;
}
}
updateThings();
}
Is there an easier way to get my Tokens out of the CurrentSnapshot?