Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/Context.java

Issue 10389074: Cache unresolved units separately from libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/Context.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/Context.java (revision 7495)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/Context.java (working copy)
@@ -13,9 +13,11 @@
*/
package com.google.dart.tools.core.analysis;
+import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.tools.core.DartCore;
import java.io.File;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -33,14 +35,27 @@
*/
private final HashMap<File, Library> libraryCache;
+ /**
+ * A map of URI (as needed by DartC) to parsed but unresolved unit. Units are added to this
+ * collection by {@link ParseFileTask} and {@link ParseLibraryFileTask}, and removed from this
+ * collection by {@link ResolveLibraryTask} when it calls
+ * {@link AnalysisUtility#resolve(AnalysisServer, Library, java.util.Map, java.util.Map)}
+ */
+ private final HashMap<URI, DartUnit> unresolvedUnits;
+
Context() {
this.libraryCache = new HashMap<File, Library>();
+ this.unresolvedUnits = new HashMap<URI, DartUnit>();
}
void cacheLibrary(Library library) {
libraryCache.put(library.getFile(), library);
}
+ void cacheUnresolvedUnit(File file, DartUnit unit) {
+ unresolvedUnits.put(file.toURI(), unit);
+ }
+
void discardLibraries() {
libraryCache.clear();
}
@@ -121,6 +136,20 @@
return result;
}
+ /**
+ * Answer a unit that has been parsed but not resolved, or <code>null</code> if none
+ */
+ DartUnit getUnresolvedUnit(File file) {
+ return unresolvedUnits.get(file.toURI());
+ }
+
+ /**
+ * Answer units that have been parsed by not resolved.
+ */
+ HashMap<URI, DartUnit> getUnresolvedUnits() {
+ return unresolvedUnits;
+ }
+
private Library[] append(Library[] oldArray, Library library) {
if (oldArray.length == 0) {
return new Library[] {library};

Powered by Google App Engine
This is Rietveld 408576698