Skip to content

Add compiler-backed definition navigation - #38

Open
serene1491 wants to merge 2 commits into
masterfrom
tooling/project-snapshots-navigation
Open

Add compiler-backed definition navigation#38
serene1491 wants to merge 2 commits into
masterfrom
tooling/project-snapshots-navigation

Conversation

@serene1491

@serene1491 serene1491 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Add compiler-backed go-to-definition for namespace-scope functions and
statically resolved direct calls in the private Pop Lang language server.

The compiler now preserves the exact callee span through typed bodies and HIR,
then publishes a bounded tooling projection keyed by SymbolIdentity. The
language server joins occurrences to declarations without textual lookup and
serves LSP 3.17 textDocument/definition locations in the current immutable
same-Bubble snapshot.

This change intentionally does not add local/member navigation, dependency or
cross-Bubble navigation, references, rename, completion, or a public
Pop.Syntax/Pop.Lsp schema.

Architecture traceability

  • Authorizing architecture section or ADR: ADR 0092 - Private Semantic
    Definition Navigation
  • New or changed public contract: the private language-server transport now
    advertises and implements LSP 3.17 textDocument/definition; no Pop Lang
    public package API is stabilized.
  • Architecture documents, examples, or terminology updated: ADR 0092,
    implementation roadmap, closed design decisions, CLI/tooling architecture,
    language-server README, and architecture conformance tests.

Verification

  • Tests were added or updated before implementation where behavior changed.
  • Positive behavior is covered.
  • Negative/rejection boundaries are covered.
  • Convention, consistency, and regression coverage is present where relevant.
  • Cross-backend or differential coverage is present where relevant.
  • cargo fmt --all -- --check
  • cargo check --workspace --all-targets
  • cargo test --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings

If a check was not run, explain why:

cargo test --workspace --all-targets was not run because the repository's
architecture conformance policy rejects executing harness-free benchmarks.
The accepted PR test command was used instead:

cargo test --workspace --lib --bins --tests --examples --quiet -- --test-threads=1

Additional successful validation:

  • focused compiler overload-identity and exact-callee-span test;
  • complete language-server document and transport tests;
  • complete HIR and architecture conformance tests;
  • relative Markdown document-link validation;
  • VS Code Extension Host definition-provider test against the built server;
  • VS Code TypeScript check, unit tests, and VSIX packaging.

Review notes

  • No dynamic typing, runtime string lookup, broad reflection, or universal-table behavior was introduced.
  • HIR/MIR remain backend-neutral.
  • No generated artifacts, dependency caches, credentials, or editor files are included.
  • This is ready for technical review.

The bootstrap Package snapshot remains deliberately conservative. It navigates
across source-owned Modules only when conventional discovery selects one Bubble
without unresolved dependency edges. Dependency-bearing Packages fall back to
standalone analysis and return no fabricated destination.

The compiler projection currently covers function declarations and direct
function calls. Local variables, parameters, fields, methods, referenced
dependencies, references, rename, and complete Workspace snapshots require
separate architecture and query work.

A companion vscode-pop commit tests the standard LSP capability through
vscode.executeDefinitionProvider; the extension does not implement a
competing navigation engine.


Summary by cubic

Adds compiler-backed go-to-definition for namespace functions and resolved direct calls in the private pop-language-server. Implements LSP textDocument/definition with precise callee spans and cross‑module navigation within the current dependency‑free Bubble snapshot.

  • New Features
    • Compiler projects ToolingDefinitionOccurrence keyed by SymbolIdentity, preserving exact callee spans through typed bodies and HIR.
    • The server answers LSP textDocument/definition and advertises definitionProvider; occurrences are joined to declarations by identity with no textual lookup.
    • Cross‑module navigation works within the selected Bubble; unresolved, indirect, or dependency‑owned uses return no destination.
    • Accurate UTF‑16 positions, including non‑BMP text; ADR 0092 and tests cover overloads, sibling modules, deterministic file URIs, transport, and VS Code provider execution.

Written for commit a9d4cc9. Summary will update on new commits.

Review in cubic

Preserve compiler-resolved callee spans and project definition
occurrences by SymbolIdentity so the private language server can answer
LSP definition requests without textual lookup.

Limit navigation to namespace functions in the current dependency-free
Bubble snapshot. Document the boundary in ADR 0092 and cover overloads,
UTF-16 positions, sibling Modules, unresolved dependencies, and the LSP
transport.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 20 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/compiler/driver/src/front_end.rs">

<violation number="1" location="crates/compiler/driver/src/front_end.rs:334">
P2: Definition navigation is absent for every direct call inside an `@CompileTime` function because this projection only scans runtime HIR, which excludes those functions. Including the already-resolved compile-time typed bodies in the projection would cover these namespace-scope calls consistently.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

.collect::<Vec<_>>();
if let Some(hir) = hir {
occurrences.extend(
hir.functions()

@cubic-dev-ai cubic-dev-ai Bot Jul 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Definition navigation is absent for every direct call inside an @CompileTime function because this projection only scans runtime HIR, which excludes those functions. Including the already-resolved compile-time typed bodies in the projection would cover these namespace-scope calls consistently.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/compiler/driver/src/front_end.rs, line 334:

<comment>Definition navigation is absent for every direct call inside an `@CompileTime` function because this projection only scans runtime HIR, which excludes those functions. Including the already-resolved compile-time typed bodies in the projection would cover these namespace-scope calls consistently.</comment>

<file context>
@@ -309,10 +311,46 @@ pub fn analyze_bubble(input: FrontEndBubbleInput) -> FrontEndResult {
+        .collect::<Vec<_>>();
+    if let Some(hir) = hir {
+        occurrences.extend(
+            hir.functions()
+                .iter()
+                .chain(hir.methods().iter().map(pop_hir::HirMethod::function))
</file context>
Fix with cubic

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.

2 participants