Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java |
diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java |
index 3a8171e70c9d085e30bc0d1a8b79c41d3d09f977..0083fe35cd4f52e3705b8aed4e5a41b24ce506ff 100644 |
--- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java |
+++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/model/DartLibraryImpl.java |
@@ -14,6 +14,7 @@ |
package com.google.dart.tools.core.internal.model; |
import com.google.common.collect.Lists; |
+import com.google.common.collect.Maps; |
import com.google.common.collect.Sets; |
import com.google.dart.compiler.DartSource; |
import com.google.dart.compiler.LibrarySource; |
@@ -86,6 +87,14 @@ import java.util.Set; |
public class DartLibraryImpl extends OpenableElementImpl implements DartLibrary, |
CompilationUnitContainer { |
public static final DartLibraryImpl[] EMPTY_LIBRARY_ARRAY = new DartLibraryImpl[0]; |
+ private static final Map<URI, Boolean> localUris = Maps.newHashMap(); |
+ |
+ /** |
+ * Clears "local or not" cache when set of projects is changed. |
+ */ |
+ public static void clearLocalUrisCache() { |
Brian Wilkerson
2012/07/13 15:00:08
This makes me nervous because it's too easy for so
scheglov
2012/07/13 16:48:10
OK, I will try to address this in the next CL.
|
+ localUris.clear(); |
+ } |
/** |
* Add the transitive closure of CompilationUnits from the given library to the units list. Record |
@@ -601,15 +610,13 @@ public class DartLibraryImpl extends OpenableElementImpl implements DartLibrary, |
*/ |
@Override |
public boolean isLocal() { |
- // Check the most common case |
- IProject project = ((DartProjectImpl) getParent()).getProject(); |
- if (project.isOpen()) { |
- return true; |
+ URI uri = sourceFile.getUri(); |
+ Boolean local = localUris.get(uri); |
+ if (local == null) { |
+ local = isLocal0(); |
+ localUris.put(uri, local); |
} |
- |
- // Check for external reference to file in open project |
- IResource resource = ResourceUtil.getResource(sourceFile); |
- return resource != null && resource.getProject().isOpen(); |
+ return local.booleanValue(); |
} |
/** |
@@ -1140,6 +1147,17 @@ public class DartLibraryImpl extends OpenableElementImpl implements DartLibrary, |
return false; |
} |
+ private Boolean isLocal0() { |
+ // Check the most common case |
+ IProject project = ((DartProjectImpl) getParent()).getProject(); |
+ if (project.isOpen()) { |
+ return true; |
+ } |
+ // Check for external reference to file in open project |
+ IResource resource = ResourceUtil.getResource(sourceFile); |
+ return resource != null && resource.getProject().isOpen(); |
+ } |
+ |
/** |
* Return the result of parsing the file that defines this library, or <code>null</code> if the |
* contents of the file cannot be accessed for some reason. |