Skip to content

Commit 54cf6ee

Browse files
committed
Address review comments.
1 parent 73c950d commit 54cf6ee

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

Rubberduck.Parsing/VBA/DeclarationCaching/DeclarationFinder.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -541,21 +541,26 @@ public ParameterDeclaration FindParameterFromArgument(VBAParser.ArgumentExpressi
541541
return null;
542542
}
543543

544-
var callStmt = argExpression?.GetAncestor<VBAParser.CallStmtContext>();
545-
var procedureName = callStmt?.GetDescendent<VBAParser.LExpressionContext>()
546-
.GetDescendents<VBAParser.IdentifierContext>()
547-
.LastOrDefault()?.GetText();
548-
if (procedureName == null)
544+
var callStmt = argExpression.GetAncestor<VBAParser.CallStmtContext>();
545+
546+
var identifier = callStmt?
547+
.GetDescendent<VBAParser.LExpressionContext>()
548+
.GetDescendents<VBAParser.IdentifierContext>()
549+
.LastOrDefault();
550+
551+
if (identifier == null)
549552
{
550553
// if we don't know what we're calling, we can't dig any further
551554
return null;
552555
}
553556

554-
var procedure = MatchName(procedureName)
555-
.SingleOrDefault(p =>
556-
(!p.DeclarationType.HasFlag(DeclarationType.Property) ||
557-
p.DeclarationType.HasFlag(DeclarationType.PropertyGet)) &&
558-
p.References.Any(r => callStmt == r.Context.GetAncestor<VBAParser.CallStmtContext>()));
557+
var selection = new QualifiedSelection(enclosingProcedure.QualifiedModuleName, identifier.GetSelection());
558+
if (!_referencesBySelection.TryGetValue(selection, out var matches))
559+
{
560+
return null;
561+
}
562+
563+
var procedure = matches.SingleOrDefault()?.Declaration;
559564
if (procedure?.ParentScopeDeclaration is ClassModuleDeclaration)
560565
{
561566
// we can't know that the member is on the class' default interface

0 commit comments

Comments
 (0)