Chromium Code Reviews| Index: pkg/analyzer/lib/src/dart/analysis/driver.dart |
| diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| index d7dc7c6969bb9dc3e5fdfef010607af56780c7d3..208dba23f6e0ca610fd1a4c34f6d8108e992baf2 100644 |
| --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| @@ -203,7 +203,8 @@ class AnalysisDriver { |
| * Return the [Stream] that produces [AnalysisResult]s for added files. |
| * |
| * Analysis starts when the client starts listening to the stream, and stops |
| - * when the client cancels the subscription. |
| + * when the client cancels the subscription. Note that the stream supports |
| + * only one single subscriber. |
| * |
| * When the client starts listening, the analysis state transitions to |
| * "analyzing" and an analysis result is produced for every added file prior |
| @@ -309,8 +310,10 @@ class AnalysisDriver { |
| * The results of analysis are eventually produced by the [results] stream. |
| */ |
| void addFile(String path) { |
| - _explicitFiles.add(path); |
| - _filesToAnalyze.add(path); |
| + if (_isDartFile(path)) { |
| + _explicitFiles.add(path); |
| + _filesToAnalyze.add(path); |
| + } |
| _transitionToAnalyzing(); |
| _hasWork.notify(); |
| } |
| @@ -334,9 +337,11 @@ class AnalysisDriver { |
| * [changeFile] invocation. |
| */ |
| void changeFile(String path) { |
| - _changedFiles.add(path); |
| - if (_explicitFiles.contains(path)) { |
| - _filesToAnalyze.add(path); |
| + if (_isDartFile(path)) { |
| + _changedFiles.add(path); |
| + if (_explicitFiles.contains(path)) { |
| + _filesToAnalyze.add(path); |
| + } |
| } |
| _transitionToAnalyzing(); |
| _hasWork.notify(); |
| @@ -367,6 +372,20 @@ class AnalysisDriver { |
| } |
| /** |
| + * Returns a [Future] that completes after pumping the event queue [times] |
| + * times. By default, this should pump the event queue enough times to allow |
| + * any code to run, as long as it's not waiting on some external event. |
| + */ |
| + Future pumpEventQueue([int times = 5000]) { |
| + if (times == 0) return new Future.value(); |
| + // We use a delayed future to allow microtask events to finish. The |
| + // Future.value or Future() constructors use scheduleMicrotask themselves and |
| + // would therefore not wait for microtask callbacks that are scheduled after |
| + // invoking this method. |
| + return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); |
| + } |
| + |
| + /** |
| * Remove the file with the given [path] from the list of files to analyze. |
| * |
| * The [path] must be absolute and normalized. |
| @@ -702,6 +721,13 @@ class AnalysisDriver { |
| } |
| /** |
| + * Return `true` if the given [path] is a Dart file. |
| + */ |
| + static bool _isDartFile(String path) { |
|
Brian Wilkerson
2016/10/31 18:03:47
Can we use AnalysisEngine.isDartFileName?
What ab
scheglov
2016/10/31 18:14:01
Done.
|
| + return path.toLowerCase().endsWith('.dart'); |
| + } |
| + |
| + /** |
| * Remove and return the first item in the given [set]. |
| */ |
| static Object/*=T*/ _removeFirst/*<T>*/(LinkedHashSet<Object/*=T*/ > set) { |
| @@ -709,20 +735,6 @@ class AnalysisDriver { |
| set.remove(element); |
| return element; |
| } |
| - |
| - /** |
| - * Returns a [Future] that completes after pumping the event queue [times] |
| - * times. By default, this should pump the event queue enough times to allow |
| - * any code to run, as long as it's not waiting on some external event. |
| - */ |
| - Future pumpEventQueue([int times = 5000]) { |
| - if (times == 0) return new Future.value(); |
| - // We use a delayed future to allow microtask events to finish. The |
| - // Future.value or Future() constructors use scheduleMicrotask themselves and |
| - // would therefore not wait for microtask callbacks that are scheduled after |
| - // invoking this method. |
| - return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); |
| - } |
| } |
| /** |