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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/ParseLibraryFileTask.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/ParseLibraryFileTask.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/ParseLibraryFileTask.java (revision 7495)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/analysis/ParseLibraryFileTask.java (working copy)
@@ -14,6 +14,7 @@
package com.google.dart.tools.core.analysis;
import com.google.dart.compiler.UrlLibrarySource;
+import com.google.dart.compiler.ast.DartDirective;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.tools.core.DartCore;
@@ -22,6 +23,7 @@
import java.io.File;
import java.net.URI;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
/**
@@ -54,15 +56,35 @@
@Override
void perform() {
Library library = context.getCachedLibrary(libraryFile);
+
+ // Get the cached unit or parse the source
+
+ DartUnit unit = null;
+ if (library != null) {
+ unit = library.getResolvedUnit(libraryFile);
+ }
+ if (unit == null) {
+ unit = context.getUnresolvedUnit(libraryFile);
+ if (unit == null) {
+ Set<String> prefixes = new HashSet<String>();
+ unit = parse(server, libraryFile, librarySource, libraryFile, prefixes);
+ context.cacheUnresolvedUnit(libraryFile, unit);
+ }
+ }
+
+ // Ensure the library is built
+
if (library == null) {
- Set<String> prefixes = new HashSet<String>();
- DartUnit unit = parse(server, libraryFile, librarySource, libraryFile, prefixes);
- library = Library.fromDartUnit(server, libraryFile, librarySource, unit, prefixes);
+ List<DartDirective> directives = unit.getDirectives();
+ library = Library.fromDartUnit(server, libraryFile, librarySource, directives);
context.cacheLibrary(library);
}
+
+ // Notify the caller
+
if (callback != null) {
try {
- callback.parsed(new ParseLibraryFileEvent(library));
+ callback.parsed(new ParseLibraryFileEvent(library, unit));
} catch (Throwable e) {
DartCore.logError("Exception during parse notification", e);
}

Powered by Google App Engine
This is Rietveld 408576698