tree-sitter / tree-sitter-graph

Construct graphs from parsed source code

Home Page:https://docs.rs/tree-sitter-graph/*/tree_sitter_graph/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show where the rule matched for dynamic errors

robrix opened this issue · comments

I've got a duplicate edge error, which is discovered dynamically when running against some source file. How can this edge already exist? What node is it actually talking about? Who knows!

I'd like the error to include:

  1. Where the match in the source file began, along with an excerpt of (at least) the first line of that source (#84).
  2. Where the bound nodes were within the source, e.g. by picking a terminal-usable colour for each variable, drawing the variable's name in that, and drawing the corresponding span of the excerpt in that as well, with child nodes taking precedence over parent nodes colour-wise.
  3. What variables exist on the various nodes. (Maybe just the ones we've explicitly bound, although a REPL (#77) might allow one to get more.)