A VLS submodule dedicated for analyzing and extracting information from the Tree-sitter trees.
We're using the Tree-sitter parser to gracefully handle such operations that the current V tooling cannot do at this moment and because of this, we are recreating the whole process due to its incompatibility with the existing tools.
By using the tree traversal and node retrieval operations provided by the Tree-sitter API, we can extract information about a specific symbol and use it for later use (autocompletion, goto definition, and etc.)
The analyzer module does a variety of things required for understanding V code:
- Symbol registration
- Semantic/type analysis (aka diagnostics).
- Import analysis / module importation
- Import Analysis / Module Importation
- Scans the import nodes and list them inside an import list.
- Resolves the scanned imports by looking up the locations and registers them to a shared dependency graph.
- Imports the resolved imports.
- Clean up unused imports.
- Top-level Symbol declaration
- Registers all the top-level nodes (enums/functions/structs/consts/globals) into the store.
- Creates a scope tree for each block (except for the imported ones)
- Semantic / type checking
- Follows the rules implemented in
v.checker
- It strives to be modular as much as possible and provides abstractions for easy debugging and testing.
- It does not have dependencies in other VLS-specific modules with the exception of the Tree-sitter module.
- The
builtin
module and it's symbols are not automatically imported by the analyzer. They are therefore done by the consumers (tests, programs, applications) as they are the ones who know the exact location of it. - "Compiler magic"-specific features are handled.
- Translation of data such as position information and more are handled by the consumers of the module which is in this case is VLS.
- By "consumers", it means that it can be used outside VLS.
- IDE-specific features such as autocompletion are not handled by analyzer. Instead they are handled by VLS.