mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-91810 - assert: NoSwingUnderWriteAction.lambda$watchForEvents$
push write access to utility to avoid dialogs from write actions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.intellij.psi.impl.file;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
@@ -59,7 +58,6 @@ public class PsiFileImplUtil {
|
||||
}
|
||||
|
||||
public static void checkSetName(@NotNull PsiFile file, @NotNull String name) throws IncorrectOperationException {
|
||||
ApplicationManager.getApplication().assertWriteAccessAllowed();
|
||||
VirtualFile vFile = file.getVirtualFile();
|
||||
VirtualFile parentFile = vFile.getParent();
|
||||
if (parentFile == null) return;
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import com.intellij.ide.util.EditorHelper;
|
||||
import com.intellij.ide.util.PlatformPackageUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -331,7 +332,7 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase {
|
||||
}
|
||||
|
||||
if (selection == 0 && file != existing) {
|
||||
existing.delete();
|
||||
WriteAction.run(() -> existing.delete());
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
|
||||
+1
-8
@@ -22,7 +22,6 @@ import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
@@ -153,13 +152,7 @@ public class MoveFilesOrDirectoriesUtil {
|
||||
for (final PsiElement psiElement : newElements) {
|
||||
if (psiElement instanceof PsiFile) {
|
||||
final PsiFile file = (PsiFile)psiElement;
|
||||
final boolean fileExist = ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
return CopyFilesOrDirectoriesHandler.checkFileExist(targetDirectory1, choice, file, file.getName(), "Move");
|
||||
}
|
||||
});
|
||||
if (fileExist) continue;
|
||||
if (CopyFilesOrDirectoriesHandler.checkFileExist(targetDirectory1, choice, file, file.getName(), "Move")) continue;
|
||||
}
|
||||
checkMove(psiElement, targetDirectory1);
|
||||
els.add(psiElement);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -200,6 +200,31 @@ public class RenameProcessor extends BaseRefactoringProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
final int[] choice = myAllRenames.size() > 1 ? new int[]{-1} : null;
|
||||
String message = null;
|
||||
try {
|
||||
for (Iterator<Map.Entry<PsiElement, String>> iterator = myAllRenames.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Map.Entry<PsiElement, String> entry = iterator.next();
|
||||
if (entry.getKey() instanceof PsiFile) {
|
||||
final PsiFile file = (PsiFile)entry.getKey();
|
||||
final PsiDirectory containingDirectory = file.getContainingDirectory();
|
||||
if (CopyFilesOrDirectoriesHandler.checkFileExist(containingDirectory, choice, file, entry.getValue(), "Rename")) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
RenameUtil.checkRename(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
message = e.getMessage();
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("rename.title"), message, getHelpID(), myProject);
|
||||
return false;
|
||||
}
|
||||
|
||||
final Set<UsageInfo> usagesSet = ContainerUtil.newLinkedHashSet(usagesIn);
|
||||
usagesSet.addAll(variableUsages);
|
||||
final List<UnresolvableCollisionUsageInfo> conflictUsages = RenameUtil.removeConflictUsages(usagesSet);
|
||||
@@ -350,31 +375,6 @@ public class RenameProcessor extends BaseRefactoringProcessor {
|
||||
|
||||
@Override
|
||||
public void performRefactoring(@NotNull UsageInfo[] usages) {
|
||||
final int[] choice = myAllRenames.size() > 1 ? new int[]{-1} : null;
|
||||
String message = null;
|
||||
try {
|
||||
for (Iterator<Map.Entry<PsiElement, String>> iterator = myAllRenames.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Map.Entry<PsiElement, String> entry = iterator.next();
|
||||
if (entry.getKey() instanceof PsiFile) {
|
||||
final PsiFile file = (PsiFile)entry.getKey();
|
||||
final PsiDirectory containingDirectory = file.getContainingDirectory();
|
||||
if (CopyFilesOrDirectoriesHandler.checkFileExist(containingDirectory, choice, file, entry.getValue(), "Rename")) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
RenameUtil.checkRename(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
message = e.getMessage();
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("rename.title"), message, getHelpID(), myProject);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Runnable> postRenameCallbacks = new ArrayList<>();
|
||||
|
||||
final MultiMap<PsiElement, UsageInfo> classified = classifyUsages(myAllRenames.keySet(), usages);
|
||||
|
||||
Reference in New Issue
Block a user