private void RebuidTokens() { CommentTable.Clear(); ClassfificationList.Clear(); QuickInfoList.Clear(); StructNameList.Clear(); BracePairList.Clear(); OutlineList.Clear(); ErrorList.Clear(); var snapshot = this.Buffer.CurrentSnapshot; var lexer = new FlatbufferLexer(new AntlrInputStream(snapshot.GetText())); foreach (var token in lexer.GetAllTokens()) { if (token.Type == FlatbufferLexer.COMMENT) { ClassfificationList.Add(new ClassificationSpan(new SnapshotSpan(snapshot, new Span(token.StartIndex, token.StopIndex - token.StartIndex + 1)), FBSComment)); var txt = token.Text; if (txt.StartsWith("//")) { txt = txt.Substring(2).Trim(); } else if (txt.StartsWith("/*")) { txt = txt.Substring(2, txt.Length - 4).Trim().Trim('*').Trim(); } var lines = txt.Split('\n'); for (int i = 0; i < lines.Length; i++) { CommentTable.Add(token.Line + i, txt); } } } lexer.Reset(); var parser = new FlatbufferParser(new CommonTokenStream(lexer)); parser.ErrorHandler = classificationErrorHandler; parser.RemoveErrorListeners(); parser.AddErrorListener(classificationErrorListener); parser.schema().Accept <int>(classificationVisitor); var dom = this.Buffer.Properties.GetProperty(typeof(ITextDocument)); if (dom != null) { filePath = (dom as ITextDocument).FilePath; FBSProject builder = new FBSProject("", new string[] { filePath }, ErrorReport); builder.Build(filePath, snapshot.GetText()); } ClassificationChanged?.Invoke(this, new ClassificationChangedEventArgs(new SnapshotSpan(snapshot, 0, snapshot.Length))); }
private void RebuidTokens() { CommentTable.Clear(); ClassfificationList.Clear(); StructNameList.Clear(); BracePairList.Clear(); OutlineList.Clear(); ErrorList.Clear(); var snapshot = this.Buffer.CurrentSnapshot; var lexer = new TemplateLexer(new AntlrInputStream(snapshot.GetText())); var parser = new TemplateParser(new CommonTokenStream(lexer)); //parser.ErrorHandler = classificationErrorHandler; //parser.RemoveErrorListeners(); //parser.AddErrorListener(classificationErrorListener); parser.document().Accept <int>(classificationVisitor); FlagAllHiddenToken(snapshot, lexer); //ClassificationChanged?.Invoke(this, new ClassificationChangedEventArgs(new SnapshotSpan(snapshot, 0, snapshot.Length))); }