Added check for read-only files in intention actions
This commit is contained in:
@@ -16,12 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
@@ -39,6 +41,20 @@ public abstract class JetIntentionAction<T extends PsiElement> implements Intent
|
||||
return element.isValid() && file.getManager().isInProject(file) && (file instanceof JetFile);
|
||||
}
|
||||
|
||||
//Don't override this method. Use the method below instead.
|
||||
@Deprecated
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||
if (file instanceof JetFile) {
|
||||
if (CodeInsightUtilBase.prepareFileForWrite(element.getContainingFile())) {
|
||||
invoke(project, editor, (JetFile) file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void invoke(@NotNull Project project, Editor editor, JetFile file) throws IncorrectOperationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startInWriteAction() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user