use of com.intellij.openapi.projectRoots.impl.ProjectJdkImpl in project intellij-community by JetBrains.
the class PySdkFlavorTest method createMockSdk.
// TODO: Add tests for MayaPy and IronPython SDK flavors
@NotNull
private static Sdk createMockSdk(@NotNull PythonSdkFlavor flavor, @NotNull String versionOutput) {
final String versionString = flavor.getVersionStringFromOutput(versionOutput);
final ProjectJdkImpl sdk = new ProjectJdkImpl("Test", PythonSdkType.getInstance(), "/path/to/sdk", versionString);
sdk.setSdkAdditionalData(new PythonSdkAdditionalData(flavor));
return sdk;
}
use of com.intellij.openapi.projectRoots.impl.ProjectJdkImpl in project intellij-community by JetBrains.
the class PythonSdkDetailsStep method getVEnvCallback.
@NotNull
private AbstractCreateVirtualEnvDialog.VirtualEnvCallback getVEnvCallback() {
return new CreateVirtualEnvDialog.VirtualEnvCallback() {
@Override
public void virtualEnvCreated(Sdk sdk, boolean associateWithProject) {
if (associateWithProject) {
SdkAdditionalData additionalData = sdk.getSdkAdditionalData();
if (additionalData == null) {
additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(sdk.getHomePath()));
((ProjectJdkImpl) sdk).setSdkAdditionalData(additionalData);
}
if (myNewProject) {
((PythonSdkAdditionalData) additionalData).associateWithNewProject();
} else {
((PythonSdkAdditionalData) additionalData).associateWithProject(myProject);
}
}
mySdkAddedCallback.consume(sdk);
}
};
}
use of com.intellij.openapi.projectRoots.impl.ProjectJdkImpl in project intellij-community by JetBrains.
the class SdkEditor method doSetHomePath.
private void doSetHomePath(final String homePath, final SdkType sdkType) {
if (homePath == null) {
return;
}
setHomePathValue(homePath.replace('/', File.separatorChar));
final String newSdkName = suggestSdkName(homePath);
((ProjectJdkImpl) mySdk).setName(newSdkName);
try {
final Sdk dummySdk = (Sdk) mySdk.clone();
SdkModificator sdkModificator = dummySdk.getSdkModificator();
sdkModificator.setHomePath(homePath);
sdkModificator.removeAllRoots();
sdkModificator.commitChanges();
sdkType.setupSdkPaths(dummySdk, mySdkModel);
clearAllPaths();
myVersionString = dummySdk.getVersionString();
if (myVersionString == null) {
Messages.showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", homePath), ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon());
}
sdkModificator = dummySdk.getSdkModificator();
for (OrderRootType type : myPathEditors.keySet()) {
SdkPathEditor pathEditor = myPathEditors.get(type);
pathEditor.setAddBaseDir(dummySdk.getHomeDirectory());
pathEditor.addPaths(sdkModificator.getRoots(type));
}
mySdkModel.getMulticaster().sdkHomeSelected(dummySdk, homePath);
} catch (CloneNotSupportedException e) {
// should not happen in normal program
LOG.error(e);
}
}
use of com.intellij.openapi.projectRoots.impl.ProjectJdkImpl in project ballerina by ballerina-lang.
the class BallerinaCodeInsightFixtureTestCase method createMockSdk.
@NotNull
private static Sdk createMockSdk(@NotNull String version) {
String homePath = new File(getTestDataPath("mockSdk-") + version + "/").getAbsolutePath();
BallerinaSdkType sdkType = BallerinaSdkType.getInstance();
ProjectJdkImpl sdk = new ProjectJdkImpl("Ballerina " + version, sdkType, homePath, version);
sdkType.setupSdkPaths(sdk);
sdk.setVersionString(version);
return sdk;
}
use of com.intellij.openapi.projectRoots.impl.ProjectJdkImpl in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoProjectModelConverterProvider method convertSdks.
private static void convertSdks() {
ProjectJdkTable sdkTable = ProjectJdkTable.getInstance();
Collection<String> globalGoPathUrls = ContainerUtil.newLinkedHashSet();
Collection<Sdk> sdksToDelete = ContainerUtil.newArrayList();
Collection<Sdk> sdksToAdd = ContainerUtil.newArrayList();
GoSdkType sdkType = GoSdkType.getInstance();
for (Sdk sdk : sdkTable.getAllJdks()) {
String sdkTypeName = sdk.getSdkType().getName();
if (isGoSdkType(sdkTypeName)) {
sdksToDelete.add(sdk);
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);
for (String classesRoot : sdk.getRootProvider().getUrls(OrderRootType.CLASSES)) {
if (!classesRoot.equals(sdk.getHomePath())) {
globalGoPathUrls.add(classesRoot);
}
}
}
}
}
for (VirtualFile file : GoSdkUtil.getGoPathsRootsFromEnvironment()) {
globalGoPathUrls.remove(file.getUrl());
}
AccessToken l = WriteAction.start();
try {
for (Sdk sdk : sdksToDelete) {
sdkTable.removeJdk(sdk);
}
for (Sdk sdk : sdksToAdd) {
sdkTable.addJdk(sdk);
}
globalGoPathUrls.addAll(GoApplicationLibrariesService.getInstance().getLibraryRootUrls());
GoApplicationLibrariesService.getInstance().setLibraryRootUrls(globalGoPathUrls);
} finally {
l.finish();
}
}
Aggregations