mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix tests and prevent bugs in the future: commit SDK under write action only
GitOrigin-RevId: fda21f17f8a68005b0299fed33b9daecafa8bcc9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
758af6f5a7
commit
3b8b513936
@@ -114,19 +114,36 @@ public final class PySdkTools {
|
||||
addTestSdkRoot(modificator, path);
|
||||
}
|
||||
if (!addSkeletons) {
|
||||
ApplicationManager.getApplication().invokeAndWait(modificator::commitChanges);
|
||||
commitChangesObeyWriteAction(modificator);
|
||||
return;
|
||||
}
|
||||
|
||||
final String skeletonsPath = PythonSdkUtil.getSkeletonsPath(PathManager.getSystemPath(), sdk.getHomePath());
|
||||
addTestSdkRoot(modificator, skeletonsPath);
|
||||
|
||||
ApplicationManager.getApplication().invokeAndWait(modificator::commitChanges);
|
||||
commitChangesObeyWriteAction(modificator);
|
||||
|
||||
PySkeletonRefresher
|
||||
.refreshSkeletonsOfSdk(project, null, skeletonsPath, sdk);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SdkModificator#commitChanges()} is marked with {@link com.intellij.util.concurrency.annotations.RequiresWriteLock} and can't be called without it
|
||||
*/
|
||||
private static void commitChangesObeyWriteAction(@NotNull SdkModificator modificator) {
|
||||
var app = ApplicationManager.getApplication();
|
||||
app.invokeAndWait(() -> {
|
||||
if (app.isWriteAccessAllowed()) {
|
||||
modificator.commitChanges();
|
||||
}
|
||||
else {
|
||||
WriteAction.run(() -> {
|
||||
modificator.commitChanges();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void addTestSdkRoot(@NotNull SdkModificator sdkModificator, @NotNull String path) {
|
||||
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
|
||||
if (file != null) {
|
||||
|
||||
Reference in New Issue
Block a user