Skip to content

Commit 7d4231f

Browse files
committed
Made the parser state dispose project declarations for removed projects.
1 parent 77bc2ef commit 7d4231f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,22 @@ private void Sinks_ProjectRemoved(object sender, ProjectEventArgs e)
152152
}
153153

154154
Debug.Assert(e.ProjectId != null);
155+
DisposeProjectDeclarations(e.ProjectId);
156+
155157
OnParseRequested(sender);
156158
}
157159

160+
private void DisposeProjectDeclarations(string projectId)
161+
{
162+
var projectDeclarations = DeclarationFinder.UserDeclarations(DeclarationType.Project)
163+
.Where(declaration => declaration.ProjectId == projectId)
164+
.OfType<ProjectDeclaration>();
165+
foreach (var projectDeclaration in projectDeclarations)
166+
{
167+
projectDeclaration.Dispose();
168+
}
169+
}
170+
158171
private void Sinks_ProjectRenamed(object sender, ProjectRenamedEventArgs e)
159172
{
160173
if (!_vbe.IsInDesignMode || !ThereAreDeclarations())

0 commit comments

Comments
 (0)