Skip to content

IntelliSense: alias.column completion (semantic resolver) [epic] #27

Closed

Description

@melonamin

Split out from #17. Tracking epic — do not start without a design doc.

Why this is an epic, not a follow-up

alias. completion requires a semantic resolver that understands:

  • FROM / JOIN scope introduction,
  • CTE visibility,
  • subquery and lateral scopes,
  • correlated references,
  • implicit alias shadowing.

This is a separate subsystem, not a completion-provider tweak.

Gate

Do not start before the basic IntelliSense issue ships and the flat-model refactor lands. A design doc at docs/design/semantic-resolver.md should precede any implementation work.

Activity

  1. added
    enhancement
    on Apr 12, 2026
  2. melonamin commented on Apr 21, 2026

    @melonamin
    MemberAuthor

    Closing — implemented. Gates from the issue are both satisfied (#26 shipped, #19 flat-model landed).

    Where it lives

    crates/flowscope-core/src/completion/context.rs:

    • `extract_qualifier()` at :1258 — parses the cursor prefix to find the qualifier before a `.` (trailing dot, mid-token, multi-dot `schema.table.`, UTF-8 boundaries, quoted identifiers)
    • `resolve_qualifier()` at :1417 — resolves against table aliases, bare table names, schema names, catalog names, and schema-qualified tables. Returns a `QualifierResolution` with target `ColumnLabel | SchemaTable | SchemaOnly`
    • `schema_tables_for_qualifier()` at :1363 — tables for a schema qualifier
    • `build_columns_for_table()` at :1322 — column filtering to the resolved table

    Scope collection is in `crates/flowscope-core/src/completion/ast_extractor.rs`, producing a flat `tables_in_scope: Vec`.

    Test coverage — `crates/flowscope-core/tests/completion_items.rs`

    Scope requirement from #27 Test Line
    FROM / JOIN scope `qualifier_alias_filters_columns` :649
    FROM / JOIN scope — exclusion `qualifier_alias_excludes_other_tables` :673
    Self-joins (aliased) `self_join_both_aliases_available` :1236
    Self-joins — filtering `self_join_alias_filters_correctly` :1254
    Case-insensitive aliasing `qualifier_alias_case_insensitive` :661
    Subquery scopes `qualifier_subquery_alias` :746
    Nested subqueries `nested_subquery_two_levels` :1288
    Correlated references `nested_subquery_correlated` :1328
    Correlated — EXISTS `nested_subquery_exists` :1308
    Schema qualifiers `qualifier_schema_only_shows_tables` :720
    Schema.table qualifiers `qualifier_schema_table_shows_columns` :732
    Prefix matching after dot `qualifier_alias_partial_prefix` :686
    Cross-statement alias reuse `alias_shadowing_across_statements` (new)

    Lateral aliases are covered by `completion_items_do_not_leak_lateral_aliases_across_statements` at :234 and the scoping suite.

    `cargo test -p flowscope-core --test completion_items` → 97 passed.

    Remaining gap — tracked separately in #41

    The "implicit alias shadowing" bullet from the original gate is genuinely not handled: when the same alias name is bound at multiple nesting levels within one statement, `tables_in_scope` unions both bindings rather than picking the enclosing scope. Two `#[ignore]`-d tests (`alias_shadowing_inner_subquery_wins`, `alias_shadowing_outer_scope_unaffected`) live in the repo as executable acceptance criteria for #41. Cross-statement shadowing already works via statement-level isolation.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions