-
Notifications
You must be signed in to change notification settings - Fork 0
fix(resolve): prefer a base CLASS for Python implements edges (#172) #180
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -590,7 +590,7 @@ pub(crate) fn resolve_symbol<'a>( | |
| .copied() | ||
| .filter(|symbol| kind_matches(symbol)) | ||
| .collect::<Vec<_>>(); | ||
| let preferred = preferred_matches(request.edge_kind, &matches); | ||
| let preferred = preferred_matches(request.edge_kind, request.source_language, &matches); | ||
| // In languages with separate type/value namespaces (Rust, C, C++), a `references_type` | ||
| // reference must resolve to a type DEFINITION (struct/enum/trait/type/…). If none of the | ||
| // same-named candidates is one, do NOT fall back to a non-type symbol (an `impl` block, a | ||
|
|
@@ -736,12 +736,18 @@ pub(crate) fn is_common_member_name(value: &str) -> bool { | |
| } | ||
| pub(crate) fn preferred_matches<'a>( | ||
| edge_kind: &str, | ||
| source_language: Option<&str>, | ||
| matches: &[&'a IndexedSymbol], | ||
| ) -> Vec<&'a IndexedSymbol> { | ||
| let preferred_kinds: &[&str] = match edge_kind { | ||
| "calls_name" => &["function", "method"], | ||
| "constructs" => &["struct", "class", "object"], | ||
| "uses_macro" => &["macro"], | ||
| // Python base-class inheritance emits an `implements` edge to a CLASS — Python has no | ||
| // traits/interfaces — so prefer class-like kinds for Python (#172). Kept language-scoped so | ||
| // Kotlin/TS are UNCHANGED: there `implements`/`: I` targets an interface, and a same-named | ||
| // class must not be preferred over it. | ||
| "implements" if source_language == Some(Language::Python.as_str()) => &["class", "object"], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This preference also applies to every Python Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In mixed-language indexes this branch prefers any Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This preference also applies to every Python Useful? React with 👍 / 👎. |
||
| "implements" => &["trait", "interface"], | ||
| "references_type" => &["struct", "enum", "trait", "type", "class", "interface", "object"], | ||
| _ => &[], | ||
|
|
||
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.
In mixed-language indexes this branch prefers any
class/objectsymbol by kind only;preferred_matchesdoes not checksymbol.language, and the name buckets are repo-wide. When a Python base is external or otherwise not indexed as a Python class, but a TS/Kotlin/C++ class or Kotlin object with the same short name exists alongside another same-named non-class candidate, this new preferred set can resolveclass Sub(Base)to the foreign symbol instead of leaving it unresolved. Please restrict the Pythonimplementspreference to Python symbols (or otherwise suppress cross-language candidates) when applying this branch.Useful? React with 👍 / 👎.