Search in sources :

Example 1 with ProjectJdkTableImpl

use of com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl in project intellij-plugins by JetBrains.

the class ConversionTestBaseEx method doTest.

@Override
protected boolean doTest(String testName, boolean conversionShouldHappen) throws IOException, JDOMException {
    String path = getHomePath() + getBasePath() + testName;
    final File globalBefore = new File(path, "global_before");
    ApplicationManager.getApplication().runWriteAction(() -> {
        try {
            if (checkJdk()) {
                Element d = JDOMUtil.load(new File(globalBefore, JDK_TABLE_XML));
                ConversionHelper.expandPaths(d);
                ((ProjectJdkTableImpl) ProjectJdkTable.getInstance()).loadState(d);
            }
            {
                Element d = JDOMUtil.load(new File(globalBefore, GLOBAL_LIBS_XML));
                ConversionHelper.expandPaths(d);
                ApplicationLibraryTable.getApplicationTable().loadState(d);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    if (!super.doTest(testName, conversionShouldHappen)) {
        return false;
    }
    Path globalAfter = Paths.get(path, "global_after");
    if (checkJdk()) {
        Element sdkState = ((ProjectJdkTableImpl) ProjectJdkTable.getInstance()).getState();
        ConversionHelper.collapsePaths(sdkState);
        assertThat(sdkState).isEqualTo(globalAfter.resolve(JDK_TABLE_XML));
    }
    {
        Element globalLibState = ApplicationLibraryTable.getApplicationTable().getState();
        ConversionHelper.collapsePaths(globalLibState);
        assertThat(globalLibState).isEqualTo(globalAfter.resolve(GLOBAL_LIBS_XML));
    }
    return true;
}
Also used : Path(java.nio.file.Path) Element(org.jdom.Element) ProjectJdkTableImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl) File(java.io.File) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException)

Example 2 with ProjectJdkTableImpl

use of com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl in project intellij-elixir by KronicDeth.

the class ParsingTestCase method setProjectSdkFromSdkHome.

private void setProjectSdkFromSdkHome(@NotNull String sdkHome) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
    MessageBus messageBus = messageBus();
    registerProjectFileIndex(messageBus);
    ProjectRootManager projectRootManager = registerProjectRootManager();
    assertTrue(pathIsValidSdkHome(sdkHome));
    registerExtensionPoint(OrderRootType.EP_NAME, OrderRootType.class);
    registerExtension(OrderRootType.EP_NAME, new JavadocOrderRootType());
    getApplication().addComponent(VirtualFileManager.class, new VirtualFileManagerImpl(new VirtualFileSystem[] { new MockLocalFileSystem() }, messageBus));
    ProjectJdkTable projectJdkTable = new ProjectJdkTableImpl();
    registerApplicationService(ProjectJdkTable.class, projectJdkTable);
    registerExtensionPoint(com.intellij.openapi.projectRoots.SdkType.EP_NAME, com.intellij.openapi.projectRoots.SdkType.class);
    registerExtension(com.intellij.openapi.projectRoots.SdkType.EP_NAME, new ElixirSdkType());
    Sdk sdk = ElixirSdkType.createMockSdk(sdkHome, elixirSdkRelease());
    projectJdkTable.addJdk(sdk);
    ExtensionsArea area = Extensions.getArea(myProject);
    registerExtensionPoint(area, ProjectExtension.EP_NAME, ProjectExtension.class);
    registerExtensionPoint(FilePropertyPusher.EP_NAME, FilePropertyPusher.class);
    myProject.addComponent(PushedFilePropertiesUpdater.class, new PushedFilePropertiesUpdaterImpl(myProject));
    projectRootManager.setProjectSdk(sdk);
}
Also used : MockLocalFileSystem(com.intellij.mock.MockLocalFileSystem) ProjectJdkTableImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl) ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) MessageBus(com.intellij.util.messages.MessageBus) VirtualFileSystem(com.intellij.openapi.vfs.VirtualFileSystem) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) VirtualFileManagerImpl(com.intellij.openapi.vfs.impl.VirtualFileManagerImpl) Sdk(com.intellij.openapi.projectRoots.Sdk) ElixirSdkType(org.elixir_lang.sdk.ElixirSdkType)

Example 3 with ProjectJdkTableImpl

use of com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl in project intellij-plugins by JetBrains.

the class ConversionTestBaseEx method tearDown.

@Override
protected void tearDown() throws Exception {
    try {
        ApplicationManager.getApplication().runWriteAction(() -> {
            final Library[] libraries = ApplicationLibraryTable.getApplicationTable().getLibraries();
            for (Library library : libraries) {
                ApplicationLibraryTable.getApplicationTable().removeLibrary(library);
            }
            ApplicationLibraryTable.getApplicationTable().loadState(myOriginalGlobalLibraries);
            if (checkJdk()) {
                ((ProjectJdkTableImpl) ProjectJdkTable.getInstance()).loadState(myOriginalSkds);
            }
        });
        if (checkJdk()) {
            PathMacros.getInstance().removeMacro(SDK_HOME_VAR);
            PathMacros.getInstance().removeMacro(SDK_HOME_VAR_2);
        }
        if (PathMacros.getInstance().getAllMacroNames().contains(PROJECT_VAR)) {
            PathMacros.getInstance().removeMacro(PROJECT_VAR);
        }
    } finally {
        super.tearDown();
    }
}
Also used : ProjectJdkTableImpl(com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl) Library(com.intellij.openapi.roots.libraries.Library)

Aggregations

ProjectJdkTableImpl (com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl)3 MockLocalFileSystem (com.intellij.mock.MockLocalFileSystem)1 ExtensionsArea (com.intellij.openapi.extensions.ExtensionsArea)1 ProjectJdkTable (com.intellij.openapi.projectRoots.ProjectJdkTable)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 Library (com.intellij.openapi.roots.libraries.Library)1 VirtualFileSystem (com.intellij.openapi.vfs.VirtualFileSystem)1 VirtualFileManagerImpl (com.intellij.openapi.vfs.impl.VirtualFileManagerImpl)1 MessageBus (com.intellij.util.messages.MessageBus)1 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ElixirSdkType (org.elixir_lang.sdk.ElixirSdkType)1 Element (org.jdom.Element)1 JDOMException (org.jdom.JDOMException)1