This is a (mostly) language-agnostic command-line tool for generating LSIF data.
Currently supported languages:
- Graphql
- TypeScript
- JavaScript
- Java
Currently, only TypeScript support is precise enough.
Binary download for MacOS is available on the release tab.
Note: If you want to run it locally, you need to run clone_parsers to compile the program.
fast & parallelized:
| Repository | Index time | Lines | Code | Language |
|---|---|---|---|---|
| rome/Tools | ~2.1s | 277317 | 185412 | TypeScript |
| facebook/Jest | ~480ms | 85563 | 67512 | TypeScript |
| reduxjs/Redux | ~50ms | 4018 | 3028 | TypeScript |
Benchmarks were run on a 4-core MacBook Pro.
-
It uses treesitter to parse files and produce a treesitter AST.
-
With the language specific query file (in the
queriesdirectory), it finds the query matches using treesitter. (seesrc/analyzer/analyzer.rs) At the end of this step, it has found the following:- All definitions:
- The exact location (file and offset)
- Whether or not it was exported - Name and documentation
- All references:
- It's defintion if it was defined in the same file it was used
- Name and exact location (file and offset)
- All definitions:
For incremental indexing: At this step, we can keep a cache of refernces and definitions (even unlinked onces). After a commit, we only need to reparse the files that were modified, and update the cache accordingly, then move on to the next step to produce the graph. This can decrease the indexing time by half.
-
Once all files are analyzed, we can find the definition locations for each reference whose definition is in a different file. (see
src/indexer/indexer.rs) -
It produces the LSIF graph. (see
src/indexer/indexer.rs)
--
For a good example of what a query file looks like, see queries/typescript.scm; it is more complete that others.