// Tokenizer just skips comments, so we are unable to detect whether typing is done inside a comment // Therefore we need to reparse and detect all comment tokens private List <Token> ParseCommentTokens() { var script = textDocument.DslScripts.Single(); var commentTokens = new List <Token>(); var tokenizerInternals = new TokenizerInternals(rhetosProjectContext.DslSyntax); try { var scriptPosition = 0; while (true) { TokenizerInternals.SkipWhitespaces(script.Script, ref scriptPosition); if (scriptPosition >= textDocument.Text.Length) { break; } var startPosition = scriptPosition; var token = tokenizerInternals.GetNextToken_ValueType(script, ref scriptPosition, _ => ""); token.DslScript = script; token.PositionInDslScript = startPosition; if (token.Type == TokenType.Comment) { commentTokens.Add(token); } } } catch { // we will ignore all errors as any relevant ones are captured by CreateTokenizerWithCapturedErrors() } return(commentTokens); }
//=========================================================================================== private static Token TestGetNextToken_ValueType(string dsl, ref int position) { var dslScript = new MockDslScript(dsl); return(TokenizerInternals.GetNextToken_ValueType(dslScript, ref position)); }