@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); } }); } }
@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); } }