mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-13873 Pull down setReadOnlyStatusClearedByRequest implementation, renamed to setClearReadOnlyInTests; revert project state in LightQuickFixTestCase
This commit is contained in:
+9
-3
@@ -196,9 +196,15 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
});
|
||||
ReadonlyStatusHandler.getInstance(file.getProject()).setReadOnlyStatusClearedByRequest(true);
|
||||
ShowIntentionActionsHandler.chooseActionAndInvoke(file, getEditor(), action, action.getText());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
ReadonlyStatusHandler handler = ReadonlyStatusHandler.getInstance(file.getProject());
|
||||
handler.setClearReadOnlyInTests(true);
|
||||
try {
|
||||
ShowIntentionActionsHandler.chooseActionAndInvoke(file, getEditor(), action, action.getText());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
finally {
|
||||
handler.setClearReadOnlyInTests(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected IntentionAction findActionWithText(@NotNull String text) {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.vfs;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -27,7 +26,6 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class ReadonlyStatusHandler {
|
||||
protected boolean myClearedByRequest;
|
||||
|
||||
public static boolean ensureFilesWritable(@NotNull Project project, @NotNull VirtualFile... files) {
|
||||
return !getInstance(project).ensureFilesWritable(files).hasReadonlyFiles();
|
||||
@@ -75,12 +73,9 @@ public abstract class ReadonlyStatusHandler {
|
||||
* Normally when file is read-only and ensureFilesWritable is called, a dialog box appears which allows user to decide
|
||||
* whether to clear read-only flag or not. This method allows to control what will happen in unit-test mode.
|
||||
*
|
||||
* @param clearedByRequest if true, ensureFilesWritable will try to clear read-only status from passed files.
|
||||
* @param clearReadOnlyInTests if true, ensureFilesWritable will try to clear read-only status from passed files.
|
||||
* Otherwise, read-only status is not modified (as if user refused to modify it).
|
||||
*/
|
||||
@TestOnly
|
||||
public void setReadOnlyStatusClearedByRequest(boolean clearedByRequest) {
|
||||
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||
myClearedByRequest = clearedByRequest;
|
||||
}
|
||||
public abstract void setClearReadOnlyInTests(boolean clearReadOnlyInTests);
|
||||
}
|
||||
|
||||
+10
-1
@@ -33,6 +33,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -40,6 +41,7 @@ import java.util.*;
|
||||
public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements PersistentStateComponent<ReadonlyStatusHandlerImpl.State> {
|
||||
private final Project myProject;
|
||||
private final WritingAccessProvider[] myAccessProviders;
|
||||
protected boolean myClearReadOnlyInTests;
|
||||
|
||||
public static class State {
|
||||
public boolean SHOW_DIALOG = true;
|
||||
@@ -95,7 +97,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements
|
||||
}
|
||||
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
if (myClearedByRequest) {
|
||||
if (myClearReadOnlyInTests) {
|
||||
processFiles(new ArrayList<>(Arrays.asList(fileInfos)), null);
|
||||
}
|
||||
return createResultStatus(files);
|
||||
@@ -156,6 +158,13 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@TestOnly
|
||||
public void setClearReadOnlyInTests(boolean clearReadOnlyInTests) {
|
||||
assert ApplicationManager.getApplication().isUnitTestMode();
|
||||
myClearReadOnlyInTests = clearReadOnlyInTests;
|
||||
}
|
||||
|
||||
private static class OperationStatusImpl extends OperationStatus {
|
||||
|
||||
private final VirtualFile[] myReadonlyFiles;
|
||||
|
||||
Reference in New Issue
Block a user