LSP: Implement a cache for typechecking (Serokell, Milestone-1) #4931
+205
−34
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.
In order to improve the performance of the LSP server we need to be able to cache and pass cached the type checking context (
Scope.t
). It's helpful in two situations:mo:base
) is parsed and type-checked as many times as it's imported (transitively) in any other file. Caching fixes this by allowing dependency type information to be reused.Changes:
src/pipeline/
load_progs_cached
/chase_imports_cached
that are likeload_progs
/chase_imports
but also take the scope cache and populates it. Note, expiring logic is implemented in the TS part of the server, see adjoint MR: Benchmarks & Dependecies' types caching (Serokell, Milestone-1) vscode-motoko#329).src/js
(IDE API)parseMotokoTyped paths
which returns typed AST withparseMotokoTyped path scopeCache
which returns typed AST and updatedscopeCache
parseMotokoWithDeps
which is likeparseMotoko
but also returns a list of immediate importsSee also interface changes in the
node-motoko
: dfinity/node-motoko#113