Skip to content

Commit 9be8481

Browse files
committed
Added infrastructure to remove references by specified modules only.
1 parent a302e55 commit 9be8481

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Rubberduck.Parsing/Symbols/Declaration.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,5 +616,12 @@ public void ClearReferences()
616616
{
617617
_references = new ConcurrentBag<IdentifierReference>();
618618
}
619+
620+
public void RemoveReferencesFrom(ICollection<QualifiedModuleName> modulesByWhichToRemoveReferences)
621+
{
622+
//This gets replaced with a new ConcurrentBag because one cannot remove specific items from a ConcurrentBag.
623+
//Moreover, changing to a ConcurrentDictionary<IdentifierReference,byte> breaks all sorts of tests, for some obscure reason.
624+
var newReferences = new ConcurrentBag<IdentifierReference>(_references.Where(reference => !modulesByWhichToRemoveReferences.Contains(reference.QualifiedModuleName)));
625+
}
619626
}
620627
}

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,14 @@ public void ClearAllReferences()
795795
}
796796
}
797797

798+
public void RemoveAllReferencesBy(ICollection<QualifiedModuleName> referencesFromToRemove)
799+
{
800+
foreach (var declaration in AllDeclarations)
801+
{
802+
declaration.RemoveReferencesFrom(referencesFromToRemove);
803+
}
804+
}
805+
798806
public bool ClearStateCache(IVBComponent component, bool notifyStateChanged = false)
799807
{
800808
return component != null && ClearStateCache(new QualifiedModuleName(component), notifyStateChanged);

0 commit comments

Comments
 (0)