|
14 | 14 | using Rubberduck.Parsing.Inspections.Abstract;
|
15 | 15 | using Rubberduck.Parsing.UIContext;
|
16 | 16 | using Rubberduck.Parsing.VBA;
|
| 17 | +using Rubberduck.Parsing.VBA.Extensions; |
17 | 18 | using Rubberduck.Settings;
|
18 | 19 | using Rubberduck.UI.Command;
|
19 |
| -using Rubberduck.UI.Controls; |
20 | 20 | using Rubberduck.UI.Settings;
|
| 21 | +using Rubberduck.VBEditor; |
21 | 22 |
|
22 | 23 | namespace Rubberduck.UI.Inspections
|
23 | 24 | {
|
@@ -383,6 +384,12 @@ private void HandleStateChanged(object sender, ParserStateEventArgs e)
|
383 | 384 | {
|
384 | 385 | RefreshInspections(e.Token);
|
385 | 386 | }
|
| 387 | + else |
| 388 | + { |
| 389 | + //Todo: Find a way to get the actually modified modules in here. |
| 390 | + var modifiedModules = _state.DeclarationFinder.AllModules.ToHashSet(); |
| 391 | + InvalidateStaleInspectionResults(modifiedModules); |
| 392 | + } |
386 | 393 | }
|
387 | 394 |
|
388 | 395 | private async void RefreshInspections(CancellationToken token)
|
@@ -442,6 +449,18 @@ private async void RefreshInspections(CancellationToken token)
|
442 | 449 | LogManager.GetCurrentClassLogger().Trace("Inspections loaded in {0}ms", stopwatch.ElapsedMilliseconds);
|
443 | 450 | }
|
444 | 451 |
|
| 452 | + private void InvalidateStaleInspectionResults(ICollection<QualifiedModuleName> modifiedModules) |
| 453 | + { |
| 454 | + var staleResults = Results.Where(result => result.ChangesInvalidateResult(modifiedModules)).ToList(); |
| 455 | + _uiDispatcher.Invoke(() => |
| 456 | + { |
| 457 | + foreach (var staleResult in staleResults) |
| 458 | + { |
| 459 | + Results.Remove(staleResult); |
| 460 | + } |
| 461 | + }); |
| 462 | + } |
| 463 | + |
445 | 464 | private void ExecuteQuickFixCommand(object parameter)
|
446 | 465 | {
|
447 | 466 | var quickFix = parameter as IQuickFix;
|
|
0 commit comments