Skip to content

Commit 648a704

Browse files
committed
fixed sticky built-in declarations' identifier references
1 parent b4c250c commit 648a704

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

Rubberduck.Parsing/Symbols/Declaration.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,11 @@ public override int GetHashCode()
562562

563563
public void ClearReferences()
564564
{
565-
_references = new ConcurrentBag<IdentifierReference>();
565+
while (!_references.IsEmpty)
566+
{
567+
IdentifierReference reference;
568+
_references.TryTake(out reference);
569+
}
566570
}
567571
}
568572
}

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ private void ParseInternal()
9292
{
9393
AddDeclarationsFromProjectReferences(projects);
9494
}
95+
else
96+
{
97+
_state.ClearBuiltInReferences();
98+
}
9599

96100
var components = projects
97101
.SelectMany(project => project.VBComponents.Cast<VBComponent>())
@@ -264,8 +268,6 @@ private void Resolve(DeclarationFinder finder)
264268
{
265269
try
266270
{
267-
//Parallel.ForEach(_state.AllDeclarations, declaration => declaration.ClearReferences());
268-
269271
foreach (var kvp in _state.ParseTrees)
270272
{
271273
ResolveReferences(finder, kvp.Key, kvp.Value);

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ public void ClearDeclarations(VBProject project)
291291
}
292292
}
293293

294+
public void ClearBuiltInReferences()
295+
{
296+
foreach (var item in AllDeclarations.Where(item => item.IsBuiltIn && item.References.Any()))
297+
{
298+
item.ClearReferences();
299+
}
300+
}
301+
294302
public bool ClearDeclarations(VBComponent component)
295303
{
296304
var project = component.Collection.Parent;

0 commit comments

Comments
 (0)