fix(resolution): recognize union instantiation
This commit is contained in:
@@ -1079,13 +1079,16 @@ export class ReferenceResolver {
|
||||
}
|
||||
|
||||
// Promote "calls" to "instantiates" when the resolved target is a
|
||||
// class/struct. Languages without a `new` keyword (Python, Ruby)
|
||||
// class/struct/union. Languages without a `new` keyword (Python, Ruby)
|
||||
// express instantiation as `Foo()` — extraction can't tell that
|
||||
// apart from a function call without symbol info, but resolution
|
||||
// can: if `Foo` resolves to a class, the call IS an instantiation.
|
||||
if (kind === 'calls') {
|
||||
const targetNode = this.queries.getNodeById(ref.targetNodeId);
|
||||
if (targetNode && (targetNode.kind === 'class' || targetNode.kind === 'struct')) {
|
||||
if (
|
||||
targetNode &&
|
||||
(targetNode.kind === 'class' || targetNode.kind === 'struct' || targetNode.kind === 'union')
|
||||
) {
|
||||
kind = 'instantiates';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2107,6 +2107,7 @@ function findBestMatch(
|
||||
if (
|
||||
candidate.kind === 'class' ||
|
||||
candidate.kind === 'struct' ||
|
||||
candidate.kind === 'union' ||
|
||||
candidate.kind === 'interface'
|
||||
) {
|
||||
score += 25;
|
||||
|
||||
Reference in New Issue
Block a user