| 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 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 /** | 662 /** |
| 663 * Return a [Future] that completes with a [AnalysisResult] for the Dart | 663 * Return a [Future] that completes with a [AnalysisResult] for the Dart |
| 664 * file with the given [path]. If the file is not a Dart file or cannot | 664 * file with the given [path]. If the file is not a Dart file or cannot |
| 665 * be analyzed, the [Future] completes with `null`. | 665 * be analyzed, the [Future] completes with `null`. |
| 666 * | 666 * |
| 667 * The [path] must be absolute and normalized. | 667 * The [path] must be absolute and normalized. |
| 668 * | 668 * |
| 669 * The [path] can be any file - explicitly or implicitly analyzed, or neither. | 669 * The [path] can be any file - explicitly or implicitly analyzed, or neither. |
| 670 * | 670 * |
| 671 * If the driver has the cached analysis result for the file, it is returned. | 671 * If the driver has the cached analysis result for the file, it is returned. |
| 672 * If [sendCachedToStream] is `true`, then the result is also reported into |
| 673 * the [results] stream, just as if it were freshly computed. |
| 672 * | 674 * |
| 673 * Otherwise causes the analysis state to transition to "analyzing" (if it is | 675 * Otherwise causes the analysis state to transition to "analyzing" (if it is |
| 674 * not in that state already), the driver will produce the analysis result for | 676 * not in that state already), the driver will produce the analysis result for |
| 675 * it, which is consistent with the current file state (including new states | 677 * it, which is consistent with the current file state (including new states |
| 676 * of the files previously reported using [changeFile]), prior to the next | 678 * of the files previously reported using [changeFile]), prior to the next |
| 677 * time the analysis state transitions to "idle". | 679 * time the analysis state transitions to "idle". |
| 678 */ | 680 */ |
| 679 Future<AnalysisResult> getResult(String path) { | 681 Future<AnalysisResult> getResult(String path, |
| 682 {bool sendCachedToStream: false}) { |
| 680 if (!_fsState.hasUri(path)) { | 683 if (!_fsState.hasUri(path)) { |
| 681 return new Future.value(); | 684 return new Future.value(); |
| 682 } | 685 } |
| 683 | 686 |
| 684 // Return the cached result. | 687 // Return the cached result. |
| 685 { | 688 { |
| 686 AnalysisResult result = getCachedResult(path); | 689 AnalysisResult result = getCachedResult(path); |
| 687 if (result != null) { | 690 if (result != null) { |
| 691 if (sendCachedToStream) { |
| 692 _resultController.add(result); |
| 693 } |
| 688 return new Future.value(result); | 694 return new Future.value(result); |
| 689 } | 695 } |
| 690 } | 696 } |
| 691 | 697 |
| 692 // Schedule analysis. | 698 // Schedule analysis. |
| 693 var completer = new Completer<AnalysisResult>(); | 699 var completer = new Completer<AnalysisResult>(); |
| 694 _requestedFiles | 700 _requestedFiles |
| 695 .putIfAbsent(path, () => <Completer<AnalysisResult>>[]) | 701 .putIfAbsent(path, () => <Completer<AnalysisResult>>[]) |
| 696 .add(completer); | 702 .add(completer); |
| 697 _scheduler.notify(this); | 703 _scheduler.notify(this); |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2063 libraryDeclarations.add(new TopLevelDeclarationInSource( | 2069 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 2064 file.source, declaration, isExported)); | 2070 file.source, declaration, isExported)); |
| 2065 } | 2071 } |
| 2066 } | 2072 } |
| 2067 } | 2073 } |
| 2068 | 2074 |
| 2069 // We're not done yet. | 2075 // We're not done yet. |
| 2070 return false; | 2076 return false; |
| 2071 } | 2077 } |
| 2072 } | 2078 } |
| OLD | NEW |