Skip to content

Commit 77bc2ef

Browse files
committed
Made reparsing refresh projects with disposed project declarations.
1 parent 739bd97 commit 77bc2ef

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ private void ParseAllInternal(object requestor, CancellationToken token)
361361
removedModules.UnionWith(ModulesInProjects(removedProjects));
362362
token.ThrowIfCancellationRequested();
363363

364+
var notRemovedDisposedProjects = NotRemovedDisposedProjects(removedProjects);
365+
toParse.UnionWith(ModulesInProjects(notRemovedDisposedProjects));
366+
364367
var toReResolveReferences = OtherModulesReferencingAnyNotToBeParsed(removedModules.AsReadOnly(), toParse.AsReadOnly());
365368
token.ThrowIfCancellationRequested();
366369

@@ -371,7 +374,10 @@ private void ParseAllInternal(object requestor, CancellationToken token)
371374
token.ThrowIfCancellationRequested();
372375

373376
//This must come after the component cleanup because of cache invalidation.
374-
CleanUpRemovedProjects(removedProjects);
377+
CleanUpProjects(removedProjects);
378+
token.ThrowIfCancellationRequested();
379+
380+
CleanUpProjects(notRemovedDisposedProjects);
375381
token.ThrowIfCancellationRequested();
376382

377383
ExecuteCommonParseActivities(toParse.AsReadOnly(), toReResolveReferences, token);
@@ -384,10 +390,10 @@ private IReadOnlyCollection<QualifiedModuleName> OtherModulesReferencingAnyNotTo
384390
.ToHashSet().AsReadOnly();
385391
}
386392

387-
private IEnumerable<QualifiedModuleName> ModulesInProjects(IReadOnlyCollection<string> removedProjects)
393+
private IEnumerable<QualifiedModuleName> ModulesInProjects(IReadOnlyCollection<string> projectIds)
388394
{
389395
return State.DeclarationFinder.UserDeclarations(DeclarationType.Module)
390-
.Where(declaration => removedProjects.Contains(declaration.ProjectId))
396+
.Where(declaration => projectIds.Contains(declaration.ProjectId))
391397
.Select(declaration => declaration.QualifiedName.QualifiedModuleName);
392398
}
393399

@@ -410,7 +416,7 @@ private void ClearStateCache(IEnumerable<QualifiedModuleName> modules)
410416
}
411417
}
412418

413-
private void CleanUpRemovedProjects(IReadOnlyCollection<string> removedProjectIds)
419+
private void CleanUpProjects(IReadOnlyCollection<string> removedProjectIds)
414420
{
415421
ClearStateCache(removedProjectIds);
416422
}
@@ -439,6 +445,17 @@ private IReadOnlyCollection<string> RemovedProjects(IReadOnlyCollection<IVBProje
439445
return removedProjects.Select(tuple => tuple.Item1).ToHashSet().AsReadOnly();
440446
}
441447

448+
private IReadOnlyCollection<string> NotRemovedDisposedProjects(IEnumerable<string> removedProjects)
449+
{
450+
var disposedProjects = State.DeclarationFinder
451+
.UserDeclarations(DeclarationType.Project)
452+
.OfType<ProjectDeclaration>()
453+
.Where(declaration => declaration.IsDisposed)
454+
.Select(declaration => declaration.ProjectId)
455+
.ToHashSet();
456+
disposedProjects.ExceptWith(removedProjects);
457+
return disposedProjects.AsReadOnly();
458+
}
442459

443460
public void Dispose()
444461
{

0 commit comments

Comments
 (0)