| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /** | 5 /** |
| 6 * An object used to collect partial results (of type [E]) where the partial | 6 * An object used to collect partial results (of type [E]) where the partial |
| 7 * results are contributed by plugins. | 7 * results are contributed by plugins. |
| 8 */ | 8 */ |
| 9 class ResultCollector<E> { | 9 class ResultCollector<E> { |
| 10 /** | 10 /** |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 void clearResultsFromPlugin(String pluginId) { | 42 void clearResultsFromPlugin(String pluginId) { |
| 43 for (Map<String, E> partialResults in resultMap.values) { | 43 for (Map<String, E> partialResults in resultMap.values) { |
| 44 partialResults.remove(pluginId); | 44 partialResults.remove(pluginId); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * Return an iterator producing the partial results that have been contributed | 49 * Return an iterator producing the partial results that have been contributed |
| 50 * for the given [filePath]. | 50 * for the given [filePath]. |
| 51 */ | 51 */ |
| 52 Iterable<E> getResults(String filePath) { | 52 List<E> getResults(String filePath) { |
| 53 Map<String, E> partialResultMap = resultMap[filePath]; | 53 Map<String, E> partialResultMap = resultMap[filePath]; |
| 54 if (partialResultMap == null) { | 54 if (partialResultMap == null) { |
| 55 return <E>[]; | 55 return <E>[]; |
| 56 } | 56 } |
| 57 List<E> values = partialResultMap.values.toList(); | 57 List<E> values = partialResultMap.values.toList(); |
| 58 // | 58 // |
| 59 // Ensure that the server's contributions are always first in the list. | 59 // Ensure that the server's contributions are always first in the list. |
| 60 // | 60 // |
| 61 E serverContributions = partialResultMap[serverId]; | 61 E serverContributions = partialResultMap[serverId]; |
| 62 if (serverContributions != null && values.remove(serverContributions)) { | 62 if (serverContributions != null && values.remove(serverContributions)) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * Stop collecting results contributed for the file with the given [filePath]. | 89 * Stop collecting results contributed for the file with the given [filePath]. |
| 90 * Until the collector is told to start collecting results for the file, any | 90 * Until the collector is told to start collecting results for the file, any |
| 91 * results that are contributed for the file are discarded. | 91 * results that are contributed for the file are discarded. |
| 92 */ | 92 */ |
| 93 void stopCollectingFor(String filePath) { | 93 void stopCollectingFor(String filePath) { |
| 94 resultMap.remove(filePath); | 94 resultMap.remove(filePath); |
| 95 } | 95 } |
| 96 } | 96 } |
| OLD | NEW |