use of com.goide.sdk.GoSdkType 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();
}
}
use of com.goide.sdk.GoSdkType in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoCodeInsightFixtureTestCase method createMockSdk.
@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;
}
Aggregations