This repository was archived by the owner on Mar 18, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is tree-sitter?
tree-sitter is a parser for ~15 programming languages (TypeScript, Go, Python, Java, etc.). It does not do analysis such as type checking - it only constructs a syntax tree and provides an API for walking the syntax tree.
What can basic-code-intel use it for?
.
(e.g.Bar
infoo.Bar
probably comes from thefoo
package/class/namespace)This PR
This PR supports jump-to-definition on local parameters and variables for 1 language (TypeScript) as a proof-of-concept. Further but similar work is necessary to support find-references and other languages.
Implementation of jump-to-definition
"Checking for a binding" is implemented with a tiny CSS-like EDSL involving what I call "selectors" rather than switch-statements and recursion. To see what this looks like, check out the TypeScript selector defined in
handler.ts
.Status of this work
I've been working on this here and there over the past 2 weeks and now that we're considering investing effort in non-basic-code-intel approaches in the near future, I figured I would checkpoint this work and make a PR out of it in case we come back to it later.
TODO
.wasm
and grammars to a file hosting site.wasm
files are compressed.delete()
the parser and tree when done with them (i.e. when a file is closed).delete()
the parser and tree after a timeout to safeguard against memory leaks