Repository navigation
Conversation
The analysis that the editor asks for, with every rule category and no rule selection, is kept in the document's cache under a CacheKey of the settings version, the project and the catalog base. It is dropped when the content changes. Code actions read it by reference instead of analysing the whole file on every cursor move. The analysis moves to server/analysis.rs as a DocumentAnalysis with private fields. The LSP now honours the code action context's only kinds.
This was referenced Oct 26, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #1003. Part of the rebuild described in #997 (point 4). Replaces #929.
Editors request code actions on every cursor move, and each request ran the whole analysis of the file: every lint and typecheck rule, over every statement. Right after an edit, the diagnostics had already run the same analysis. On a file with 20,000 statements that took seconds per cursor move.
What changed
DocumentCachegets the caches that depend on more than the text of the document, under oneCacheKey: the settings version, the project whose settings apply, and the catalog base (whose identity is the database snapshot's). When the key of a request differs from the cached one, all of them are dropped together. The settings version is bumped while the settings are write-locked (workspaces_mut), so nothing is cached for the old settings under the new version. The project is part of the key because a file can be opened by two projects with different settings (nested workspace folders).only/skipselection, is kept until the content changes (Document::update_content) or the key does. Requests with a rule selection, likecheck --onlyorfix_filewithonly, are not cached.server.rsintoserver/analysis.rs:analyse_documentreturns anArc<DocumentAnalysis>, whose fields are private, with what the diagnostics need (lint_diagnostics,syntax_diagnostics,disabled_rules,is_skipped,statements) instead of a four-element tuple.pull_file_diagnosticsand the database checks read it by reference, and the lint code actions look at the diagnostics under the cursor without copying the others.LinterDiagnosticand its advices deriveClone, so that the diagnostics can be converted out of the shared analysis, andRuleCategoriesderivesPartialEqto recognise the request for every category.context.onlyfor all actions (it already did for the fix-all action). Kinds are matched hierarchically, soquickfixincludesquickfix.pgls.banDropTable, and a request for quick fixes doesn't get theExecute Statementcommand.EXPLAIN and plpgsql_check diagnostics are not part of the cached analysis and are not affected.
Tests
code_actions_reuse_the_analysis: the code actions use the analysis that the diagnostics cached (the sameArc), an edit drops it, and turning a rule off in the settings removes its actions.test_lint_fix_code_actions(LSP): withonly: [quickfix]only the fix and the suppression come back, and withonly: [source.fixAll]nothing does.requested_kinds_are_hierarchical: the kind matching, including"", a prefix that isn't a whole segment, and the empty kind of the commands.pgls_workspace(includingprojects_have_their_own_nested_settings, which caught the project missing from the key) andpgls_lsppass, and clippy on the whole workspace.Cost
Memory: each open document keeps its last analysis (its diagnostics and per-statement facts) until the next edit, a settings change or a new snapshot. A budget across documents follows later in the stack. Timings for the whole stack are in its last PR.