Skip to content

chore: remove dead code - #989

Open
psteinroe wants to merge 1 commit into
refactor/workspace-formatting-rebuildfrom
chore/remove-dead-code-rebuild
Open

psteinroe wants to merge 1 commit into
refactor/workspace-formatting-rebuildfrom
chore/remove-dead-code-rebuild

Conversation

@psteinroe

Copy link
Copy Markdown
Collaborator

Stacked on #988.

Removes code that nothing uses. I grepped for every item first. Clippy on the whole workspace is clean.

Removed

  • AnnotationStore (pgls_workspace/src/workspace/server/annotation.rs). Every Document built one and pruned 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.
  • 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.
  • InitializeParams::workspace_folders in pgls_lsp's session (#[allow(unused)]). The session keeps the workspace folders in a field of its own, which is what everything reads.
  • The pgls_console dependency of pgls_lsp, which nothing in the crate uses any more.

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 had an #[allow] but is used (completions). Only the attribute is 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 schema-only structs 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.

Update: This is #977 again, rebuilt on #988 for the rebuild of the document caches and the walk. Since #977 was opened, print_markup was already removed on main, and InitializeParams::workspace_folders became unused because the session now keeps the folders separately, so it is removed here instead of kept. SQLFunctionSignature no longer exists on main.

Removes AnnotationStore, the unused ast of hover's parameters with
WithCSTandASTMapper, HoveredNode::Trigger, Snapshot::find_types, the
client information and workspace folders that the LSP session stored
without reading them, and the pgls_console dependency of pgls_lsp.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant