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/instrumentation/instrumentation.dart'; | 10 import 'package:analyzer/instrumentation/instrumentation.dart'; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 @override | 368 @override |
369 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); | 369 List<Source> get librarySources => _getSources(SourceKind.LIBRARY); |
370 | 370 |
371 @override | 371 @override |
372 Stream<SourcesChangedEvent> get onSourcesChanged => | 372 Stream<SourcesChangedEvent> get onSourcesChanged => |
373 _onSourcesChangedController.stream; | 373 _onSourcesChangedController.stream; |
374 | 374 |
375 /** | 375 /** |
376 * Make _pendingFutureSources available to unit tests. | 376 * Make _pendingFutureSources available to unit tests. |
377 */ | 377 */ |
378 HashMap<AnalysisTarget, | 378 HashMap<AnalysisTarget, List<PendingFuture>> |
379 List<PendingFuture>> get pendingFutureSources_forTesting => | 379 get pendingFutureSources_forTesting => _pendingFutureTargets; |
380 _pendingFutureTargets; | |
381 | 380 |
382 @override | 381 @override |
383 List<Source> get prioritySources => _priorityOrder; | 382 List<Source> get prioritySources => _priorityOrder; |
384 | 383 |
385 @override | 384 @override |
386 List<AnalysisTarget> get priorityTargets => prioritySources; | 385 List<AnalysisTarget> get priorityTargets => prioritySources; |
387 | 386 |
388 @override | 387 @override |
389 CachePartition get privateAnalysisCachePartition => _privatePartition; | 388 CachePartition get privateAnalysisCachePartition => _privatePartition; |
390 | 389 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 @override | 611 @override |
613 LineInfo computeLineInfo(Source source) => computeResult(source, LINE_INFO); | 612 LineInfo computeLineInfo(Source source) => computeResult(source, LINE_INFO); |
614 | 613 |
615 @override | 614 @override |
616 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( | 615 CancelableFuture<CompilationUnit> computeResolvedCompilationUnitAsync( |
617 Source unitSource, Source librarySource) { | 616 Source unitSource, Source librarySource) { |
618 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || | 617 if (!AnalysisEngine.isDartFileName(unitSource.shortName) || |
619 !AnalysisEngine.isDartFileName(librarySource.shortName)) { | 618 !AnalysisEngine.isDartFileName(librarySource.shortName)) { |
620 return new CancelableFuture.error(new AnalysisNotScheduledError()); | 619 return new CancelableFuture.error(new AnalysisNotScheduledError()); |
621 } | 620 } |
622 return new AnalysisFutureHelper<CompilationUnit>( | 621 return new AnalysisFutureHelper<CompilationUnit>(this, |
623 this, | 622 new LibrarySpecificUnit(librarySource, unitSource), RESOLVED_UNIT) |
624 new LibrarySpecificUnit(librarySource, unitSource), | 623 .computeAsync(); |
625 RESOLVED_UNIT).computeAsync(); | |
626 } | 624 } |
627 | 625 |
628 @override | 626 @override |
629 Object /*V*/ computeResult( | 627 Object /*=V*/ computeResult /*<V>*/ ( |
630 AnalysisTarget target, ResultDescriptor /*<V>*/ descriptor) { | 628 AnalysisTarget target, ResultDescriptor /*<V>*/ descriptor) { |
631 // Make sure we are not trying to invoke the task model in a reentrant | 629 // Make sure we are not trying to invoke the task model in a reentrant |
632 // fashion. | 630 // fashion. |
633 assert(!driver.isTaskRunning); | 631 assert(!driver.isTaskRunning); |
634 CacheEntry entry = getCacheEntry(target); | 632 CacheEntry entry = getCacheEntry(target); |
635 CacheState state = entry.getState(descriptor); | 633 CacheState state = entry.getState(descriptor); |
636 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { | 634 if (state == CacheState.FLUSHED || state == CacheState.INVALID) { |
637 driver.computeResult(target, descriptor); | 635 driver.computeResult(target, descriptor); |
638 } | 636 } |
639 state = entry.getState(descriptor); | 637 state = entry.getState(descriptor); |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 } | 2016 } |
2019 DartSdk sdk = factory.dartSdk; | 2017 DartSdk sdk = factory.dartSdk; |
2020 if (sdk == null) { | 2018 if (sdk == null) { |
2021 throw new IllegalArgumentException( | 2019 throw new IllegalArgumentException( |
2022 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2020 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
2023 } | 2021 } |
2024 return new AnalysisCache( | 2022 return new AnalysisCache( |
2025 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2023 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
2026 } | 2024 } |
2027 } | 2025 } |
OLD | NEW |