| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer.src.summary.summary_sdk; | 5 library analyzer.src.summary.summary_sdk; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/element/element.dart'; | 7 import 'package:analyzer/dart/element/element.dart'; |
| 8 import 'package:analyzer/dart/element/type.dart'; | 8 import 'package:analyzer/dart/element/type.dart'; |
| 9 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider; | 9 import 'package:analyzer/file_system/file_system.dart' show ResourceProvider; |
| 10 import 'package:analyzer/src/context/context.dart'; | 10 import 'package:analyzer/src/context/context.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 SummaryDataStore _dataStore; | 29 SummaryDataStore _dataStore; |
| 30 InSummaryUriResolver _uriResolver; | 30 InSummaryUriResolver _uriResolver; |
| 31 PackageBundle _bundle; | 31 PackageBundle _bundle; |
| 32 ResourceProvider resourceProvider; | 32 ResourceProvider resourceProvider; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * The [AnalysisContext] which is used for all of the sources in this sdk. | 35 * The [AnalysisContext] which is used for all of the sources in this sdk. |
| 36 */ | 36 */ |
| 37 InternalAnalysisContext _analysisContext; | 37 InternalAnalysisContext _analysisContext; |
| 38 | 38 |
| 39 SummaryBasedDartSdk(String summaryPath, this.strongMode) { | 39 SummaryBasedDartSdk(String summaryPath, this.strongMode, |
| 40 _dataStore = new SummaryDataStore(<String>[summaryPath]); | 40 {this.resourceProvider}) { |
| 41 _dataStore = new SummaryDataStore(<String>[summaryPath], |
| 42 resourceProvider: resourceProvider); |
| 41 _uriResolver = new InSummaryUriResolver(resourceProvider, _dataStore); | 43 _uriResolver = new InSummaryUriResolver(resourceProvider, _dataStore); |
| 42 _bundle = _dataStore.bundles.single; | 44 _bundle = _dataStore.bundles.single; |
| 43 } | 45 } |
| 44 | 46 |
| 45 SummaryBasedDartSdk.fromBundle( | 47 SummaryBasedDartSdk.fromBundle(this.strongMode, PackageBundle bundle, |
| 46 this.strongMode, PackageBundle bundle, this.resourceProvider) { | 48 {this.resourceProvider}) { |
| 47 _dataStore = new SummaryDataStore([]); | 49 _dataStore = new SummaryDataStore([], resourceProvider: resourceProvider); |
| 48 _dataStore.addBundle('dart_sdk.sum', bundle); | 50 _dataStore.addBundle('dart_sdk.sum', bundle); |
| 49 _uriResolver = new InSummaryUriResolver(resourceProvider, _dataStore); | 51 _uriResolver = new InSummaryUriResolver(resourceProvider, _dataStore); |
| 50 _bundle = bundle; | 52 _bundle = bundle; |
| 51 } | 53 } |
| 52 | 54 |
| 53 /** | 55 /** |
| 54 * Return the [PackageBundle] for this SDK, not `null`. | 56 * Return the [PackageBundle] for this SDK, not `null`. |
| 55 */ | 57 */ |
| 56 PackageBundle get bundle => _bundle; | 58 PackageBundle get bundle => _bundle; |
| 57 | 59 |
| 58 @override | 60 @override |
| 59 AnalysisContext get context { | 61 AnalysisContext get context { |
| 60 if (_analysisContext == null) { | 62 if (_analysisContext == null) { |
| 61 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl() | 63 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl() |
| 62 ..strongMode = strongMode; | 64 ..strongMode = strongMode; |
| 63 _analysisContext = new SdkAnalysisContext(analysisOptions); | 65 _analysisContext = new SdkAnalysisContext(analysisOptions); |
| 64 SourceFactory factory = new SourceFactory( | 66 SourceFactory factory = new SourceFactory( |
| 65 [new DartUriResolver(this)], null, resourceProvider); | 67 [new DartUriResolver(this)], null, resourceProvider); |
| 66 _analysisContext.sourceFactory = factory; | 68 _analysisContext.sourceFactory = factory; |
| 67 SummaryDataStore dataStore = new SummaryDataStore([]); | 69 SummaryDataStore dataStore = |
| 70 new SummaryDataStore([], resourceProvider: resourceProvider); |
| 68 dataStore.addBundle(null, _bundle); | 71 dataStore.addBundle(null, _bundle); |
| 69 _analysisContext.resultProvider = | 72 _analysisContext.resultProvider = |
| 70 new InputPackagesResultProvider(_analysisContext, dataStore); | 73 new InputPackagesResultProvider(_analysisContext, dataStore); |
| 71 } | 74 } |
| 72 return _analysisContext; | 75 return _analysisContext; |
| 73 } | 76 } |
| 74 | 77 |
| 75 @override | 78 @override |
| 76 List<SdkLibrary> get sdkLibraries { | 79 List<SdkLibrary> get sdkLibraries { |
| 77 throw new UnimplementedError(); | 80 throw new UnimplementedError(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 * throw a [StateError] if there is no class with the given name. | 353 * throw a [StateError] if there is no class with the given name. |
| 351 */ | 354 */ |
| 352 InterfaceType _getType(LibraryElement library, String name) { | 355 InterfaceType _getType(LibraryElement library, String name) { |
| 353 Element element = library.getType(name); | 356 Element element = library.getType(name); |
| 354 if (element == null) { | 357 if (element == null) { |
| 355 throw new StateError("No definition of type $name"); | 358 throw new StateError("No definition of type $name"); |
| 356 } | 359 } |
| 357 return (element as ClassElement).type; | 360 return (element as ClassElement).type; |
| 358 } | 361 } |
| 359 } | 362 } |
| OLD | NEW |