@Override public void chooseAndSetSdk(@Nullable Module module) { Sdk projectSdk = ProjectSettingsService.getInstance(myProject).chooseAndSetSdk(); if (projectSdk == null && module != null) { ApplicationManager.getApplication().runWriteAction(() -> { if (!module.isDisposed()) { ModuleRootModificationUtil.setSdkInherited(module); } }); } }
private void attachLibraries(@NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!libraryRoots.isEmpty()) { ApplicationManager.getApplication().runWriteAction(() -> { ModuleRootManager model = ModuleRootManager.getInstance(myModule); LibraryOrderEntry goLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (goLibraryEntry != null && goLibraryEntry.isValid()) { Library library = goLibraryEntry.getLibrary(); if (library != null && !((LibraryEx)library).isDisposed()) { fillLibrary(library, libraryRoots, exclusions); } } else { LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule.getProject()); Library library = libraryTable.createLibrary(getLibraryName()); fillLibrary(library, libraryRoots, exclusions); ModuleRootModificationUtil.addDependency(myModule, library); } }); showNotification(myModule.getProject()); } else { removeLibraryIfNeeded(); } }
@Override public void run() { JavaTestUtil.setupTestJDK(); ModuleRootModificationUtil.setModuleSdk( module, JavaTestUtil.getTestJdk()); } });
private void attachLibraries(@NotNull Collection<VirtualFile> libraryRoots, Set<VirtualFile> exclusions) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!libraryRoots.isEmpty()) { ApplicationManager.getApplication().runWriteAction(() -> { ModuleRootManager model = ModuleRootManager.getInstance(myModule); LibraryOrderEntry ballerinaLibraryEntry = OrderEntryUtil.findLibraryOrderEntry(model, getLibraryName()); if (ballerinaLibraryEntry != null && ballerinaLibraryEntry.isValid()) { Library library = ballerinaLibraryEntry.getLibrary(); if (library != null && !((LibraryEx) library).isDisposed()) { fillLibrary(library, libraryRoots, exclusions); } } else { LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myModule .getProject()); Library library = libraryTable.createLibrary(getLibraryName()); fillLibrary(library, libraryRoots, exclusions); ModuleRootModificationUtil.addDependency(myModule, library); } }); showNotification(myModule.getProject()); } else { removeLibraryIfNeeded(); } }
@Override public void chooseAndSetSdk(@Nullable Module module) { Sdk projectSdk = ProjectSettingsService.getInstance(myProject).chooseAndSetSdk(); if (projectSdk == null && module != null) { ApplicationManager.getApplication().runWriteAction(() -> { if (!module.isDisposed()) { ModuleRootModificationUtil.setSdkInherited(module); } }); } // Need to prompt a restart action to clear and re initiate language server instance from the new SDK. // Todo - Figure out a way to apply language server changes without restarting. if (isBallerinaSdk(projectSdk)) { ApplicationManager.getApplication().invokeLater(this::showRestartDialog); } }
@Override public void projectSdkChanged(@Nullable Sdk sdk) { // First we get the date context from the focus (current project). AsyncResult<DataContext> dataContextFromFocus = DataManager.getInstance().getDataContextFromFocus(); // Get the result from the data context. DataContext result = dataContextFromFocus.getResult(); if (result == null) { return; } // Get the current project. Project project = DataKeys.PROJECT.getData(result); if (project == null) { return; } // Get all modules in the project. Module[] modules = ModuleManager.getInstance(project).getModules(); // Iterate through all modules. for (Module module : modules) { // Check whether the module is a Ballerina module. if (BallerinaSdkService.getInstance(project).isBallerinaModule(module)) { // If it is a Ballerina module, inherit the project SDK. WriteAction.run(() -> ModuleRootModificationUtil.setSdkInherited(module)); } } // Need to prompt a restart action to clear and re initiate language server instance from the new SDK. // Todo - Figure out a way to apply language server changes without restarting. if (isBallerinaSdk(sdk)) { ApplicationManager.getApplication().invokeLater(this::showRestartDialog); } }