| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library code_transformers.src.resolvers; | 5 library code_transformers.src.resolvers; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:barback/barback.dart'; | 8 import 'package:barback/barback.dart'; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptions; | 11 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptions; |
| 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 12 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; | 14 import 'package:analyzer/src/generated/source.dart' show DartUriResolver; |
| 14 | 15 |
| 15 import 'entry_point.dart'; | 16 import 'entry_point.dart'; |
| 16 import 'resolver.dart'; | 17 import 'resolver.dart'; |
| 17 import 'resolver_impl.dart'; | 18 import 'resolver_impl.dart'; |
| 18 import 'dart_sdk.dart' hide dartSdkDirectory; | 19 import 'dart_sdk.dart' hide dartSdkDirectory; |
| 19 | 20 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 36 /// resolvers object is used. Any time that [Resolvers#get] or | 37 /// resolvers object is used. Any time that [Resolvers#get] or |
| 37 /// [Resolver#resolve] are called it will update the sources globally when | 38 /// [Resolver#resolve] are called it will update the sources globally when |
| 38 /// this option is in use. | 39 /// this option is in use. |
| 39 final Map<AssetId, AssetBasedSource> sharedSources; | 40 final Map<AssetId, AssetBasedSource> sharedSources; |
| 40 | 41 |
| 41 Resolvers.fromSdk(this.dartSdk, this.dartUriResolver, | 42 Resolvers.fromSdk(this.dartSdk, this.dartUriResolver, |
| 42 {this.options, bool useSharedSources}) | 43 {this.options, bool useSharedSources}) |
| 43 : sharedSources = | 44 : sharedSources = |
| 44 useSharedSources == true ? <AssetId, AssetBasedSource>{} : null; | 45 useSharedSources == true ? <AssetId, AssetBasedSource>{} : null; |
| 45 | 46 |
| 46 factory Resolvers(dartSdkDirectory, | 47 factory Resolvers(String dartSdkDirectory, |
| 47 {AnalysisOptions options, bool useSharedSources}) { | 48 {AnalysisOptions options, bool useSharedSources}) { |
| 48 _initAnalysisEngine(); | 49 _initAnalysisEngine(); |
| 49 var sdk = new DirectoryBasedDartSdkProxy(dartSdkDirectory); | 50 var sdk = new FolderBasedDartSdkProxy( |
| 51 PhysicalResourceProvider.INSTANCE, dartSdkDirectory); |
| 50 var uriResolver = new DartUriResolverProxy(sdk); | 52 var uriResolver = new DartUriResolverProxy(sdk); |
| 51 return new Resolvers.fromSdk(sdk, uriResolver, | 53 return new Resolvers.fromSdk(sdk, uriResolver, |
| 52 options: options, useSharedSources: useSharedSources); | 54 options: options, useSharedSources: useSharedSources); |
| 53 } | 55 } |
| 54 | 56 |
| 55 factory Resolvers.fromMock(Map<String, String> sources, | 57 factory Resolvers.fromMock(Map<String, String> sources, |
| 56 {bool reportMissing: false, | 58 {bool reportMissing: false, |
| 57 AnalysisOptions options, | 59 AnalysisOptions options, |
| 58 bool useSharedSources}) { | 60 bool useSharedSources}) { |
| 59 _initAnalysisEngine(); | 61 _initAnalysisEngine(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 /// Return a Future to indicate when apply is completed. | 150 /// Return a Future to indicate when apply is completed. |
| 149 applyResolver(Transform transform, Resolver resolver); | 151 applyResolver(Transform transform, Resolver resolver); |
| 150 } | 152 } |
| 151 | 153 |
| 152 bool _analysisEngineInitialized = false; | 154 bool _analysisEngineInitialized = false; |
| 153 _initAnalysisEngine() { | 155 _initAnalysisEngine() { |
| 154 if (_analysisEngineInitialized) return; | 156 if (_analysisEngineInitialized) return; |
| 155 _analysisEngineInitialized = true; | 157 _analysisEngineInitialized = true; |
| 156 AnalysisEngine.instance.processRequiredPlugins(); | 158 AnalysisEngine.instance.processRequiredPlugins(); |
| 157 } | 159 } |
| OLD | NEW |