-
Notifications
You must be signed in to change notification settings - Fork 6
Improvements to symbol resolutions #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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>
|
@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>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
9cd6ea3 to
74b7ed7
Compare
4b63018 to
e5178c2
Compare
|
@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. |
There was a problem hiding this 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 eachprovenance) 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.
21afe03 to
d5023cc
Compare
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>
d5023cc to
ddeea49
Compare
There was a problem hiding this 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.
| _ => Some(DefaultCallReference::Ambiguous( | ||
| defaults.iter().map(|d| Arc::clone(decl_to_method.get(d).unwrap())).collect())), |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
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).
| _ => 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)) | |
| }, |
| storage, errors); | ||
| }, | ||
| DMLShallowObjectVariant::Method(method_ref) => { | ||
| internal_error!("Unreachable method_ref case reached, ignored. ({:?})", method_ref); |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
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).
| internal_error!("Unreachable method_ref case reached, ignored. ({:?})", method_ref); | |
| unreachable!("Unreachable Method variant reached in add_new_symbol_from_shallow: {:?}", method_ref); |
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
ddeea49 to
431fa2e
Compare
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.