mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
platform: PerformFixesModalTask launches intention action based quick fix in read-action if possible
This commit is contained in:
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.ex;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.CommonProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.QuickFix;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.DumbModePermission;
|
||||
@@ -70,6 +72,22 @@ public abstract class PerformFixesModalTask implements SequentialTask {
|
||||
}
|
||||
indicator.setText("Processing " + presentableText);
|
||||
}
|
||||
|
||||
final boolean[] runInReadAction = {false};
|
||||
final QuickFix[] fixes = descriptor.getFixes();
|
||||
if (fixes != null) {
|
||||
for (QuickFix fix : fixes) {
|
||||
if (fix instanceof IntentionAction) {
|
||||
if (!((IntentionAction)fix).startInWriteAction()) {
|
||||
runInReadAction[0] = true;
|
||||
} else {
|
||||
runInReadAction[0] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_MODAL, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -77,9 +95,14 @@ public abstract class PerformFixesModalTask implements SequentialTask {
|
||||
@Override
|
||||
public void run() {
|
||||
myDocumentManager.commitAllDocuments();
|
||||
applyFix(myProject, descriptor);
|
||||
if (!runInReadAction[0]) {
|
||||
applyFix(myProject, descriptor);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (runInReadAction[0]) {
|
||||
applyFix(myProject, descriptor);
|
||||
}
|
||||
}
|
||||
});
|
||||
return isDone();
|
||||
|
||||
Reference in New Issue
Block a user