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;
}
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);
}
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();
}
}
Aggregations