| 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/src/context/context.dart'; | 10 import 'package:analyzer/src/context/context.dart'; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 * should be used when it is available | 248 * should be used when it is available |
| 249 */ | 249 */ |
| 250 DirectoryBasedDartSdk(JavaFile sdkDirectory, [bool useDart2jsPaths = false]) { | 250 DirectoryBasedDartSdk(JavaFile sdkDirectory, [bool useDart2jsPaths = false]) { |
| 251 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); | 251 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); |
| 252 _libraryMap = initialLibraryMap(useDart2jsPaths); | 252 _libraryMap = initialLibraryMap(useDart2jsPaths); |
| 253 } | 253 } |
| 254 | 254 |
| 255 @override | 255 @override |
| 256 AnalysisContext get context { | 256 AnalysisContext get context { |
| 257 if (_analysisContext == null) { | 257 if (_analysisContext == null) { |
| 258 SdkBundle sdkBundle = _getSummarySdkBundle(); | 258 _analysisContext = new SdkAnalysisContext(); |
| 259 if (sdkBundle != null) { | |
| 260 _analysisContext = new SummarySdkAnalysisContext(sdkBundle); | |
| 261 } else { | |
| 262 _analysisContext = new SdkAnalysisContext(); | |
| 263 } | |
| 264 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); | 259 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); |
| 265 _analysisContext.sourceFactory = factory; | 260 _analysisContext.sourceFactory = factory; |
| 266 List<String> uris = this.uris; | 261 List<String> uris = this.uris; |
| 262 // Try to use summaries. |
| 263 SdkBundle sdkBundle = _getSummarySdkBundle(); |
| 264 if (sdkBundle != null) { |
| 265 _analysisContext.aboutToComputeResultHelper = |
| 266 new SdkSummaryResultProvider(_analysisContext, sdkBundle); |
| 267 } |
| 268 // Add sources. |
| 267 ChangeSet changeSet = new ChangeSet(); | 269 ChangeSet changeSet = new ChangeSet(); |
| 268 for (String uri in uris) { | 270 for (String uri in uris) { |
| 269 changeSet.addedSource(factory.forUri(uri)); | 271 changeSet.addedSource(factory.forUri(uri)); |
| 270 } | 272 } |
| 271 _analysisContext.applyChanges(changeSet); | 273 _analysisContext.applyChanges(changeSet); |
| 272 } | 274 } |
| 273 return _analysisContext; | 275 return _analysisContext; |
| 274 } | 276 } |
| 275 | 277 |
| 276 /** | 278 /** |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 SdkLibrariesReader_LibraryBuilder libraryBuilder = | 651 SdkLibrariesReader_LibraryBuilder libraryBuilder = |
| 650 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); | 652 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); |
| 651 // If any syntactic errors were found then don't try to visit the AST | 653 // If any syntactic errors were found then don't try to visit the AST |
| 652 // structure. | 654 // structure. |
| 653 if (!errorListener.errorReported) { | 655 if (!errorListener.errorReported) { |
| 654 unit.accept(libraryBuilder); | 656 unit.accept(libraryBuilder); |
| 655 } | 657 } |
| 656 return libraryBuilder.librariesMap; | 658 return libraryBuilder.librariesMap; |
| 657 } | 659 } |
| 658 } | 660 } |
| OLD | NEW |