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

Unified Diff: sdk/lib/_internal/pub/lib/src/dart.dart

Issue 331263002: Improve parallelism when loading transformer plugins. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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: sdk/lib/_internal/pub/lib/src/dart.dart
diff --git a/sdk/lib/_internal/pub/lib/src/dart.dart b/sdk/lib/_internal/pub/lib/src/dart.dart
index 64374db6774f06e3e7b94c9bcec6d24cd3271390..9a8510568c66d70f3fd0a814d5500cdcf78187c7 100644
--- a/sdk/lib/_internal/pub/lib/src/dart.dart
+++ b/sdk/lib/_internal/pub/lib/src/dart.dart
@@ -122,6 +122,22 @@ bool isEntrypoint(CompilationUnit dart) {
});
}
+/// Efficiently parses the import and export directives in [contents].
+///
+/// If [name] is passed, it's used as the filename for error reporting.
+List<UriBasedDirective> parseImportsAndExports(String contents, {String name}) {
+ var collector = new _DirectiveCollector();
+ parseDirectives(contents, name: name).accept(collector);
+ return collector.directives;
+}
+
+/// A simple visitor that collects import and export nodes.
+class _DirectiveCollector extends GeneralizingAstVisitor {
+ final directives = <UriBasedDirective>[];
+
+ visitUriBasedDirective(UriBasedDirective node) => directives.add(node);
+}
+
/// Runs [code] in an isolate.
///
/// [code] should be the contents of a Dart entrypoint. It may contain imports;

Powered by Google App Engine
This is Rietveld 408576698