Skip to content

Qualified references follow the Rust model (#124) - #126

Merged
Kinflou merged 7 commits into
masterfrom
feat/qualified-references
Nov 16, 2026
Merged

Kinflou merged 7 commits into
masterfrom
feat/qualified-references

Conversation

@Kinflou

@Kinflou Kinflou commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Qualified references follow the Rust model (#124)

Closes #124. Rule: Qualified references; core: ComlineProject/core#290 (merged as 69039e7, with the decisions comment).

What changes

  • Pins. core 69039e7, and generation e900919, comline-rust 768afc0 and comline-typescript a384b62, which are on the same core, so the tree has one comline-core.
  • Diagnostics, from core. analysis::names::Names builds the ProjectContext core reads from the files the server has (each file's declarations and text under its namespace, the dependencies the manifest declares) and runs core's Scope and check_references over it. reference::not-in-scope, reference::qualifier-not-in-scope and reference::defined-twice reach the editor through from_core, so their fixes are the existing fix_actions quick fixes ("Write User", "Import User as TypesUser"). Code, message, help and fix are core's.
    • A bare name another file declares keeps the editor's import::missing (several candidates, an alias, validators), so core's not-in-scope for the same name is not shown twice; every other not-in-scope is core's, with no second "unknown type" beside it.
    • Without a config.idp in view, a qualifier-not-in-scope is not reported: the qualifier may be a dependency's name (the same benefit of the doubt import::unresolved has).
  • Validation reads what core's compiler freezes. A file's qualified types are frozen as their resolved path from the package's root (Scope::frozen) before core's validation, as IncrementalInterpreter does, and ImportLookup::reaches is implemented (it defaulted to false, so a full path read as an unknown type): a path to a declaration of a schema the project holds, a schema that doesn't parse right now taken as declaring it. The lookups for a validator's targets, an alias, a type that carries data and imported bounds read a frozen name by its path first.
  • use of a directory, std or a dependency's name on its own is a name to qualify with and is no longer import::unresolved (as in core's check_imports).
  • Did you mean. use typse::User now suggests package::types (core#286), and the "Change ..." quick fix writes it.
  • Hover, go-to-definition, find-references, rename. Project::resolve is the file's scope as core reads it, for every form: a bare name through its use, types::User, b::Invoice through an alias, billing::api::Invoice walked down, package::types::User, std::http::Request, shared::models::Thing. The cursor resolves the whole path it ends; a qualifier segment is the module it stands for (a name a use brought in included), for hover and go-to-definition. After use package::types a bare User resolves to nothing. A hover's size block follows the files a full path reaches.
  • Completion (details below).
  • Code actions. The missing-use message and quick fix still write use package::types::User, never a namespace use followed by a bare name; where a use here already brought the schema in as a namespace, "Write types::User" is offered beside it. Auto-import completion writes the item use, or the qualified name where a namespace in scope reaches it.
  • Tests and docs. names (the four forms, freeze, reaches, bindings), the diagnostics and their fixes applied and re-checked, import::missing and the new second fix, the unresolved-import cases, project resolution and references, hover, definition, code actions and completion. Two existing cases moved with the rule: a whole-namespace use no longer imports every name (import_check, diagnostics), and a name declared nowhere is core's not-in-scope where it was core's "Unknown type". README section on the rule.

What completion offers

Position Offers
a type position, nothing typed primitives; the file's own types; names its uses import (an alias under its alias); the namespaces its uses brought in (types, b), which write types:: and ask for the next segment; types of other files, sorted after, as package::... auto-imports (the item use) or, where a namespace in scope reaches the schema, written through it (types::User, no new use); then the roots package::, parent::, self::, std:: and the dependencies
after a root (package::, shared::, std::) the next segment: modules below it, and the types of its schema
after a namespace in scope (types::, b::, billing::) the same, from what the name stands for; a name that isn't a qualifier (a declaration, an imported item) offers nothing
parent::, self:: within the package; self:: includes the file's own types

A bare User is not offered from a schema that only a whole-namespace use brought in.

CI

Tests run in CI.

Kinflou added 6 commits November 16, 2026 12:07
Pin core at 69039e7 (core#290): a whole-namespace use brings in only its name,
a full path from a root needs no use, and a path goes down from a name in
scope. The language server runs core's Scope and check_references over the
files it has instead of keeping a second rule.

- reference::not-in-scope, reference::qualifier-not-in-scope and
  reference::defined-twice reach the editor with core's fixes as quick fixes.
- A qualified type is frozen as its resolved path before validation, and
  ImportLookup::reaches answers for a path into a schema of the project.
- Hover, go-to-definition, find-references and rename resolve the whole path
  under the cursor; a name a use brought in is a module to hover and jump to.
- Completion in a type position offers the names in scope, the namespaces a
  use brought in and the roots, and completes the next segment after a root
  or a namespace.
- Add use, auto-import and the did-you-mean write item uses and package::
  paths; a missing name can also be written through a namespace in scope.
…tors, which still pin 14ce546"

This reverts commit e9703c4.
@Kinflou
Kinflou marked this pull request as ready for review November 16, 2026 15:34
…ares, not import::missing

The editor now says what comline check says. The two fixes, "Add use" and
"Write types::User" (or the alias a use imported it under), are attached to
core's diagnostic. import::missing stays only for a validator in a
@Validators list, which core's reference rule does not cover.
@Kinflou
Kinflou merged commit c2f070b into master Nov 16, 2026
21 checks passed
@Kinflou
Kinflou deleted the feat/qualified-references branch November 16, 2026 15:51
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.

Qualified references follow the Rust model: quick fix, completion, hover

1 participant