mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
groovy intentions/fixes: make files writable outside write action
This commit is contained in:
+4
-8
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.annotator.intentions;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.CommonClassNames;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiClassType;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -82,11 +83,6 @@ public class QuickfixUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static boolean ensureFileWritable(Project project, PsiFile file) {
|
||||
return FileModificationService.getInstance().preparePsiElementsForWrite(file);
|
||||
}
|
||||
|
||||
public static List<ParamInfo> swapArgumentsAndTypes(String[] names, PsiType[] types) {
|
||||
List<ParamInfo> result = new ArrayList<>();
|
||||
|
||||
|
||||
-7
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -59,9 +58,6 @@ public abstract class GroovyFix implements LocalQuickFix {
|
||||
if (problemElement == null || !problemElement.isValid()) {
|
||||
return;
|
||||
}
|
||||
if (isQuickFixOnReadOnlyFile(problemElement)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
doFix(project, descriptor);
|
||||
} catch (IncorrectOperationException e) {
|
||||
@@ -75,9 +71,6 @@ public abstract class GroovyFix implements LocalQuickFix {
|
||||
protected abstract void doFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor)
|
||||
throws IncorrectOperationException;
|
||||
|
||||
protected static boolean isQuickFixOnReadOnlyFile(PsiElement problemElement) {
|
||||
return !FileModificationService.getInstance().preparePsiElementForWrite(problemElement);
|
||||
}
|
||||
|
||||
protected static void replaceExpression(GrExpression expression, String newExpression) {
|
||||
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(expression.getProject());
|
||||
|
||||
-4
@@ -26,7 +26,6 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyLanguage;
|
||||
import org.jetbrains.plugins.groovy.annotator.intentions.QuickfixUtil;
|
||||
import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
@@ -47,9 +46,6 @@ public abstract class Intention implements IntentionAction {
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (!QuickfixUtil.ensureFileWritable(project, file)) {
|
||||
return;
|
||||
}
|
||||
final PsiElement element = findMatchingElement(file, editor);
|
||||
if (element == null) {
|
||||
return;
|
||||
|
||||
-3
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.annotator.intentions;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.completion.JavaCompletionUtil;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.ide.util.MethodCellRenderer;
|
||||
@@ -135,8 +134,6 @@ public class GroovyStaticImportMethodFix extends Intention {
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
if (getCandidates().size() == 1) {
|
||||
final PsiMethod toImport = getCandidates().get(0);
|
||||
doImport(toImport);
|
||||
|
||||
+5
@@ -89,6 +89,11 @@ public class ConvertConcatenationToGstringIntention extends Intention {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldMakeCurrentFileWritable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
|
||||
+5
@@ -252,6 +252,11 @@ public class ConvertStringToMultilineIntention extends Intention {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldMakeCurrentFileWritable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user