github / semantic

Parsing, analyzing, and comparing source code across many languages
8.95k stars 454 forks source link

Proof of concept of "side channel" for diagnostics #639

Open alanz opened 3 years ago

alanz commented 3 years ago

Replaces ReaderC with StateC in Unmarshal, and checks for diagnostics at each visited node, kept in the state.

The diagnostic determination is dodgy, but the concept works

See https://gist.github.com/alanz/2ae23a75bba75ed09780d3fa043bd28e

Note: haskell-tree-sitter is a git dep, it needs a "git submodule update" in the appropriate "dist-newstyle/src" directory.

Related issues: #574 #638 .

Alternative approaches are to extend the query capabilities, as requested in https://github.com/tree-sitter/tree-sitter/issues/606

The ts_node_has_error and ts_node_is_missing_p calls are not the right ones, the detailed info comes from the logic in https://github.com/tree-sitter/tree-sitter/blob/2b0de9dfec62af7e74c319abe80912b02dca74be/lib/src/subtree.c#L846-L894

and

https://github.com/tree-sitter/tree-sitter/blob/2b0de9dfec62af7e74c319abe80912b02dca74be/lib/src/language.c#L67-L80