Skip to content

chore: remove dead code - #977

Closed
psteinroe wants to merge 1 commit into
refactor/workspace-formattingfrom
chore/remove-dead-code
Closed

psteinroe wants to merge 1 commit into
refactor/workspace-formattingfrom
chore/remove-dead-code

Conversation

@psteinroe

@psteinroe psteinroe commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #975.

Removes code that nothing uses. I grepped for every item first. Clippy on the whole workspace is clean. pgls_workspace without the db feature has the same six warnings as before: ExecuteStatementMapper, TypecheckDiagnosticsMapper, IdFilter and Document::find are only used with db. Those are cfg-dependent, not dead, and this PR doesn't touch them.

Removed

  • AnnotationStore (pgls_workspace/src/workspace/server/annotation.rs). Every Document built one and pruned and cleared it with the parse and tree caches, but nothing read it. The field had #[allow(dead_code)], and get_annotations had #[allow(unused)]. Its only test tested the store itself.
  • pgls_hover::OnHoverParams::ast. Hover never read it, but the workspace looked up the statement's tree to pass it. on_hover now maps the statement with WithCSTMapper, and WithCSTandASTMapper, which had no other user, is gone.
  • HoveredNode::Trigger, which was never constructed (#[allow(unused)]).
  • Snapshot::find_types in pgls_catalog, which had no callers.
  • SQLFunctionSignature::schema, which was set but never read (#[allow(dead_code)]).
  • ClientInformation in pgls_lsp: initialize stored the client's name and version in the session, and nothing read them. They are still logged by the tracing::instrument on initialize.
  • print_markup in pgls_lsp/src/utils.rs (#[allow(unused)]). It was the last use of pgls_console in pgls_lsp, so that dependency goes too.

Simplified

In pgls_hover::on_hover, the table and type branches each had an arm for "no schema" and one for "schema" that only differed in passing None or Some(&s). They pass schema.as_deref() now, which is the same. The column branches really differ (alias resolution) and stay as they are.

Kept

  • Document::count and InitializeParams::workspace_folders had #[allow]s but are used (completions, workspace folder resolution). Only the attributes are removed.
  • Migration::name is only read by tests, HoveredNode::Policy's payload is never read, but the variant stops policy names from being hovered as other objects, the #[allow(unused_variables)] on the execute_statement without db and the MapHolder test struct are cfg- or test-only. They are not dead.

Tests

pgls_workspace, pgls_lsp, pgls_hover and pgls_catalog pass, and so does clippy on the whole workspace.

- `AnnotationStore`: every document built one and pruned it with the other caches, but nothing
  read it.
- `pgls_hover::OnHoverParams::ast`: hover never read it, and the workspace looked the tree up
  for it. Hover now uses `WithCSTMapper`, and `WithCSTandASTMapper` is gone.
- `HoveredNode::Trigger`, which was never constructed. The table and type branches of hover
  passed the optional schema through two arms each; they take `schema.as_deref()` now.
- `Snapshot::find_types`, `SQLFunctionSignature::schema` and the client information that the
  language server stored at `initialize` (it is still logged), none of which were read.
- `print_markup` in `pgls_lsp`, and with it the `pgls_console` dependency.
- Stale `#[allow]`s on `Document::count` and `InitializeParams::workspace_folders`, which are
  used.
@psteinroe

Copy link
Copy Markdown
Collaborator Author

Superseded by #989 (rebuild of the document caches and walk).

@psteinroe psteinroe closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant