Skip to content

Commit

Permalink
Fix collision issue as "Refs" contains both applied and defining occu…
Browse files Browse the repository at this point in the history
…rrences.
  • Loading branch information
kaby76 committed Sep 5, 2023
1 parent a154545 commit 2fdb4f8
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/LspServer/LanguageServerTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ public void TextDocumentDidOpenName(JToken arg)
using (ParseTreeEditing.AntlrDOM.AntlrDynamicContext dynamicContext =
ate.Try(prs.Nodes, prs.Parser))
{
prs.ParserDefs.Clear();
prs.LexerDefs.Clear();
prs.Refs.Clear();
{
var expr = "//parserRuleSpec/RULE_REF";
var nodes = engine.parseExpression(expr,
Expand Down Expand Up @@ -1667,10 +1670,24 @@ public SemanticTokens SemanticTokens(JToken arg)
List<object> symbols = new List<object>();
List<uint> d = new List<uint>();
SortedList<int, IParseTree> sorted_symbols = new SortedList<int, IParseTree>();
foreach (var n in prs.ParserDefs) sorted_symbols.Add(prs.Parser.TokenStream.Get(n.SourceInterval.a).StartIndex, n);
foreach (var n in prs.LexerDefs) sorted_symbols.Add(prs.Parser.TokenStream.Get(n.SourceInterval.a).StartIndex, n);
foreach (var n in prs.Refs) sorted_symbols.Add(prs.Parser.TokenStream.Get(n.SourceInterval.a).StartIndex, n);

foreach (var n in prs.Refs)
{
try
{
var a = n.SourceInterval.a;
var t = prs.Parser.TokenStream.Get(n.SourceInterval.a);
var si = t.StartIndex;
Logger.Log.WriteLine("loop " + n.ToString());
Logger.Log.WriteLine("a " + a);
Logger.Log.WriteLine("t " + t);
Logger.Log.WriteLine("si + " + si);
sorted_symbols.Add(si, n);
}
catch (Exception e)
{
Logger.Log.WriteLine("catch e " + e);
}
}
(int,int) start = (1, 0);

foreach (var pair in sorted_symbols)
Expand Down

0 comments on commit 2fdb4f8

Please sign in to comment.