Testing: Avoid creating duplicated SDKs
This commit is contained in:
committed by
Sergey Rostov
parent
22243c756b
commit
ba5fe6cda9
@@ -94,6 +94,12 @@ public class PluginTestCaseBase {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static Sdk addJdk(@NotNull Disposable disposable, @NotNull Function0<Sdk> getJdk) {
|
public static Sdk addJdk(@NotNull Disposable disposable, @NotNull Function0<Sdk> getJdk) {
|
||||||
Sdk jdk = getJdk.invoke();
|
Sdk jdk = getJdk.invoke();
|
||||||
|
Sdk[] allJdks = IjPlatformUtil.getProjectJdkTableSafe().getAllJdks();
|
||||||
|
for (Sdk existingJdk : allJdks) {
|
||||||
|
if (existingJdk == jdk) {
|
||||||
|
return existingJdk;
|
||||||
|
}
|
||||||
|
}
|
||||||
ApplicationManager.getApplication().runWriteAction(() -> IjPlatformUtil.getProjectJdkTableSafe().addJdk(jdk, disposable));
|
ApplicationManager.getApplication().runWriteAction(() -> IjPlatformUtil.getProjectJdkTableSafe().addJdk(jdk, disposable));
|
||||||
return jdk;
|
return jdk;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user