Search in sources :

Example 1 with JavaAwareProjectJdkTableImpl

use of com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl in project intellij-community by JetBrains.

the class CompilerTestUtil method enableExternalCompiler.

@TestOnly
public static void enableExternalCompiler() {
    final JavaAwareProjectJdkTableImpl table = JavaAwareProjectJdkTableImpl.getInstanceEx();
    new WriteAction() {

        @Override
        protected void run(@NotNull final Result result) {
            table.addJdk(table.getInternalJdk());
        }
    }.execute();
}
Also used : WriteAction(com.intellij.openapi.application.WriteAction) JavaAwareProjectJdkTableImpl(com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl) Result(com.intellij.openapi.application.Result) TestOnly(org.jetbrains.annotations.TestOnly)

Example 2 with JavaAwareProjectJdkTableImpl

use of com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl in project intellij-community by JetBrains.

the class CompilerTestUtil method disableExternalCompiler.

@TestOnly
public static void disableExternalCompiler(@NotNull final Project project) {
    EdtTestUtil.runInEdtAndWait(() -> {
        final JavaAwareProjectJdkTableImpl table = JavaAwareProjectJdkTableImpl.getInstanceEx();
        ApplicationManager.getApplication().runWriteAction(() -> {
            Sdk internalJdk = table.getInternalJdk();
            List<Module> modulesToRestore = new SmartList<>();
            for (Module module : ModuleManager.getInstance(project).getModules()) {
                Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
                if (sdk != null && sdk.equals(internalJdk)) {
                    modulesToRestore.add(module);
                }
            }
            table.removeJdk(internalJdk);
            for (Module module : modulesToRestore) {
                ModuleRootModificationUtil.setModuleSdk(module, internalJdk);
            }
            BuildManager.getInstance().clearState(project);
        });
    });
}
Also used : JavaAwareProjectJdkTableImpl(com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) SmartList(com.intellij.util.SmartList) Module(com.intellij.openapi.module.Module) TestOnly(org.jetbrains.annotations.TestOnly)

Aggregations

JavaAwareProjectJdkTableImpl (com.intellij.openapi.projectRoots.impl.JavaAwareProjectJdkTableImpl)2 TestOnly (org.jetbrains.annotations.TestOnly)2 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 Module (com.intellij.openapi.module.Module)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 SmartList (com.intellij.util.SmartList)1