Skip to content

Conversation

@JonatanWaern
Copy link
Contributor

@JonatanWaern JonatanWaern commented Jan 19, 2026

Drastically improves semantical analysis of methods, supporting various things
that were previously broken.

Also makes an attempt at formalizing he behavior of the various goto-modes and
ensuring, or at least documenting, when these do not work as expected.

  • Report ambiguous overrides
  • Refactor ReferenceMatches
  • Change debug level of some prints
  • Rework symbol methodology for methods
  • Rework how fp-based symbol lookup works
  • Rework how abstract methods and template methods work
  • Clarify and ensure behavior of goto- operations

Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Allows better control of what is _semantically_ matched and what messages
are reported to the user

Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Ditch the structural lookup, just iterate over all symbols and grab the ones
that match

Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
@JonatanWaern
Copy link
Contributor Author

@TSonono @lwaern-intel @mandolaerik Have a peek over the addition to USAGE.md to see if these are useful semantics for symbol lookups, and if something is unclear or needs to be specified further. (you can ignore the TODOS for now, hopefully I can resolve those)

Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
@JonatanWaern JonatanWaern marked this pull request as ready for review January 26, 2026 09:31
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
@JonatanWaern JonatanWaern force-pushed the support-prov-explicit-method-decls branch 2 times, most recently from 9cd6ea3 to 74b7ed7 Compare January 30, 2026 13:39
@JonatanWaern JonatanWaern force-pushed the support-prov-explicit-method-decls branch from 4b63018 to e5178c2 Compare February 6, 2026 15:22
@JonatanWaern
Copy link
Contributor Author

@copilot

Copy link

Copilot AI commented Feb 9, 2026

@JonatanWaern I've opened a new pull request, #192, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves semantic analysis and symbol resolution, especially around method overrides/default calls, and formalizes/document goto-* behaviors.

Changes:

  • Reworked method/trait symbol modeling (abstract vs concrete, default-call tracking, override resolution).
  • Introduced a dedicated semantic lookup module to centralize goto-definition/declaration/implementation/references behavior.
  • Improved reference/symbol bookkeeping (template instantiations, in each provenance) and lowered log noise (debug → trace).

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/span/mod.rs Tightens span containment checks to ensure file matches when testing positions.
src/server/mod.rs Reduces log verbosity for message handling by moving several debug logs to trace.
src/file_management.rs Reduces log verbosity for path resolution output by moving debug to trace.
src/analysis/templating/traits.rs Major trait/method refactor: separates abstract vs concrete methods, adds default-call references, updates override/ambiguity handling.
src/analysis/templating/topology.rs Improves dependency diagnostics (in-each missing template reporting and clearer import mapping log).
src/analysis/templating/objects.rs Tracks in each locations used by composite objects; reworks method override sorting/default-call modeling to match new method ref shape.
src/analysis/templating/methods.rs Refactors DMLMethodRef into a struct, adds DefaultCallReference, and extends override validation (shared/default semantics).
src/analysis/symbols.rs Extends symbol source modeling for per-object method symbols; changes implementations collection to a set; adds compact debug info.
src/analysis/structure/objects.rs Adds InEach.loc and marks empty-body methods as abstract via MaybeAbstract.
src/analysis/scope.rs Reduces log verbosity during reference lookup traversal (debug → trace) and clarifies one debug message.
src/analysis/reference.rs Refactors Reference into { variant, extra_info } to carry additional metadata (e.g., instantiation markers).
src/analysis/provisionals.rs Adds provisional flag parsing for explicit_method_decls plus a unit test.
src/analysis/parsing/structure.rs Adds parsing support for an optional colon token in methods; marks template instantiation references.
src/analysis/parsing/parser.rs Reduces parse-context log verbosity (debug → trace).
src/analysis/mod.rs Large semantic lookup/symbol binding changes: per-parent method symbol indexing, reference matching redesign, method implementation binding, template instantiation implementations.
src/actions/semantic_lookup.rs New module centralizing semantic symbol/reference lookup and goto-* behaviors with limitation reporting.
src/actions/requests.rs Switches goto-* requests to use the new semantic lookup APIs, removing duplicated lookup logic.
src/actions/mod.rs Exposes the new semantic_lookup module and lowers wait-state logs (debug → trace).
src/actions/hover.rs Lowers hover logging verbosity (debug → trace).
src/actions/analysis_storage.rs Removes unused lookup helpers and lowers storage logs (debug → trace) in a few places.
src/actions/analysis_queue.rs Lowers queue logging verbosity (debug → trace) and tweaks one linter failure log level.
USAGE.md Adds documentation clarifying goto-* semantics by symbol kind.
CHANGELOG.md Documents new behavior around ambiguous default calls, instantiations, and object/template implementations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JonatanWaern JonatanWaern force-pushed the support-prov-explicit-method-decls branch from 21afe03 to d5023cc Compare February 9, 2026 09:47
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
- Previously, goto-x at the start of a name would not work, while
goto-x at the end or middle of it would.
- If there is no definition for a lookup, fall-back to declaration

Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
This can happen when methods are ambigiously overridden or overridden
in a diamond shape.
we will correctly search the entire hierarchy until we find the
method from whence the reference came, but we will also search
through adjacent hierarchies, so reaching the bottom of those
is not actually an unexpected error

Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
@JonatanWaern JonatanWaern force-pushed the support-prov-explicit-method-decls branch from d5023cc to ddeea49 Compare February 9, 2026 11:10
@JonatanWaern JonatanWaern requested a review from Copilot February 9, 2026 11:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1927 to +1928
_ => Some(DefaultCallReference::Ambiguous(
defaults.iter().map(|d| Arc::clone(decl_to_method.get(d).unwrap())).collect())),
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

The Ambiguous default-call construction uses decl_to_method.get(d).unwrap(), which can panic if any of the candidate defaults are abstract (and therefore not present in decl_to_method). This can happen because abstract defaults are explicitly represented for the single-default case but not for the multi-default case. Fix by making the ambiguous path robust to missing entries (e.g., represent abstract candidates in the ambiguous set, or build Ambiguous from a mix of Valid and Abstract without unwrap).

Suggested change
_ => Some(DefaultCallReference::Ambiguous(
defaults.iter().map(|d| Arc::clone(decl_to_method.get(d).unwrap())).collect())),
_ => {
let ambiguous_defaults =
defaults
.iter()
.filter_map(|d| decl_to_method.get(d).map(Arc::clone))
.collect();
Some(DefaultCallReference::Ambiguous(ambiguous_defaults))
},

Copilot uses AI. Check for mistakes.
storage, errors);
},
DMLShallowObjectVariant::Method(method_ref) => {
internal_error!("Unreachable method_ref case reached, ignored. ({:?})", method_ref);
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

This branch is effectively unreachable because the earlier match returning from add_new_symbol_from_shallow already handles DMLShallowObjectVariant::Method. Keeping an internal_error! here risks masking future control-flow changes and adds noise to logs. Consider removing this arm entirely (or replacing with unreachable!() if you want the compiler/runtime to enforce the invariant).

Suggested change
internal_error!("Unreachable method_ref case reached, ignored. ({:?})", method_ref);
unreachable!("Unreachable Method variant reached in add_new_symbol_from_shallow: {:?}", method_ref);

Copilot uses AI. Check for mistakes.
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
@JonatanWaern JonatanWaern force-pushed the support-prov-explicit-method-decls branch from ddeea49 to 431fa2e Compare February 9, 2026 12:03
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