@Nullable private static Sdk createDefaultErlangSdk(@NotNull ProjectJdkTable projectJdkTable, @NotNull SdkType erlangSdkType, @NotNull String homePath) { String sdkName = erlangSdkType.suggestSdkName("Default " + erlangSdkType.getName(), homePath); ProjectJdkImpl projectJdkImpl = new ProjectJdkImpl(sdkName, erlangSdkType); projectJdkImpl.setHomePath(homePath); erlangSdkType.setupSdkPaths(projectJdkImpl); final Sdk erlangSdk; if (projectJdkImpl.getVersionString() != null) { ApplicationManager.getApplication().invokeAndWait( () -> ApplicationManager.getApplication().runWriteAction(() -> projectJdkTable.addJdk(projectJdkImpl) ), NON_MODAL ); erlangSdk = projectJdkImpl; } else { erlangSdk = null; } return erlangSdk; }
@NotNull private static Sdk createMockSdk(@NotNull String version) { String homePath = new File("testData/mockSdk-" + version + "/").getAbsolutePath(); GoSdkType sdkType = GoSdkType.getInstance(); ProjectJdkImpl sdk = new ProjectJdkImpl("Go " + version, sdkType, homePath, version); sdkType.setupSdkPaths(sdk); sdk.setVersionString(version); return sdk; }
private void writeInternalErlangSdk(@NotNull SdkModificator sdkModificator, @Nullable Sdk erlangSdk) { SdkAdditionalData sdkAdditionData = new SdkAdditionalData( erlangSdk, elixirSdk ); sdkModificator.setSdkAdditionalData(sdkAdditionData); ApplicationManager.getApplication().runWriteAction(sdkModificator::commitChanges); ((ProjectJdkImpl) elixirSdk).resetVersionString(); }
/** * Creates and adds new Perl SDK * * @param interpreterPath interpreter path * @param sdkConsumer created sdk consumer */ public static void createSdk(@NotNull String interpreterPath, @NotNull PerlHostData hostData, @NotNull PerlVersionManagerData versionManagerData, @NotNull Consumer<Sdk> sdkConsumer) { VersionDescriptor perlVersionDescriptor = PerlSdkType.getPerlVersionDescriptor(interpreterPath, hostData, versionManagerData); if (perlVersionDescriptor == null) { ApplicationManager.getApplication().invokeLater( () -> Messages.showErrorDialog("Failed to fetch perl version, see logs for more details", "Failed to Create Interpreter")); return; } String newSdkName = SdkConfigurationUtil.createUniqueSdkName( suggestSdkName(perlVersionDescriptor, hostData, versionManagerData), PerlSdkTable.getInstance().getInterpreters()); final ProjectJdkImpl newSdk = PerlSdkTable.getInstance().createSdk(newSdkName); newSdk.setHomePath(interpreterPath); PerlImplementationData<?, ?> implementationData = PerlImplementationHandler.createData( interpreterPath, hostData, versionManagerData); if (implementationData == null) { return; } newSdk.setVersionString(perlVersionDescriptor.getVersionString()); newSdk.setSdkAdditionalData(new PerlSdkAdditionalData(hostData, versionManagerData, implementationData)); sdkConsumer.accept(newSdk); }
@TestOnly @NotNull public static Sdk createMockSdk(@NotNull String sdkHome, @NotNull Release version) { getInstance().mySdkHomeToReleaseCache.put(getVersionCacheKey(sdkHome), version); // we'll not try to detect sdk version in tests environment Sdk sdk = new ProjectJdkImpl(getDefaultSdkName(sdkHome, version), getInstance()); SdkModificator sdkModificator = sdk.getSdkModificator(); sdkModificator.setHomePath(sdkHome); sdkModificator.setVersionString(getVersionString(version));// must be set after home path, otherwise setting home path clears the version string sdkModificator.commitChanges(); configureSdkPaths(sdk); return sdk; }
@Override public void loadState(@NotNull Element element) { myInterpretersList.clear(); for (Element child : element.getChildren(PERL)) { ProjectJdkImpl sdk = new ProjectJdkImpl(null, null); sdk.readExternal(child, this); myInterpretersList.add(sdk); } }
protected void setUpLibrary() { Application application = ApplicationManager.getApplication(); application.invokeAndWait(() -> application.runWriteAction( () -> { VirtualFile libdir = LocalFileSystem.getInstance().refreshAndFindFileByPath("../testData/testlib"); assert libdir != null; PerlProjectManager perlProjectManager = PerlProjectManager.getInstance(getProject()); ProjectJdkImpl testSdk = PerlSdkTable.getInstance().createSdk("test"); testSdk.setSdkAdditionalData(new PerlSdkAdditionalData( PerlHostHandler.getDefaultHandler().createData(), PerlVersionManagerData.getDefault(), PerlImplementationHandler.getDefaultHandler().createData())); PerlSdkTable.getInstance().addJdk(testSdk, getTestRootDisposable()); perlProjectManager.setProjectSdk(testSdk); perlProjectManager.addExternalLibrary(libdir); CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject()); })); }
String sdkHome = sdkType.adjustSelectedSdkHome(sdk.getHomePath()); if (sdkType.isValidSdkHome(sdkHome)) { ProjectJdkImpl newSdk = new ProjectJdkImpl(sdk.getName(), sdkType, sdkHome, sdkType.getVersionString(sdkHome)); sdkType.setupSdkPaths(newSdk); sdksToAdd.add(newSdk);