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

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

Issue 336013003: Version 1.5.0-dev.4.14 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: 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
« no previous file with comments | « dart/pkg/code_transformers/lib/src/resolver_impl.dart ('k') | dart/pkg/code_transformers/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/code_transformers/lib/src/resolvers.dart
===================================================================
--- dart/pkg/code_transformers/lib/src/resolvers.dart (revision 37358)
+++ dart/pkg/code_transformers/lib/src/resolvers.dart (working copy)
@@ -7,9 +7,13 @@
import 'dart:async';
import 'package:barback/barback.dart';
+import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
+import 'package:analyzer/src/generated/source.dart' show DartUriResolver;
+
import 'entry_point.dart';
import 'resolver.dart';
import 'resolver_impl.dart';
+import 'dart_sdk.dart' hide dartSdkDirectory;
/// Barback-based code resolvers which maintains up-to-date resolved ASTs for
/// the specified code entry points.
@@ -21,10 +25,23 @@
/// the same Resolvers object to minimize re-parsing the AST.
class Resolvers {
final Map<AssetId, Resolver> _resolvers = {};
- final String dartSdkDirectory;
+ final DartSdk dartSdk;
+ final DartUriResolver dartUriResolver;
- Resolvers(this.dartSdkDirectory);
+ Resolvers.fromSdk(this.dartSdk, this.dartUriResolver);
+ factory Resolvers(dartSdkDirectory) {
+ var sdk = new DirectoryBasedDartSdkProxy(dartSdkDirectory);
+ var uriResolver = new DartUriResolverProxy(sdk);
+ return new Resolvers.fromSdk(sdk, uriResolver);
+ }
+
+ factory Resolvers.fromMock(Map<String, String> sources,
+ {bool reportMissing: false}) {
+ var sdk = new MockDartSdk(sources, reportMissing: reportMissing);
+ return new Resolvers.fromSdk(sdk, sdk.resolver);
+ }
+
/// Get a resolver for [transform]. If provided, this resolves the code
/// starting from each of the assets in [entryPoints]. If not, this resolves
/// the code starting from `transform.primaryInput.id` by default.
@@ -35,7 +52,7 @@
Future<Resolver> get(Transform transform, [List<AssetId> entryPoints]) {
var id = transform.primaryInput.id;
var resolver = _resolvers.putIfAbsent(id,
- () => new ResolverImpl(dartSdkDirectory));
+ () => new ResolverImpl(dartSdk, dartUriResolver));
return resolver.resolve(transform, entryPoints);
}
}
« no previous file with comments | « dart/pkg/code_transformers/lib/src/resolver_impl.dart ('k') | dart/pkg/code_transformers/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698