inspection toolwindow: do not track modification because fix doesn't mean modification + do not forget already ignored elements IDEA-156376

This commit is contained in:
Dmitry Batkovich
2016-05-24 15:30:22 +03:00
parent 4be08d85a3
commit bc220204d6
2 changed files with 4 additions and 9 deletions
@@ -24,8 +24,6 @@ import com.intellij.codeInspection.reference.RefManager;
import com.intellij.codeInspection.ui.InspectionToolPresentation;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;
import com.intellij.psi.util.PsiModificationTracker;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -92,7 +90,6 @@ public class LocalQuickFixWrapper extends QuickFixAction {
@NotNull final GlobalInspectionContextImpl context,
@NotNull final CommonProblemDescriptor[] descriptors,
@NotNull final Set<PsiElement> ignoredElements) {
final PsiModificationTracker tracker = PsiManager.getInstance(project).getModificationTracker();
if (myFix instanceof BatchQuickFix) {
final List<PsiElement> collectedElementsToIgnore = new ArrayList<>();
final Runnable refreshViews = () -> {
@@ -121,13 +118,10 @@ public class LocalQuickFixWrapper extends QuickFixAction {
if (fixes != null) {
final QuickFix fix = getWorkingQuickFix(fixes);
if (fix != null) {
final long startCount = tracker.getModificationCount();
//CCE here means QuickFix was incorrectly inherited, is there a way to signal (plugin) it is wrong?
fix.applyFix(project, descriptor);
if (startCount != tracker.getModificationCount()) {
restart = true;
ignore(ignoredElements, descriptor, fix, context);
}
restart = true;
ignore(ignoredElements, descriptor, fix, context);
}
}
}
@@ -355,7 +355,8 @@ public class DefaultInspectionToolPresentation implements ProblemDescriptionsPro
@Override
public void ignoreCurrentElement(RefEntity refEntity) {
if (refEntity == null) return;
getIgnoredElements().put(refEntity, getProblemElements().get(refEntity));
getIgnoredElements().put(refEntity, mergeDescriptors(getIgnoredElements().getOrDefault(refEntity, CommonProblemDescriptor.EMPTY_ARRAY),
getProblemElements().getOrDefault(refEntity, CommonProblemDescriptor.EMPTY_ARRAY)));
}
@Override