Skip to content

refactor(catalog): return resolved references from resolve - #867

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

psteinroe merged 1 commit into
feat/inlay-hintsfrom
refactor/catalog-references

Conversation

@psteinroe

@psteinroe psteinroe commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

resolve can now also return what the names of a statement resolve to, not just the errors. This replaces the narrow resolve::function_calls / ResolvedCall API from #861, so hover (#868) can use the resolver instead of name-only snapshot lookups.

API

  • ResolveParams::collect_references: bool. The linter passes false. When it's false, nothing is collected and nothing extra is allocated: FROM items only get a column source when collecting.
  • Resolution::references: Vec<Reference>, which is empty unless requested. Every variant has a location and a span (the possibly qualified name) relative to the statement:
    • Function { function, arguments }: what ResolvedCall held before.
    • Column { source, column }: source is a catalog Relation { schema, name }, a Cte { name } (the CTE's own name, not the alias it is referenced by) or a Subquery { alias }. column is the column as its source defines it: under its own name even if an alias renames it (users u(uid) → id). CTE and subquery columns carry their inferred type. Only the FROM item a column resolves to is followed, not where a CTE's columns come from in turn, so hover can say "column of CTE c".
    • Relation { relation }: catalog relations in FROM and the targets of INSERT/UPDATE/DELETE/COPY. CTEs referenced by name are not relations.
  • A reference is recorded only when a name resolves to exactly one object. Ambiguous columns, columns merged by USING, output-column names in ORDER BY, levels with FROM items whose columns aren't known, and unknown objects are all skipped.
  • Inlay hints now call resolve(.. collect_references: true ..) and keep only the Function references. Their behaviour and tests are unchanged.

Risk

The recording hooks sit in the column-ref and range-var resolution paths, next to the findings logic. A test checks that findings and database_only are identical with and without collection. All catalog and analyser tests pass, including the Postgres regression test (crates/pgls_analyser/tests/postgres_regress.rs), so typecheck findings are unchanged.

Not covered

INSERT target column lists, UPDATE SET targets, excluded/old/new, columns of functions in FROM and of aliased joins, and columns behind NATURAL joins get no column references.

Generalise the function call recording of the resolver into opt-in
references on Resolution: function calls, columns and relations that
resolve to exactly one object. Replaces resolve::function_calls; inlay
hints read the function references instead.
@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
@psteinroe
psteinroe merged commit 1e0514a into feat/inlay-hints Oct 18, 2026
6 of 9 checks passed
@psteinroe
psteinroe deleted the refactor/catalog-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