optimization
authorAlexey Kudravtsev <cdr@intellij.com>
Fri, 25 Jun 2010 07:59:20 +0000 (11:59 +0400)
committerAlexey Kudravtsev <cdr@intellij.com>
Fri, 25 Jun 2010 08:46:41 +0000 (12:46 +0400)
platform/platform-api/src/com/intellij/openapi/application/ex/PathManagerEx.java

index e81becf3bc2b15a6518bff6862aca7df0ce8769c..7573e3194c965dcce6e2dccdb3e5212f05c0d911 100644 (file)
@@ -118,12 +118,8 @@ public class PathManagerEx {
 
   static {
     TEST_DATA_RELATIVE_PATHS.put(TestDataLookupStrategy.ULTIMATE, Collections.singletonList(toSystemDependentName("testData")));
-    TEST_DATA_RELATIVE_PATHS.put(
-      TestDataLookupStrategy.COMMUNITY, Collections.singletonList(toSystemDependentName("java/java-tests/testData"))
-    );
-    TEST_DATA_RELATIVE_PATHS.put(
-      TestDataLookupStrategy.COMMUNITY_FROM_ULTIMATE, Collections.singletonList(toSystemDependentName("community/java/java-tests/testData"))
-    );
+    TEST_DATA_RELATIVE_PATHS.put(TestDataLookupStrategy.COMMUNITY, Collections.singletonList(toSystemDependentName("java/java-tests/testData")));
+    TEST_DATA_RELATIVE_PATHS.put(TestDataLookupStrategy.COMMUNITY_FROM_ULTIMATE, Collections.singletonList(toSystemDependentName("community/java/java-tests/testData")));
   }
 
   /**
@@ -156,10 +152,16 @@ public class PathManagerEx {
    * @throws IllegalStateException    as defined by {@link #getTestDataPath(TestDataLookupStrategy)}
    */
   public static String getTestDataPath(Class<?> testClass) throws IllegalStateException {
-    TestDataLookupStrategy strategy = determineLookupStrategy(testClass);
+    TestDataLookupStrategy strategy = isLocatedInCommunity() ? TestDataLookupStrategy.COMMUNITY : determineLookupStrategy(testClass);
     return getTestDataPath(strategy);
   }
 
+  private static boolean isLocatedInCommunity() {
+    FileSystemLocation projectLocation = parseProjectLocation();
+    return projectLocation == FileSystemLocation.COMMUNITY;
+    // There is no other options then.
+  }
+
   /**
    * Tries to return test data path for the given lookup strategy.
    *
@@ -210,6 +212,7 @@ public class PathManagerEx {
   @SuppressWarnings({"ThrowableInstanceNeverThrown"})
   @Nullable
   private static TestDataLookupStrategy guessTestDataLookupStrategyOnClassLocation() {
+    if (isLocatedInCommunity()) return TestDataLookupStrategy.COMMUNITY;
 
     // The general idea here is to find test class at the bottom of hierarchy and try to resolve test data lookup strategy
     // against it. Rationale is that there is a possible case that, say, 'ultimate' test class extends basic test class
@@ -274,13 +277,7 @@ public class PathManagerEx {
   }
 
   @Nullable
-  public static TestDataLookupStrategy determineLookupStrategy(Class<?> clazz) {
-    FileSystemLocation projectLocation = parseProjectLocation();
-    if (projectLocation == FileSystemLocation.COMMUNITY) {
-      // There is no other options then.
-      return TestDataLookupStrategy.COMMUNITY;
-    }
-
+  private static TestDataLookupStrategy determineLookupStrategy(Class<?> clazz) {
     // Check if resulting strategy is already cached for the target class.
     TestDataLookupStrategy result = CLASS_STRATEGY_CACHE.get(clazz);
     if (result != null) {