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.context.context; | 5 library analyzer.src.context.context; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 2155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2166 * Otherwise, it returns `false` to indicate that the result should be | 2166 * Otherwise, it returns `false` to indicate that the result should be |
2167 * computed as usually. | 2167 * computed as usually. |
2168 */ | 2168 */ |
2169 bool compute(CacheEntry entry, ResultDescriptor result); | 2169 bool compute(CacheEntry entry, ResultDescriptor result); |
2170 } | 2170 } |
2171 | 2171 |
2172 /** | 2172 /** |
2173 * An [AnalysisContext] that only contains sources for a Dart SDK. | 2173 * An [AnalysisContext] that only contains sources for a Dart SDK. |
2174 */ | 2174 */ |
2175 class SdkAnalysisContext extends AnalysisContextImpl { | 2175 class SdkAnalysisContext extends AnalysisContextImpl { |
| 2176 /** |
| 2177 * Initialize a newly created SDK analysis context with the given [options]. |
| 2178 * Analysis options cannot be changed afterwards. If the given [options] are |
| 2179 * `null`, then default options are used. |
| 2180 */ |
| 2181 SdkAnalysisContext(AnalysisOptions options) { |
| 2182 if (options != null) { |
| 2183 super.analysisOptions = options; |
| 2184 } |
| 2185 } |
| 2186 |
2176 @override | 2187 @override |
| 2188 void set analysisOptions(AnalysisOptions options) { |
| 2189 throw new StateError('AnalysisOptions of SDK context cannot be changed.'); |
| 2190 } |
| 2191 |
| 2192 @override |
2177 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 2193 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
2178 if (factory == null) { | 2194 if (factory == null) { |
2179 return super.createCacheFromSourceFactory(factory); | 2195 return super.createCacheFromSourceFactory(factory); |
2180 } | 2196 } |
2181 DartSdk sdk = factory.dartSdk; | 2197 DartSdk sdk = factory.dartSdk; |
2182 if (sdk == null) { | 2198 if (sdk == null) { |
2183 throw new IllegalArgumentException( | 2199 throw new IllegalArgumentException( |
2184 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2200 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
2185 } | 2201 } |
2186 return new AnalysisCache( | 2202 return new AnalysisCache( |
2187 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2203 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
2188 } | 2204 } |
2189 } | 2205 } |
OLD | NEW |