| 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 analyzer.src.generated.sdk_io; | 5 library analyzer.src.generated.sdk_io; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 _analysisOptions = options; | 275 _analysisOptions = options; |
| 276 } | 276 } |
| 277 | 277 |
| 278 @override | 278 @override |
| 279 AnalysisContext get context { | 279 AnalysisContext get context { |
| 280 if (_analysisContext == null) { | 280 if (_analysisContext == null) { |
| 281 _analysisContext = new SdkAnalysisContext(_analysisOptions); | 281 _analysisContext = new SdkAnalysisContext(_analysisOptions); |
| 282 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); | 282 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); |
| 283 _analysisContext.sourceFactory = factory; | 283 _analysisContext.sourceFactory = factory; |
| 284 if (_useSummary) { | 284 if (_useSummary) { |
| 285 PackageBundle sdkBundle = _getSummarySdkBundle(); | 285 PackageBundle sdkBundle = getSummarySdkBundle(); |
| 286 if (sdkBundle != null) { | 286 if (sdkBundle != null) { |
| 287 _analysisContext.resultProvider = | 287 _analysisContext.resultProvider = |
| 288 new SdkSummaryResultProvider(_analysisContext, sdkBundle); | 288 new SdkSummaryResultProvider(_analysisContext, sdkBundle); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 return _analysisContext; | 292 return _analysisContext; |
| 293 } | 293 } |
| 294 | 294 |
| 295 /** | 295 /** |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 Source source = _uriToSourceMap[dartUri]; | 563 Source source = _uriToSourceMap[dartUri]; |
| 564 if (source == null) { | 564 if (source == null) { |
| 565 source = _mapDartUri(dartUri); | 565 source = _mapDartUri(dartUri); |
| 566 _uriToSourceMap[dartUri] = source; | 566 _uriToSourceMap[dartUri] = source; |
| 567 } | 567 } |
| 568 return source; | 568 return source; |
| 569 } | 569 } |
| 570 | 570 |
| 571 /** | 571 /** |
| 572 * Return the [PackageBundle] for this SDK, if it exists, or `null` otherwise. | 572 * Return the [PackageBundle] for this SDK, if it exists, or `null` otherwise. |
| 573 * This method should not be used outside of `analyzer` and `analyzer_cli` |
| 574 * packages. |
| 573 */ | 575 */ |
| 574 PackageBundle _getSummarySdkBundle() { | 576 PackageBundle getSummarySdkBundle() { |
| 575 String rootPath = directory.getAbsolutePath(); | 577 String rootPath = directory.getAbsolutePath(); |
| 576 bool strongMode = _analysisOptions?.strongMode ?? false; | 578 bool strongMode = _analysisOptions?.strongMode ?? false; |
| 577 String name = strongMode ? 'strong.sum' : 'spec.sum'; | 579 String name = strongMode ? 'strong.sum' : 'spec.sum'; |
| 578 String path = pathos.join(rootPath, 'lib', '_internal', name); | 580 String path = pathos.join(rootPath, 'lib', '_internal', name); |
| 579 try { | 581 try { |
| 580 File file = new File(path); | 582 File file = new File(path); |
| 581 if (file.existsSync()) { | 583 if (file.existsSync()) { |
| 582 List<int> bytes = file.readAsBytesSync(); | 584 List<int> bytes = file.readAsBytesSync(); |
| 583 return new PackageBundle.fromBuffer(bytes); | 585 return new PackageBundle.fromBuffer(bytes); |
| 584 } | 586 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 SdkLibrariesReader_LibraryBuilder libraryBuilder = | 683 SdkLibrariesReader_LibraryBuilder libraryBuilder = |
| 682 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); | 684 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); |
| 683 // If any syntactic errors were found then don't try to visit the AST | 685 // If any syntactic errors were found then don't try to visit the AST |
| 684 // structure. | 686 // structure. |
| 685 if (!errorListener.errorReported) { | 687 if (!errorListener.errorReported) { |
| 686 unit.accept(libraryBuilder); | 688 unit.accept(libraryBuilder); |
| 687 } | 689 } |
| 688 return libraryBuilder.librariesMap; | 690 return libraryBuilder.librariesMap; |
| 689 } | 691 } |
| 690 } | 692 } |
| OLD | NEW |