Improvements to symbol resolutions#189
Conversation
|
@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) |
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.
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.
d5023cc to
ddeea49
Compare
There was a problem hiding this comment.
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.
ddeea49 to
431fa2e
Compare
2d4ffaf to
008c675
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| span: *span, | ||
| description: format!( | ||
| "No template; '{}'", | ||
| missing_template_name), | ||
| related: vec![], |
There was a problem hiding this comment.
The diagnostic text "No template; '{}'" reads like it has an accidental semicolon and is a bit unclear. Consider changing it to something like "No template named '{}'" (or similar), since this is user-facing.
| ## 0.9.15 | ||
| - Added support for line length and breaking rules regarding line-breaks after opening parentheses, method output arguments, conditional expressions and binary operands. | ||
| - Added support for indendation rule indent_continuation_line. | ||
| - Added support for indendation rule indent\_continuation\_line. |
There was a problem hiding this comment.
Spelling: indendation should be indentation.
There was a problem hiding this comment.
Willfix in different PR
src/analysis/templating/objects.rs
Outdated
| // © 2024 Intel Corporation | ||
| // SPDX-License-Identifier: Apache-2.0 and MIT | ||
| use std::collections::{HashMap, HashSet}; | ||
| use std::hash::Hash; |
There was a problem hiding this comment.
use std::hash::Hash; appears unused in this module. Please remove it to avoid unused-import warnings (and potential CI failures if warnings are treated as errors).
| use std::hash::Hash; |
There was a problem hiding this comment.
Curious but correct. I think the 'Hash' name is included by default?
27223ab to
3606d50
Compare
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>
- 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>
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>
Values in the decl_map can be duplicated when two diamond inheritance occurs. So the prior assumption does not hold (and we do not need it) 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>
3606d50 to
095be61
Compare
Previously, we used the context-chain as the authorative hierarchical location of the lookup, this does not hold in general (breaks for templates and in-eachs). New approach uses context-chain to find the object from within the reference is made, and then parent-links to search parent scopes Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
There was a problem hiding this comment.
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.
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
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.