mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tests: when launching intentions, remember the top-level file because it might become invalid after applying intention
This commit is contained in:
+5
-4
@@ -1805,7 +1805,8 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
// if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
|
||||
|
||||
ReadonlyStatusHandlerImpl handler = (ReadonlyStatusHandlerImpl)ReadonlyStatusHandler.getInstance(file.getProject());
|
||||
setReadOnly(file, true);
|
||||
VirtualFile vFile = InjectedLanguageUtil.getTopLevelFile(file).getVirtualFile();
|
||||
setReadOnly(vFile, true);
|
||||
handler.setClearReadOnlyInTests(true);
|
||||
AtomicBoolean result = new AtomicBoolean();
|
||||
try {
|
||||
@@ -1819,14 +1820,14 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
}
|
||||
finally {
|
||||
handler.setClearReadOnlyInTests(false);
|
||||
setReadOnly(file, false);
|
||||
setReadOnly(vFile, false);
|
||||
}
|
||||
return result.get();
|
||||
}
|
||||
|
||||
private static void setReadOnly(PsiFile file, boolean readOnlyStatus) {
|
||||
private static void setReadOnly(VirtualFile vFile, boolean readOnlyStatus) {
|
||||
try {
|
||||
WriteAction.run(() -> ReadOnlyAttributeUtil.setReadOnlyAttribute(InjectedLanguageUtil.getTopLevelFile(file).getVirtualFile(), readOnlyStatus));
|
||||
WriteAction.run(() -> ReadOnlyAttributeUtil.setReadOnlyAttribute(vFile, readOnlyStatus));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
|
||||
Reference in New Issue
Block a user