Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watch-based incremental code analysis #918

Open
Myriad-Dreamin opened this issue Nov 30, 2024 · 0 comments
Open

Watch-based incremental code analysis #918

Myriad-Dreamin opened this issue Nov 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Myriad-Dreamin
Copy link
Owner

Myriad-Dreamin commented Nov 30, 2024

There are two models for incremental code analysis:

  • run a file watcher, and check the project again if files changed.
  • perform (syntax/type) check files on demand, and reuse results if the analysis's inputs are not changed.

rust-analyzer currently uses the former model, and they are switching language queries to the latter one as much as possible, because we usually don't have to check all modules in a project to execute some specific language query.

tinymist currently uses the latter model, but we also see the benefit if tinymist also supports former one. If so, we can run code analysis only when the user saves files.

Examples/Questions

This will allow configuration "tinymist.codeAnalysisWhen" to specify how lazy the language server checks the code:

{
  "tinymist.diagnostics": "onSave",
  "tinymist.typeCheck": "onSave"
}

Question: we are missing a way to encode reference (name) of definition stably across editions.

#let f(x) = x;
#f // 1
#let f(x) = 1;
#f // 2
#let f(x) = x + 1;
#f // 3

When user edits the file to query code completion at 1, 2, or 3, tinymist must query the cached result of type checking and get the corresponding types of symbol. Currently, we use the typst::syntax::Span to encode the reference (name), but it will be soonly buggy if we only run type check on save, as the typst::syntax::Span doesn't resist changes of AST nodes at the same depth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant