better autodetection of platform prefix

This commit is contained in:
Dmitry Jemerov
2011-12-20 17:38:56 +01:00
parent ab68908323
commit ea0b4b72ed
2 changed files with 18 additions and 5 deletions
@@ -43,11 +43,6 @@ public abstract class IdeaTestCase extends PlatformTestCase {
super.tearDown();
}
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
protected IdeaTestCase() {
initPlatformPrefix();
}
public final JavaPsiFacadeEx getJavaFacade() {
return myJavaFacade;
}
@@ -83,6 +83,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -125,6 +126,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
protected void initApplication() throws Exception {
boolean firstTime = ourApplication == null;
autodetectPlatformPrefix();
ourApplication = IdeaTestApplication.getInstance(getApplicationConfigDirPath());
ourApplication.setDataProvider(this);
@@ -133,6 +135,22 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
}
}
private static void autodetectPlatformPrefix() {
if (ourPlatformPrefixInitialized) {
return;
}
URL resource = PlatformTestCase.class.getClassLoader().getResource("idea/ApplicationInfo.xml");
if (resource == null) {
resource = PlatformTestCase.class.getClassLoader().getResource("idea/IdeaApplicationInfo.xml");
if (resource == null) {
System.setProperty("idea.platform.prefix", "PlatformLangXml");
}
else {
System.setProperty("idea.platform.prefix", "Idea");
}
}
}
private static void cleanPersistedVFSContent() {
((PersistentFS)ManagingFS.getInstance()).cleanPersistedContents();
}