Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: pkg/analysis_server/lib/src/plugin/result_collector.dart

Issue 2689903002: Add conversion routines from the plugin API to the server API (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/plugin/result_converter.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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)) {
63 values.insert(0, serverContributions); 63 values.insert(0, serverContributions);
64 } 64 }
65 return values; 65 return values;
66 } 66 }
67 67
68 /** 68 /**
69 * Return `true` if this collector is collecting results associated with the
70 * given [filePath].
71 */
72 bool isCollectingFor(String filePath) => resultMap.containsKey(filePath);
73
74 /**
69 * Record the [partialResults] as having been contributed for the given 75 * Record the [partialResults] as having been contributed for the given
70 * [filePath] by the plugin with the given [pluginId]. 76 * [filePath] by the plugin with the given [pluginId].
71 */ 77 */
72 void putResults(String filePath, String pluginId, E partialResults) { 78 void putResults(String filePath, String pluginId, E partialResults) {
73 Map<String, E> fileResults = resultMap[filePath]; 79 Map<String, E> fileResults = resultMap[filePath];
74 if (fileResults != null) { 80 if (fileResults != null) {
75 fileResults[pluginId] = partialResults; 81 fileResults[pluginId] = partialResults;
76 } 82 }
77 } 83 }
78 84
79 /** 85 /**
80 * Start collecting results contributed for the file with the given 86 * Start collecting results contributed for the file with the given
81 * [filePath]. Unless the collector is told to collect results for a file, any 87 * [filePath]. Unless the collector is told to collect results for a file, any
82 * results that are contributed for that file are discarded. 88 * results that are contributed for that file are discarded.
83 */ 89 */
84 void startCollectingFor(String filePath) { 90 void startCollectingFor(String filePath) {
85 resultMap.putIfAbsent(filePath, () => <String, E>{}); 91 resultMap.putIfAbsent(filePath, () => <String, E>{});
86 } 92 }
87 93
88 /** 94 /**
89 * Stop collecting results contributed for the file with the given [filePath]. 95 * 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 96 * Until the collector is told to start collecting results for the file, any
91 * results that are contributed for the file are discarded. 97 * results that are contributed for the file are discarded.
92 */ 98 */
93 void stopCollectingFor(String filePath) { 99 void stopCollectingFor(String filePath) {
94 resultMap.remove(filePath); 100 resultMap.remove(filePath);
95 } 101 }
96 } 102 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/plugin/result_converter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698