OLD | NEW |
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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
8 | 8 |
9 import 'package:analyzer/context/context_root.dart'; | 9 import 'package:analyzer/context/context_root.dart'; |
10 import 'package:analyzer/context/declared_variables.dart'; | 10 import 'package:analyzer/context/declared_variables.dart'; |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 _createFileTracker(); | 532 _createFileTracker(); |
533 _fileTracker.addFiles(addedFiles); | 533 _fileTracker.addFiles(addedFiles); |
534 } | 534 } |
535 | 535 |
536 @override | 536 @override |
537 void dispose() { | 537 void dispose() { |
538 _scheduler.remove(this); | 538 _scheduler.remove(this); |
539 } | 539 } |
540 | 540 |
541 /** | 541 /** |
| 542 * Return the cached [AnalysisResult] for the Dart file with the given [path]. |
| 543 * If there is no cached result, return `null`. Usually only results of |
| 544 * priority files are cached. |
| 545 * |
| 546 * The [path] must be absolute and normalized. |
| 547 * |
| 548 * The [path] can be any file - explicitly or implicitly analyzed, or neither. |
| 549 */ |
| 550 AnalysisResult getCachedResult(String path) { |
| 551 AnalysisResult result = _priorityResults[path]; |
| 552 if (disableChangesAndCacheAllResults) { |
| 553 result ??= _allCachedResults[path]; |
| 554 } |
| 555 return result; |
| 556 } |
| 557 |
| 558 /** |
542 * Return a [Future] that completes with the [ErrorsResult] for the Dart | 559 * Return a [Future] that completes with the [ErrorsResult] for the Dart |
543 * file with the given [path]. If the file is not a Dart file or cannot | 560 * file with the given [path]. If the file is not a Dart file or cannot |
544 * be analyzed, the [Future] completes with `null`. | 561 * be analyzed, the [Future] completes with `null`. |
545 * | 562 * |
546 * The [path] must be absolute and normalized. | 563 * The [path] must be absolute and normalized. |
547 * | 564 * |
548 * This method does not use analysis priorities, and must not be used in | 565 * This method does not use analysis priorities, and must not be used in |
549 * interactive analysis, such as Analysis Server or its plugins. | 566 * interactive analysis, such as Analysis Server or its plugins. |
550 */ | 567 */ |
551 Future<ErrorsResult> getErrors(String path) async { | 568 Future<ErrorsResult> getErrors(String path) async { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 * of the files previously reported using [changeFile]), prior to the next | 676 * of the files previously reported using [changeFile]), prior to the next |
660 * time the analysis state transitions to "idle". | 677 * time the analysis state transitions to "idle". |
661 */ | 678 */ |
662 Future<AnalysisResult> getResult(String path) { | 679 Future<AnalysisResult> getResult(String path) { |
663 if (!_fsState.hasUri(path)) { | 680 if (!_fsState.hasUri(path)) { |
664 return new Future.value(); | 681 return new Future.value(); |
665 } | 682 } |
666 | 683 |
667 // Return the cached result. | 684 // Return the cached result. |
668 { | 685 { |
669 AnalysisResult result = _priorityResults[path]; | 686 AnalysisResult result = getCachedResult(path); |
670 if (disableChangesAndCacheAllResults) { | |
671 result ??= _allCachedResults[path]; | |
672 } | |
673 if (result != null) { | 687 if (result != null) { |
674 return new Future.value(result); | 688 return new Future.value(result); |
675 } | 689 } |
676 } | 690 } |
677 | 691 |
678 // Schedule analysis. | 692 // Schedule analysis. |
679 var completer = new Completer<AnalysisResult>(); | 693 var completer = new Completer<AnalysisResult>(); |
680 _requestedFiles | 694 _requestedFiles |
681 .putIfAbsent(path, () => <Completer<AnalysisResult>>[]) | 695 .putIfAbsent(path, () => <Completer<AnalysisResult>>[]) |
682 .add(completer); | 696 .add(completer); |
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 libraryDeclarations.add(new TopLevelDeclarationInSource( | 2063 libraryDeclarations.add(new TopLevelDeclarationInSource( |
2050 file.source, declaration, isExported)); | 2064 file.source, declaration, isExported)); |
2051 } | 2065 } |
2052 } | 2066 } |
2053 } | 2067 } |
2054 | 2068 |
2055 // We're not done yet. | 2069 // We're not done yet. |
2056 return false; | 2070 return false; |
2057 } | 2071 } |
2058 } | 2072 } |
OLD | NEW |