Skip to content

Commit de4fb11

Browse files
committed
fixes #1161 (does not address performance)
1 parent 83e74bd commit de4fb11

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Rubberduck.Parsing/Symbols/IdentifierReferenceResolver.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ private Declaration ResolveType(Declaration parent)
420420
.ToList();
421421
}
422422

423-
return result.Count == 1 ? result.SingleOrDefault() : null;
423+
return result.Count == 1 ? result.SingleOrDefault() :
424+
matches.Count == 1 ? matches.First() : null;
424425
}
425426

426427
private static readonly Type[] IdentifierContexts =
@@ -803,6 +804,8 @@ public void Resolve(VBAParser.ICS_S_MembersCallContext context)
803804

804805
if (parent == null)
805806
{
807+
808+
806809
return;
807810
}
808811

@@ -826,7 +829,7 @@ public void Resolve(VBAParser.ICS_S_MembersCallContext context)
826829
return;
827830
}
828831

829-
member.AddMemberCall(CreateReference(GetMemberCallIdentifierContext(memberCall), member));
832+
member.AddReference(CreateReference(GetMemberCallIdentifierContext(memberCall), member));
830833
parent = ResolveType(member);
831834
}
832835

@@ -1173,7 +1176,8 @@ private static bool IsBuiltInDeclarationInScope(Declaration item, Declaration lo
11731176
// if localScope is not null, we can resolve to any public or global in that scope:
11741177
var isInLocalScope = (localScope != null && item.Accessibility == Accessibility.Global
11751178
&& localScope.IdentifierName == item.ParentDeclaration.IdentifierName)
1176-
|| (localScope != null && localScope.QualifiedName.QualifiedModuleName.Component.Type == Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_Document
1179+
|| (localScope != null && localScope.QualifiedName.QualifiedModuleName.Component != null
1180+
&& localScope.QualifiedName.QualifiedModuleName.Component.Type == Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_Document
11771181
&& item.Accessibility == Accessibility.Public && item.ParentDeclaration.DeclarationType == localScope.DeclarationType);
11781182

11791183
return isBuiltInNonEvent && (isBuiltInGlobal || isInLocalScope);

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,11 @@ public void Resolve(CancellationToken token)
179179
{
180180
try
181181
{
182-
var resolverTasks = _state.ParseTrees.Select(kvp => Task.Run(() =>
182+
Parallel.ForEach(_state.ParseTrees, kvp =>
183183
{
184184
token.ThrowIfCancellationRequested();
185185
ResolveReferences(kvp.Key, kvp.Value, token);
186-
}, token)).ToArray();
187-
188-
Task.WaitAll(resolverTasks);
186+
});
189187
}
190188
catch (OperationCanceledException)
191189
{

0 commit comments

Comments
 (0)