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

Side by Side Diff: pkg/analyzer/lib/src/summary/summary_sdk.dart

Issue 1979183005: Pass the 'strongMode' flag into SdkSummaryResynthesizer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/src/context/cache.dart' show CacheEntry; 9 import 'package:analyzer/src/context/cache.dart' show CacheEntry;
10 import 'package:analyzer/src/context/context.dart'; 10 import 'package:analyzer/src/context/context.dart';
(...skipping 14 matching lines...) Expand all
25 show AnalysisTarget, ResultDescriptor, TargetedResult; 25 show AnalysisTarget, ResultDescriptor, TargetedResult;
26 26
27 class SdkSummaryResultProvider implements SummaryResultProvider { 27 class SdkSummaryResultProvider implements SummaryResultProvider {
28 final InternalAnalysisContext context; 28 final InternalAnalysisContext context;
29 final PackageBundle bundle; 29 final PackageBundle bundle;
30 final SummaryTypeProvider typeProvider = new SummaryTypeProvider(); 30 final SummaryTypeProvider typeProvider = new SummaryTypeProvider();
31 31
32 @override 32 @override
33 SummaryResynthesizer resynthesizer; 33 SummaryResynthesizer resynthesizer;
34 34
35 SdkSummaryResultProvider(this.context, this.bundle) { 35 SdkSummaryResultProvider(this.context, this.bundle, bool strongMode) {
36 resynthesizer = new SdkSummaryResynthesizer( 36 resynthesizer = new SdkSummaryResynthesizer(
37 context, typeProvider, context.sourceFactory, bundle); 37 context, typeProvider, context.sourceFactory, bundle, strongMode);
38 _buildCoreLibrary(); 38 _buildCoreLibrary();
39 _buildAsyncLibrary(); 39 _buildAsyncLibrary();
40 resynthesizer.finalizeCoreAsyncLibraries(); 40 resynthesizer.finalizeCoreAsyncLibraries();
41 context.typeProvider = typeProvider; 41 context.typeProvider = typeProvider;
42 } 42 }
43 43
44 @override 44 @override
45 bool compute(CacheEntry entry, ResultDescriptor result) { 45 bool compute(CacheEntry entry, ResultDescriptor result) {
46 if (result == TYPE_PROVIDER) { 46 if (result == TYPE_PROVIDER) {
47 entry.setValue(result, typeProvider, TargetedResult.EMPTY_LIST); 47 entry.setValue(result, typeProvider, TargetedResult.EMPTY_LIST);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 /** 157 /**
158 * The implementation of [SummaryResynthesizer] for Dart SDK. 158 * The implementation of [SummaryResynthesizer] for Dart SDK.
159 */ 159 */
160 class SdkSummaryResynthesizer extends SummaryResynthesizer { 160 class SdkSummaryResynthesizer extends SummaryResynthesizer {
161 final PackageBundle bundle; 161 final PackageBundle bundle;
162 final Map<String, UnlinkedUnit> unlinkedSummaries = <String, UnlinkedUnit>{}; 162 final Map<String, UnlinkedUnit> unlinkedSummaries = <String, UnlinkedUnit>{};
163 final Map<String, LinkedLibrary> linkedSummaries = <String, LinkedLibrary>{}; 163 final Map<String, LinkedLibrary> linkedSummaries = <String, LinkedLibrary>{};
164 164
165 SdkSummaryResynthesizer(AnalysisContext context, TypeProvider typeProvider, 165 SdkSummaryResynthesizer(AnalysisContext context, TypeProvider typeProvider,
166 SourceFactory sourceFactory, this.bundle) 166 SourceFactory sourceFactory, this.bundle, bool strongMode)
167 : super(null, context, typeProvider, sourceFactory, false) { 167 : super(null, context, typeProvider, sourceFactory, strongMode) {
168 // TODO(paulberry): we always resynthesize the summary in weak mode. Is
169 // this ok?
170 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) { 168 for (int i = 0; i < bundle.unlinkedUnitUris.length; i++) {
171 unlinkedSummaries[bundle.unlinkedUnitUris[i]] = bundle.unlinkedUnits[i]; 169 unlinkedSummaries[bundle.unlinkedUnitUris[i]] = bundle.unlinkedUnits[i];
172 } 170 }
173 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) { 171 for (int i = 0; i < bundle.linkedLibraryUris.length; i++) {
174 linkedSummaries[bundle.linkedLibraryUris[i]] = bundle.linkedLibraries[i]; 172 linkedSummaries[bundle.linkedLibraryUris[i]] = bundle.linkedLibraries[i];
175 } 173 }
176 } 174 }
177 175
178 @override 176 @override
179 LinkedLibrary getLinkedSummary(String uri) { 177 LinkedLibrary getLinkedSummary(String uri) {
(...skipping 11 matching lines...) Expand all
191 } 189 }
192 } 190 }
193 191
194 /** 192 /**
195 * An implementation of [DartSdk] which provides analysis results for `dart:` 193 * An implementation of [DartSdk] which provides analysis results for `dart:`
196 * libraries from the given summary file. This implementation is limited and 194 * libraries from the given summary file. This implementation is limited and
197 * suitable only for command-line tools, but not for IDEs - it does not 195 * suitable only for command-line tools, but not for IDEs - it does not
198 * implement [sdkLibraries], [sdkVersion], [uris] and [fromFileUri]. 196 * implement [sdkLibraries], [sdkVersion], [uris] and [fromFileUri].
199 */ 197 */
200 class SummaryBasedDartSdk implements DartSdk { 198 class SummaryBasedDartSdk implements DartSdk {
199 final bool strongMode;
201 SummaryDataStore _dataStore; 200 SummaryDataStore _dataStore;
202 InSummaryPackageUriResolver _uriResolver; 201 InSummaryPackageUriResolver _uriResolver;
203 PackageBundle _bundle; 202 PackageBundle _bundle;
204 203
205 /** 204 /**
206 * The [AnalysisContext] which is used for all of the sources in this sdk. 205 * The [AnalysisContext] which is used for all of the sources in this sdk.
207 */ 206 */
208 InternalAnalysisContext _analysisContext; 207 InternalAnalysisContext _analysisContext;
209 208
210 SummaryBasedDartSdk(String summaryPath) { 209 SummaryBasedDartSdk(String summaryPath, this.strongMode) {
211 _dataStore = new SummaryDataStore(<String>[summaryPath]); 210 _dataStore = new SummaryDataStore(<String>[summaryPath]);
212 _uriResolver = new InSummaryPackageUriResolver(_dataStore); 211 _uriResolver = new InSummaryPackageUriResolver(_dataStore);
213 _bundle = _dataStore.bundles.single; 212 _bundle = _dataStore.bundles.single;
214 } 213 }
215 214
216 /** 215 /**
217 * Return the [PackageBundle] for this SDK, not `null`. 216 * Return the [PackageBundle] for this SDK, not `null`.
218 */ 217 */
219 PackageBundle get bundle => _bundle; 218 PackageBundle get bundle => _bundle;
220 219
221 @override 220 @override
222 AnalysisContext get context { 221 AnalysisContext get context {
223 if (_analysisContext == null) { 222 if (_analysisContext == null) {
224 _analysisContext = new SdkAnalysisContext(null); 223 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl()
224 ..strongMode = strongMode;
225 _analysisContext = new SdkAnalysisContext(analysisOptions);
225 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); 226 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
226 _analysisContext.sourceFactory = factory; 227 _analysisContext.sourceFactory = factory;
227 _analysisContext.resultProvider = 228 _analysisContext.resultProvider =
228 new SdkSummaryResultProvider(_analysisContext, _bundle); 229 new SdkSummaryResultProvider(_analysisContext, _bundle, strongMode);
229 } 230 }
230 return _analysisContext; 231 return _analysisContext;
231 } 232 }
232 233
233 @override 234 @override
234 List<SdkLibrary> get sdkLibraries { 235 List<SdkLibrary> get sdkLibraries {
235 throw new UnimplementedError(); 236 throw new UnimplementedError();
236 } 237 }
237 238
238 @override 239 @override
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 * throw a [StateError] if there is no class with the given name. 503 * throw a [StateError] if there is no class with the given name.
503 */ 504 */
504 InterfaceType _getType(LibraryElement library, String name) { 505 InterfaceType _getType(LibraryElement library, String name) {
505 Element element = library.getType(name); 506 Element element = library.getType(name);
506 if (element == null) { 507 if (element == null) {
507 throw new StateError("No definition of type $name"); 508 throw new StateError("No definition of type $name");
508 } 509 }
509 return (element as ClassElement).type; 510 return (element as ClassElement).type;
510 } 511 }
511 } 512 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk_io.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698