use of com.intellij.codeInspection.BatchQuickFix in project intellij-community by JetBrains.
the class LocalQuickFixWrapper method applyFix.
@Override
protected void applyFix(@NotNull final Project project, @NotNull final GlobalInspectionContextImpl context, @NotNull final CommonProblemDescriptor[] descriptors, @NotNull final Set<PsiElement> ignoredElements) {
if (myFix instanceof BatchQuickFix) {
final List<PsiElement> collectedElementsToIgnore = new ArrayList<>();
final Runnable refreshViews = () -> {
DaemonCodeAnalyzer.getInstance(project).restart();
for (CommonProblemDescriptor descriptor : descriptors) {
ignore(ignoredElements, descriptor, getWorkingQuickFix(descriptor.getFixes()), context);
}
final RefManager refManager = context.getRefManager();
final RefElement[] refElements = new RefElement[collectedElementsToIgnore.size()];
for (int i = 0, collectedElementsToIgnoreSize = collectedElementsToIgnore.size(); i < collectedElementsToIgnoreSize; i++) {
refElements[i] = refManager.getReference(collectedElementsToIgnore.get(i));
}
removeElements(refElements, project, myToolWrapper);
};
((BatchQuickFix) myFix).applyFix(project, descriptors, collectedElementsToIgnore, refreshViews);
return;
}
boolean restart = false;
for (CommonProblemDescriptor descriptor : descriptors) {
if (descriptor == null)
continue;
final QuickFix[] fixes = descriptor.getFixes();
if (fixes != null) {
final QuickFix fix = getWorkingQuickFix(fixes);
if (fix != null) {
//CCE here means QuickFix was incorrectly inherited, is there a way to signal (plugin) it is wrong?
fix.applyFix(project, descriptor);
restart = true;
ignore(ignoredElements, descriptor, fix, context);
}
}
}
if (restart) {
DaemonCodeAnalyzer.getInstance(project).restart();
}
}
Aggregations