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

Unified Diff: pkg/compiler/lib/src/compiler.dart

Issue 1314973003: Add support for analyzing individual URIs. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment Created 5 years, 4 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
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | pkg/compiler/lib/src/diagnostics/source_span.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compiler.dart
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 205222c8886f6d1af9d3a768156b1468879c8af0..4a4127a5b79275db2b4f1e3539f83aa485c2bacf 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -1046,6 +1046,30 @@ abstract class Compiler implements DiagnosticListener {
}
}
+ /// Analyze all member of the library in [libraryUri].
+ ///
+ /// If [skipLibraryWithPartOfTag] is `true`, member analysis is skipped if the
+ /// library has a `part of` tag, assuming it is a part and not a library.
+ ///
+ /// This operation assumes an unclosed resolution queue and is only supported
+ /// when the '--analyze-main' option is used.
+ Future<LibraryElement> analyzeUri(
+ Uri libraryUri,
+ {bool skipLibraryWithPartOfTag: true}) {
+ assert(analyzeMain);
+ log('Analyzing $libraryUri ($buildId)');
+ return libraryLoader.loadLibrary(libraryUri).then((LibraryElement library) {
+ var compilationUnit = library.compilationUnit;
+ if (skipLibraryWithPartOfTag && compilationUnit.partTag != null) {
+ return null;
+ }
+ fullyEnqueueLibrary(library, enqueuer.resolution);
+ emptyQueue(enqueuer.resolution);
+ enqueuer.resolution.logSummary(log);
+ return library;
+ });
+ }
+
/// Performs the compilation when all libraries have been loaded.
void compileLoadedLibraries() {
computeMain();
@@ -1183,6 +1207,17 @@ abstract class Compiler implements DiagnosticListener {
}
}
+ /**
+ * Empty the [world] queue.
+ */
+ void emptyQueue(Enqueuer world) {
+ world.forEach((WorkItem work) {
+ withCurrentElement(work.element, () {
+ world.applyImpact(work.element, work.run(this, world));
+ });
+ });
+ }
+
void processQueue(Enqueuer world, Element main) {
world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries);
if (main != null && !main.isErroneous) {
@@ -1204,11 +1239,7 @@ abstract class Compiler implements DiagnosticListener {
if (verbose) {
progress.reset();
}
- world.forEach((WorkItem work) {
- withCurrentElement(work.element, () {
- world.applyImpact(work.element, work.run(this, world));
- });
- });
+ emptyQueue(world);
world.queueIsClosed = true;
assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods());
}
@@ -1395,8 +1426,7 @@ abstract class Compiler implements DiagnosticListener {
if (uri == null && currentElement != null) {
uri = currentElement.compilationUnit.script.resourceUri;
}
- return SourceSpan.withCharacterOffsets(begin, end,
- (beginOffset, endOffset) => new SourceSpan(uri, beginOffset, endOffset));
+ return new SourceSpan.fromTokens(uri, begin, end);
}
SourceSpan spanFromNode(Node node) {
« no previous file with comments | « pkg/compiler/lib/src/apiimpl.dart ('k') | pkg/compiler/lib/src/diagnostics/source_span.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698