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

Unified Diff: pkg/code_transformers/lib/src/resolver_transformer.dart

Issue 181383015: Refactoring resolvers to make them able to be run in parallel. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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: pkg/code_transformers/lib/src/resolver_transformer.dart
diff --git a/pkg/code_transformers/lib/src/resolver_transformer.dart b/pkg/code_transformers/lib/src/resolver_transformer.dart
deleted file mode 100644
index ed8325a86340ac1f5ca0da05a0fc3d5c5d38d104..0000000000000000000000000000000000000000
--- a/pkg/code_transformers/lib/src/resolver_transformer.dart
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library code_transformers.src.resolver_transformer;
-
-import 'dart:async';
-import 'package:barback/barback.dart';
-
-import 'resolver.dart';
-import 'resolver_impl.dart';
-
-/// Filter for whether the specified asset is an entry point to the Dart
-/// application.
-typedef EntryPointFilter(Asset input);
-
-/// Transformer which maintains up-to-date resolved ASTs for the specified
-/// code entry points.
-///
-/// This can used by transformers dependent on resolved ASTs which can reference
-/// this transformer to get the resolver needed.
-///
-/// This transformer must be in a phase before any dependent transformers. The
-/// resolve AST is automatically updated any time any dependent assets are
-/// changed.
-///
-/// This will only resolve the AST for code beginning from assets which are
-/// accepted by [entryPointFilter].
-///
-/// If multiple transformers rely on a resolved AST they should (ideally) share
-/// the same ResolverTransformer to avoid re-parsing the AST.
-class ResolverTransformer extends Transformer {
- final Map<AssetId, Resolver> _resolvers = {};
- final EntryPointFilter entryPointFilter;
- final String dartSdkDirectory;
-
- ResolverTransformer(this.dartSdkDirectory, this.entryPointFilter);
-
- Future<bool> isPrimary(Asset input) =>
- new Future.value(entryPointFilter(input));
-
- /// Updates the resolved AST for the primary input of the transform.
- Future apply(Transform transform) {
- var resolver = getResolver(transform.primaryInput.id);
-
- return resolver.updateSources(transform).then((_) {
- transform.addOutput(transform.primaryInput);
- return null;
- });
- }
-
- /// Get a resolver for the AST starting from [id].
- Resolver getResolver(AssetId id) =>
- _resolvers.putIfAbsent(id, () => new ResolverImpl(id, dartSdkDirectory));
-}

Powered by Google App Engine
This is Rietveld 408576698