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

Side by Side Diff: pkg/analyzer/lib/src/dart/sdk/sdk.dart

Issue 2242963002: Add DartSdk.getLinkedBundle() and use it in PubSummaryManager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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/source/embedder.dart ('k') | pkg/analyzer/lib/src/generated/sdk.dart » ('j') | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.generated.sdk2; 5 library analyzer.src.generated.sdk2;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 /** 55 /**
56 * The [AnalysisContext] which is used for all of the sources in this SDK. 56 * The [AnalysisContext] which is used for all of the sources in this SDK.
57 */ 57 */
58 InternalAnalysisContext _analysisContext; 58 InternalAnalysisContext _analysisContext;
59 59
60 /** 60 /**
61 * The mapping from Dart URI's to the corresponding sources. 61 * The mapping from Dart URI's to the corresponding sources.
62 */ 62 */
63 Map<String, Source> _uriToSourceMap = new HashMap<String, Source>(); 63 Map<String, Source> _uriToSourceMap = new HashMap<String, Source>();
64 64
65 PackageBundle _sdkBundle;
66
65 /** 67 /**
66 * Set the [options] for this SDK analysis context. Throw [StateError] if the 68 * Set the [options] for this SDK analysis context. Throw [StateError] if the
67 * context has been already created. 69 * context has been already created.
68 */ 70 */
69 void set analysisOptions(AnalysisOptions options) { 71 void set analysisOptions(AnalysisOptions options) {
70 if (_analysisContext != null) { 72 if (_analysisContext != null) {
71 throw new StateError( 73 throw new StateError(
72 'Analysis options cannot be changed after context creation.'); 74 'Analysis options cannot be changed after context creation.');
73 } 75 }
74 _analysisOptions = options; 76 _analysisOptions = options;
75 } 77 }
76 78
77 @override 79 @override
78 AnalysisContext get context { 80 AnalysisContext get context {
79 if (_analysisContext == null) { 81 if (_analysisContext == null) {
80 _analysisContext = new SdkAnalysisContext(_analysisOptions); 82 _analysisContext = new SdkAnalysisContext(_analysisOptions);
81 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); 83 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
82 _analysisContext.sourceFactory = factory; 84 _analysisContext.sourceFactory = factory;
83 if (_useSummary) { 85 if (_useSummary) {
84 bool strongMode = _analysisOptions?.strongMode ?? false; 86 bool strongMode = _analysisOptions?.strongMode ?? false;
85 PackageBundle sdkBundle = getSummarySdkBundle(strongMode); 87 PackageBundle sdkBundle = getLinkedBundle();
86 if (sdkBundle != null) { 88 if (sdkBundle != null) {
87 _analysisContext.resultProvider = new SdkSummaryResultProvider( 89 _analysisContext.resultProvider = new SdkSummaryResultProvider(
88 _analysisContext, sdkBundle, strongMode); 90 _analysisContext, sdkBundle, strongMode);
89 } 91 }
90 } 92 }
91 } 93 }
92 return _analysisContext; 94 return _analysisContext;
93 } 95 }
94 96
95 @override 97 @override
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 try { 146 try {
145 return file.createSource(parseUriWithException(path)); 147 return file.createSource(parseUriWithException(path));
146 } on URISyntaxException catch (exception, stackTrace) { 148 } on URISyntaxException catch (exception, stackTrace) {
147 AnalysisEngine.instance.logger.logInformation( 149 AnalysisEngine.instance.logger.logInformation(
148 "Failed to create URI: $path", 150 "Failed to create URI: $path",
149 new CaughtException(exception, stackTrace)); 151 new CaughtException(exception, stackTrace));
150 } 152 }
151 return null; 153 return null;
152 } 154 }
153 155
156 @override
157 PackageBundle getLinkedBundle() {
158 bool strongMode = _analysisOptions?.strongMode ?? false;
159 _sdkBundle ??= getSummarySdkBundle(strongMode);
160 return _sdkBundle;
161 }
162
154 String getRelativePathFromFile(File file); 163 String getRelativePathFromFile(File file);
155 164
156 @override 165 @override
157 SdkLibrary getSdkLibrary(String dartUri) => libraryMap.getLibrary(dartUri); 166 SdkLibrary getSdkLibrary(String dartUri) => libraryMap.getLibrary(dartUri);
158 167
159 /** 168 /**
160 * Return the [PackageBundle] for this SDK, if it exists, or `null` otherwise. 169 * Return the [PackageBundle] for this SDK, if it exists, or `null` otherwise.
161 * This method should not be used outside of `analyzer` and `analyzer_cli` 170 * This method should not be used outside of `analyzer` and `analyzer_cli`
162 * packages. 171 * packages.
163 */ 172 */
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 @override 274 @override
266 // TODO(danrubel) Determine SDK version 275 // TODO(danrubel) Determine SDK version
267 String get sdkVersion => '0'; 276 String get sdkVersion => '0';
268 277
269 /** 278 /**
270 * The url mappings for this SDK. 279 * The url mappings for this SDK.
271 */ 280 */
272 Map<String, String> get urlMappings => _urlMappings; 281 Map<String, String> get urlMappings => _urlMappings;
273 282
274 @override 283 @override
284 PackageBundle getLinkedBundle() => null;
285
286 @override
275 String getRelativePathFromFile(File file) => file.path; 287 String getRelativePathFromFile(File file) => file.path;
276 288
277 @override 289 @override
278 PackageBundle getSummarySdkBundle(bool strongMode) => null; 290 PackageBundle getSummarySdkBundle(bool strongMode) => null;
279 291
280 @override 292 @override
281 Source internalMapDartUri(String dartUri) { 293 Source internalMapDartUri(String dartUri) {
282 String libraryName; 294 String libraryName;
283 String relativePath; 295 String relativePath;
284 int index = dartUri.indexOf('/'); 296 int index = dartUri.indexOf('/');
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 SdkLibrariesReader_LibraryBuilder libraryBuilder = 722 SdkLibrariesReader_LibraryBuilder libraryBuilder =
711 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); 723 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths);
712 // If any syntactic errors were found then don't try to visit the AST 724 // If any syntactic errors were found then don't try to visit the AST
713 // structure. 725 // structure.
714 if (!errorListener.errorReported) { 726 if (!errorListener.errorReported) {
715 unit.accept(libraryBuilder); 727 unit.accept(libraryBuilder);
716 } 728 }
717 return libraryBuilder.librariesMap; 729 return libraryBuilder.librariesMap;
718 } 730 }
719 } 731 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/source/embedder.dart ('k') | pkg/analyzer/lib/src/generated/sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698