mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javafx intentions: make files writable outside write action
This commit is contained in:
+1
-12
@@ -15,11 +15,8 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.javaFX.fxml.codeInsight.inspections;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.lang.ImportOptimizer;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -106,15 +103,7 @@ public class JavaFxUnusedImportsInspection extends XmlSuppressableInspectionTool
|
||||
if (psiElement == null) return;
|
||||
final PsiFile file = psiElement.getContainingFile();
|
||||
if (file == null || !JavaFxFileTypeFactory.isFxml(file)) return;
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
ImportOptimizer optimizer = new JavaFxImportsOptimizer();
|
||||
final Runnable runnable = optimizer.processFile(file);
|
||||
new WriteCommandAction.Simple(project, getFamilyName(), file) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
runnable.run();
|
||||
}
|
||||
}.execute();
|
||||
new JavaFxImportsOptimizer().processFile(file).run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-2
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.javaFX.fxml.codeInsight.inspections;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -63,7 +62,6 @@ public class UnwrapTagFix implements LocalQuickFix {
|
||||
if (xmlTag != null) {
|
||||
final XmlTag parentTag = xmlTag.getParentTag();
|
||||
final PsiElement[] children = PsiTreeUtil.getChildrenOfType(xmlTag, XmlTagChild.class);
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
|
||||
if (children != null && children.length > 0 && parentTag != null) {
|
||||
parentTag.addRange(children[0], children[children.length - 1]);
|
||||
}
|
||||
|
||||
-2
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.javaFX.fxml.codeInsight.intentions;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -39,7 +38,6 @@ import org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxPropertyTagDescriptor
|
||||
public class JavaFxCollapseSubTagToAttributeIntention extends PsiElementBaseIntentionAction{
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
|
||||
final XmlTag tag = (XmlTag)element.getParent();
|
||||
final String value;
|
||||
if (tag.getSubTags().length == 0) {
|
||||
|
||||
-2
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.javaFX.fxml.codeInsight.intentions;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -45,7 +44,6 @@ public class JavaFxExpandAttributeIntention extends PsiElementBaseIntentionActio
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
|
||||
final XmlAttribute attr = (XmlAttribute)element.getParent();
|
||||
final String name = attr.getName();
|
||||
final XmlAttributeDescriptor descriptor = attr.getDescriptor();
|
||||
|
||||
-2
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.plugins.javaFX.fxml.codeInsight.intentions;
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -53,7 +52,6 @@ public class JavaFxWrapWithDefineIntention extends PsiElementBaseIntentionAction
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return;
|
||||
final XmlTag tagFromText = XmlElementFactory.getInstance(project).createTagFromText("<" + FxmlConstants.FX_DEFINE + "/>");
|
||||
tagFromText.addSubTag(myTag, true);
|
||||
myTag.replace(tagFromText);
|
||||
|
||||
Reference in New Issue
Block a user