Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalidate inspection results after parsing #4695

Merged

Conversation

MDoerner
Copy link
Contributor

@MDoerner MDoerner commented Jan 5, 2019

This PR closes #2023

This PR introduces the base framework for inspection result invalidation. Each inspection result now has a member ChangedInvalidateResult taking the modified modules and returning whether the result got invalidated by the changes.

The base implementation checks whether the module on the inspection result got modified. If not, it asks the inspection whether it thinks that the result is stale. DeclarationInspectionResults and IdentifierInspectionResults also take the module of the corresponding declaraion into account. AggregateInspectionResults are always considered stale as there is no information about the contents.

For the inspections, the check whether a result is stale defaults to true. If anything else is desired, the corresponding virtual method on InspectionBase has to be overriden. (This effectively deems all results stale at the moment.)

In the InspectionViewModel now all reults deemed atale get removed after a parse, provided the inspections do not run; running the inspections removes all results anyway. Consequently, when automatically running the inspections is deactivated, the stale results no longer remain in the view. This prevents the execution of quickfixes on stale data.

Currently, all existing modules are considered modified. To change that, the parsed modules would have to find their way into the state changed handler somehow. (This will not be part of this PR.)

This commit introduces the method ChangesInvalidateResult on the IInspectionResult that returns whether a change of the specified modules makes the result invalid. The base implementation returns true if the module specified on the result gets invalidated or else forwards the request to the inspection to allow inspection specific handling.

Declaration- and IdentifierReferenceInspectionResults also get invalidated based on the state they carry. AggregateInspectionResults are always considered invalidated as there is no way to see the individual results.
The invalidation is currently only used if the inspections do not get run; running the inspections overwrites the collection anyway.

Moreover, currently all results get invalidated unconditionally.
@Hosch250 Hosch250 merged commit 13ae992 into rubberduck-vba:next Jan 7, 2019
@MDoerner MDoerner deleted the InvalidateInspectionResultsAfterParsing branch April 18, 2019 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parser or resolver errors should invalidate Code Inspection results (or disable quick fixes)
2 participants