Skip to content

feat(hover): show the resolved overload and column - #868

Merged
psteinroe merged 1 commit into
feat/inlay-hintsfrom
feat/hover-resolved-references
Oct 18, 2026
Merged

psteinroe merged 1 commit into
feat/inlay-hintsfrom
feat/hover-resolved-references

Conversation

@psteinroe

@psteinroe psteinroe commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Hover now uses the name resolver from #867. Before, it looked names up in the snapshot, so an overloaded function listed every overload and columns were guessed by name.

Before / after

create function pick(i integer) returns integer language sql immutable as 'select i';
create function pick(t text) returns text language sql immutable as 'select t';

select pick(1);
--     ^ hover

Before, hover showed both functions:

### `public.pick(i integer) → integer`
---
### `public.pick(t text) → text`

Now it shows only the overload that pick(1) resolves to:

### `public.pick(i integer) → integer`

How

  • walk_statements is a new workspace helper, extracted from pull_inlay_hints and shared with it. It walks the file like the analyser, with the Catalog and Session following the statements. Hover uses it to resolve the innermost statement at the cursor with collect_references, and passes the references whose span contains the cursor to pgls_hover (new field OnHoverParams::references).
  • pgls_hover maps a reference of the hovered kind to the snapshot object:
    • Functions: the snapshot function with the same schema, name and input argument types. Types created in the file are matched loosely, and it gives up if more than one candidate matches.
    • Columns of catalog relations: the column by schema, table and name, which covers aliases and unqualified columns in joins.
    • Relations: the table the search path resolves to.
    • CTE and subquery columns: they aren't in the snapshot, so they get a small hover with their inferred type (c.label, text - CTE column).
  • When there's no unique reference (ambiguous call or column, unknown types, an unparsable statement), hover falls back to the name-based lookup exactly as before. Without a database there's still no hover.
  • Hover now takes the innermost statement at the cursor, so it also works inside SQL function bodies. Before, the outer CREATE FUNCTION was used and the body was just a string literal to tree-sitter.

Risks

  • Each hover now walks the file up to the cursor and applies its DDL, as inlay hints already do. This is fine for typical files but adds cost to hover on very long ones.
  • Functions created in the file still show the reduced headline of the materialized snapshot (no argument list). That's unchanged, but now it's a single block.

Hover resolves the statement at the cursor with the catalog the
analyser sees and shows the function overload, column, or relation the
hovered name resolves to. CTE and subquery columns show their inferred
type. Without a unique reference, hover falls back to the name lookups.
Hover now uses the innermost statement, so it also works inside SQL
function bodies.
@psteinroe
psteinroe added this pull request to stack #869 October 18, 2026 08:04
@psteinroe
psteinroe removed this pull request from stack #869 October 18, 2026 15:19
Base automatically changed from refactor/catalog-references to feat/inlay-hints October 18, 2026 15:19
@psteinroe
psteinroe merged commit d33500b into feat/inlay-hints Oct 18, 2026
6 of 9 checks passed
@psteinroe
psteinroe deleted the feat/hover-resolved-references branch October 18, 2026 15:19
@psteinroe

Copy link
Copy Markdown
Collaborator Author

Folded into #861 (now one PR for inlay hints, resolved references and hover). GitHub shows this as merged into feat/inlay-hints, not main.

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