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 import 'package:analysis_server/plugin/protocol/protocol.dart' as server; | 5 import 'package:analysis_server/plugin/protocol/protocol.dart' as server; |
6 import 'package:analysis_server/src/channel/channel.dart'; | 6 import 'package:analysis_server/src/channel/channel.dart'; |
7 import 'package:analysis_server/src/plugin/notification_manager.dart'; | 7 import 'package:analysis_server/src/plugin/notification_manager.dart'; |
8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
9 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin; | 9 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin; |
10 import 'package:analyzer_plugin/protocol/protocol_constants.dart' as plugin; | 10 import 'package:analyzer_plugin/protocol/protocol_constants.dart' as plugin; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 new plugin.AnalysisErrorsParams(fileA, [pluginError1, pluginError2]); | 47 new plugin.AnalysisErrorsParams(fileA, [pluginError1, pluginError2]); |
48 manager.handlePluginNotification('a', params.toNotification()); | 48 manager.handlePluginNotification('a', params.toNotification()); |
49 | 49 |
50 server.AnalysisError serverError1 = serverAnalysisError(0, 0, file: fileA); | 50 server.AnalysisError serverError1 = serverAnalysisError(0, 0, file: fileA); |
51 server.AnalysisError serverError2 = serverAnalysisError(3, 4, file: fileA); | 51 server.AnalysisError serverError2 = serverAnalysisError(3, 4, file: fileA); |
52 _verifyErrors(fileA, [serverError1, serverError2]); | 52 _verifyErrors(fileA, [serverError1, serverError2]); |
53 } | 53 } |
54 | 54 |
55 void test_handlePluginNotification_folding() { | 55 void test_handlePluginNotification_folding() { |
56 manager.setSubscriptions({ | 56 manager.setSubscriptions({ |
57 server.AnalysisService.FOLDING: [fileA, fileB] | 57 server.AnalysisService.FOLDING: new Set.from([fileA, fileB]) |
scheglov
2017/02/23 20:02:43
Or [fileA, fileB].toSet()
Brian Wilkerson
2017/02/23 20:07:48
Do you have a significant preference?
scheglov
2017/02/23 20:26:09
No.
It just feel a bit better to have a sequence o
| |
58 }); | 58 }); |
59 plugin.FoldingRegion pluginRegion1 = pluginFoldingRegion(10, 3); | 59 plugin.FoldingRegion pluginRegion1 = pluginFoldingRegion(10, 3); |
60 plugin.FoldingRegion pluginRegion2 = pluginFoldingRegion(20, 6); | 60 plugin.FoldingRegion pluginRegion2 = pluginFoldingRegion(20, 6); |
61 plugin.AnalysisFoldingParams params = | 61 plugin.AnalysisFoldingParams params = |
62 new plugin.AnalysisFoldingParams(fileA, [pluginRegion1, pluginRegion2]); | 62 new plugin.AnalysisFoldingParams(fileA, [pluginRegion1, pluginRegion2]); |
63 manager.handlePluginNotification('a', params.toNotification()); | 63 manager.handlePluginNotification('a', params.toNotification()); |
64 | 64 |
65 server.FoldingRegion serverRegion1 = serverFoldingRegion(10, 3); | 65 server.FoldingRegion serverRegion1 = serverFoldingRegion(10, 3); |
66 server.FoldingRegion serverRegion2 = serverFoldingRegion(20, 6); | 66 server.FoldingRegion serverRegion2 = serverFoldingRegion(20, 6); |
67 _verifyFoldingRegions(fileA, [serverRegion1, serverRegion2]); | 67 _verifyFoldingRegions(fileA, [serverRegion1, serverRegion2]); |
68 } | 68 } |
69 | 69 |
70 void test_handlePluginNotification_highlights() { | 70 void test_handlePluginNotification_highlights() { |
71 manager.setSubscriptions({ | 71 manager.setSubscriptions({ |
72 server.AnalysisService.HIGHLIGHTS: [fileA, fileB] | 72 server.AnalysisService.HIGHLIGHTS: new Set.from([fileA, fileB]) |
73 }); | 73 }); |
74 plugin.HighlightRegion pluginRegion1 = pluginHighlightRegion(10, 3); | 74 plugin.HighlightRegion pluginRegion1 = pluginHighlightRegion(10, 3); |
75 plugin.HighlightRegion pluginRegion2 = pluginHighlightRegion(20, 6); | 75 plugin.HighlightRegion pluginRegion2 = pluginHighlightRegion(20, 6); |
76 plugin.AnalysisHighlightsParams params = | 76 plugin.AnalysisHighlightsParams params = |
77 new plugin.AnalysisHighlightsParams( | 77 new plugin.AnalysisHighlightsParams( |
78 fileA, [pluginRegion1, pluginRegion2]); | 78 fileA, [pluginRegion1, pluginRegion2]); |
79 | 79 |
80 server.HighlightRegion serverRegion1 = serverHighlightRegion(10, 3); | 80 server.HighlightRegion serverRegion1 = serverHighlightRegion(10, 3); |
81 server.HighlightRegion serverRegion2 = serverHighlightRegion(20, 6); | 81 server.HighlightRegion serverRegion2 = serverHighlightRegion(20, 6); |
82 manager.handlePluginNotification('a', params.toNotification()); | 82 manager.handlePluginNotification('a', params.toNotification()); |
83 _verifyHighlightRegions(fileA, [serverRegion1, serverRegion2]); | 83 _verifyHighlightRegions(fileA, [serverRegion1, serverRegion2]); |
84 } | 84 } |
85 | 85 |
86 void test_handlePluginNotification_naviation() { | 86 void test_handlePluginNotification_naviation() { |
87 manager.setSubscriptions({ | 87 manager.setSubscriptions({ |
88 server.AnalysisService.NAVIGATION: [fileA, fileB] | 88 server.AnalysisService.NAVIGATION: new Set.from([fileA, fileB]) |
89 }); | 89 }); |
90 plugin.AnalysisNavigationParams pluginParams = | 90 plugin.AnalysisNavigationParams pluginParams = |
91 pluginNavigationParams(0, 0, file: fileA); | 91 pluginNavigationParams(0, 0, file: fileA); |
92 manager.handlePluginNotification('a', pluginParams.toNotification()); | 92 manager.handlePluginNotification('a', pluginParams.toNotification()); |
93 | 93 |
94 server.AnalysisNavigationParams serverParams = | 94 server.AnalysisNavigationParams serverParams = |
95 serverNavigationParams(0, 0, file: fileA); | 95 serverNavigationParams(0, 0, file: fileA); |
96 _verifyNavigationParams(serverParams); | 96 _verifyNavigationParams(serverParams); |
97 } | 97 } |
98 | 98 |
99 void test_handlePluginNotification_occurences() { | 99 void test_handlePluginNotification_occurences() { |
100 manager.setSubscriptions({ | 100 manager.setSubscriptions({ |
101 server.AnalysisService.OCCURRENCES: [fileA, fileB] | 101 server.AnalysisService.OCCURRENCES: new Set.from([fileA, fileB]) |
102 }); | 102 }); |
103 plugin.Occurrences pluginOccurrences1 = pluginOccurrences(0, 0); | 103 plugin.Occurrences pluginOccurrences1 = pluginOccurrences(0, 0); |
104 plugin.Occurrences pluginOccurrences2 = pluginOccurrences(5, 7); | 104 plugin.Occurrences pluginOccurrences2 = pluginOccurrences(5, 7); |
105 plugin.AnalysisOccurrencesParams params = | 105 plugin.AnalysisOccurrencesParams params = |
106 new plugin.AnalysisOccurrencesParams( | 106 new plugin.AnalysisOccurrencesParams( |
107 fileA, [pluginOccurrences1, pluginOccurrences2]); | 107 fileA, [pluginOccurrences1, pluginOccurrences2]); |
108 | 108 |
109 server.Occurrences serverOccurrences1 = serverOccurrences(0, 0); | 109 server.Occurrences serverOccurrences1 = serverOccurrences(0, 0); |
110 server.Occurrences serverOccurrences2 = serverOccurrences(5, 7); | 110 server.Occurrences serverOccurrences2 = serverOccurrences(5, 7); |
111 manager.handlePluginNotification('a', params.toNotification()); | 111 manager.handlePluginNotification('a', params.toNotification()); |
112 _verifyOccurrences(fileA, [serverOccurrences1, serverOccurrences2]); | 112 _verifyOccurrences(fileA, [serverOccurrences1, serverOccurrences2]); |
113 } | 113 } |
114 | 114 |
115 void test_handlePluginNotification_outline() { | 115 void test_handlePluginNotification_outline() { |
116 manager.setSubscriptions({ | 116 manager.setSubscriptions({ |
117 server.AnalysisService.OUTLINE: [fileA, fileB] | 117 server.AnalysisService.OUTLINE: new Set.from([fileA, fileB]) |
118 }); | 118 }); |
119 plugin.Outline pluginOutline1 = pluginOutline(0, 0); | 119 plugin.Outline pluginOutline1 = pluginOutline(0, 0); |
120 plugin.AnalysisOutlineParams params = | 120 plugin.AnalysisOutlineParams params = |
121 new plugin.AnalysisOutlineParams(fileA, [pluginOutline1]); | 121 new plugin.AnalysisOutlineParams(fileA, [pluginOutline1]); |
122 manager.handlePluginNotification('a', params.toNotification()); | 122 manager.handlePluginNotification('a', params.toNotification()); |
123 | 123 |
124 server.Outline serverOutline1 = serverOutline(0, 0); | 124 server.Outline serverOutline1 = serverOutline(0, 0); |
125 _verifyOutlines(fileA, serverOutline1); | 125 _verifyOutlines(fileA, serverOutline1); |
126 } | 126 } |
127 | 127 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 } | 163 } |
164 | 164 |
165 void test_recordFoldingRegions_noSubscription() { | 165 void test_recordFoldingRegions_noSubscription() { |
166 server.FoldingRegion region = serverFoldingRegion(10, 5); | 166 server.FoldingRegion region = serverFoldingRegion(10, 5); |
167 manager.recordFoldingRegions('a', fileA, [region]); | 167 manager.recordFoldingRegions('a', fileA, [region]); |
168 expect(channel.sentNotification, isNull); | 168 expect(channel.sentNotification, isNull); |
169 } | 169 } |
170 | 170 |
171 void test_recordFoldingRegions_withSubscription() { | 171 void test_recordFoldingRegions_withSubscription() { |
172 manager.setSubscriptions({ | 172 manager.setSubscriptions({ |
173 server.AnalysisService.FOLDING: [fileA, fileB] | 173 server.AnalysisService.FOLDING: new Set.from([fileA, fileB]) |
174 }); | 174 }); |
175 // | 175 // |
176 // Regions should be reported when they are recorded. | 176 // Regions should be reported when they are recorded. |
177 // | 177 // |
178 server.FoldingRegion region1 = serverFoldingRegion(10, 3); | 178 server.FoldingRegion region1 = serverFoldingRegion(10, 3); |
179 server.FoldingRegion region2 = serverFoldingRegion(20, 6); | 179 server.FoldingRegion region2 = serverFoldingRegion(20, 6); |
180 manager.recordFoldingRegions('a', fileA, [region1, region2]); | 180 manager.recordFoldingRegions('a', fileA, [region1, region2]); |
181 _verifyFoldingRegions(fileA, [region1, region2]); | 181 _verifyFoldingRegions(fileA, [region1, region2]); |
182 // | 182 // |
183 // Regions from different plugins should be cumulative. | 183 // Regions from different plugins should be cumulative. |
(...skipping 18 matching lines...) Expand all Loading... | |
202 } | 202 } |
203 | 203 |
204 void test_recordHighlightRegions_noSubscription() { | 204 void test_recordHighlightRegions_noSubscription() { |
205 server.HighlightRegion region = serverHighlightRegion(10, 5); | 205 server.HighlightRegion region = serverHighlightRegion(10, 5); |
206 manager.recordHighlightRegions('a', fileA, [region]); | 206 manager.recordHighlightRegions('a', fileA, [region]); |
207 expect(channel.sentNotification, isNull); | 207 expect(channel.sentNotification, isNull); |
208 } | 208 } |
209 | 209 |
210 void test_recordHighlightRegions_withSubscription() { | 210 void test_recordHighlightRegions_withSubscription() { |
211 manager.setSubscriptions({ | 211 manager.setSubscriptions({ |
212 server.AnalysisService.HIGHLIGHTS: [fileA, fileB] | 212 server.AnalysisService.HIGHLIGHTS: new Set.from([fileA, fileB]) |
213 }); | 213 }); |
214 // | 214 // |
215 // Regions should be reported when they are recorded. | 215 // Regions should be reported when they are recorded. |
216 // | 216 // |
217 server.HighlightRegion region1 = serverHighlightRegion(10, 3); | 217 server.HighlightRegion region1 = serverHighlightRegion(10, 3); |
218 server.HighlightRegion region2 = serverHighlightRegion(20, 6); | 218 server.HighlightRegion region2 = serverHighlightRegion(20, 6); |
219 manager.recordHighlightRegions('a', fileA, [region1, region2]); | 219 manager.recordHighlightRegions('a', fileA, [region1, region2]); |
220 _verifyHighlightRegions(fileA, [region1, region2]); | 220 _verifyHighlightRegions(fileA, [region1, region2]); |
221 // | 221 // |
222 // Regions from different plugins should be cumulative. | 222 // Regions from different plugins should be cumulative. |
(...skipping 19 matching lines...) Expand all Loading... | |
242 | 242 |
243 void test_recordNavigationParams_noSubscription() { | 243 void test_recordNavigationParams_noSubscription() { |
244 server.AnalysisNavigationParams params = | 244 server.AnalysisNavigationParams params = |
245 serverNavigationParams(0, 0, file: fileA); | 245 serverNavigationParams(0, 0, file: fileA); |
246 manager.recordNavigationParams('a', fileA, params); | 246 manager.recordNavigationParams('a', fileA, params); |
247 expect(channel.sentNotification, isNull); | 247 expect(channel.sentNotification, isNull); |
248 } | 248 } |
249 | 249 |
250 void test_recordNavigationParams_withSubscription() { | 250 void test_recordNavigationParams_withSubscription() { |
251 manager.setSubscriptions({ | 251 manager.setSubscriptions({ |
252 server.AnalysisService.NAVIGATION: [fileA, fileB] | 252 server.AnalysisService.NAVIGATION: new Set.from([fileA, fileB]) |
253 }); | 253 }); |
254 // | 254 // |
255 // Parameters should be reported when they are recorded. | 255 // Parameters should be reported when they are recorded. |
256 // | 256 // |
257 server.AnalysisNavigationParams params1 = | 257 server.AnalysisNavigationParams params1 = |
258 serverNavigationParams(0, 0, file: fileA); | 258 serverNavigationParams(0, 0, file: fileA); |
259 manager.recordNavigationParams('a', fileA, params1); | 259 manager.recordNavigationParams('a', fileA, params1); |
260 _verifyNavigationParams(params1); | 260 _verifyNavigationParams(params1); |
261 // | 261 // |
262 // Parameters from different plugins should be cumulative. | 262 // Parameters from different plugins should be cumulative. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 } | 310 } |
311 | 311 |
312 void test_recordOccurrences_noSubscription() { | 312 void test_recordOccurrences_noSubscription() { |
313 server.Occurrences occurrences = serverOccurrences(0, 0); | 313 server.Occurrences occurrences = serverOccurrences(0, 0); |
314 manager.recordOccurrences('a', fileA, [occurrences]); | 314 manager.recordOccurrences('a', fileA, [occurrences]); |
315 expect(channel.sentNotification, isNull); | 315 expect(channel.sentNotification, isNull); |
316 } | 316 } |
317 | 317 |
318 void test_recordOccurrences_withSubscription() { | 318 void test_recordOccurrences_withSubscription() { |
319 manager.setSubscriptions({ | 319 manager.setSubscriptions({ |
320 server.AnalysisService.OCCURRENCES: [fileA, fileB] | 320 server.AnalysisService.OCCURRENCES: new Set.from([fileA, fileB]) |
321 }); | 321 }); |
322 // | 322 // |
323 // Occurrences should be reported when they are recorded. | 323 // Occurrences should be reported when they are recorded. |
324 // | 324 // |
325 server.Occurrences occurrences1 = serverOccurrences(0, 0); | 325 server.Occurrences occurrences1 = serverOccurrences(0, 0); |
326 server.Occurrences occurrences2 = serverOccurrences(5, 7); | 326 server.Occurrences occurrences2 = serverOccurrences(5, 7); |
327 manager.recordOccurrences('a', fileA, [occurrences1, occurrences2]); | 327 manager.recordOccurrences('a', fileA, [occurrences1, occurrences2]); |
328 _verifyOccurrences(fileA, [occurrences1, occurrences2]); | 328 _verifyOccurrences(fileA, [occurrences1, occurrences2]); |
329 // | 329 // |
330 // Occurrences from different plugins should be cumulative. | 330 // Occurrences from different plugins should be cumulative. |
(...skipping 22 matching lines...) Expand all Loading... | |
353 manager.recordOutlines('a', fileA, [outline]); | 353 manager.recordOutlines('a', fileA, [outline]); |
354 expect(channel.sentNotification, isNull); | 354 expect(channel.sentNotification, isNull); |
355 } | 355 } |
356 | 356 |
357 @failingTest | 357 @failingTest |
358 void test_recordOutlines_withSubscription() { | 358 void test_recordOutlines_withSubscription() { |
359 fail('The outline handling needs to be re-worked slightly'); | 359 fail('The outline handling needs to be re-worked slightly'); |
360 // TODO(brianwilkerson) Figure out outlines. What should we do when merge | 360 // TODO(brianwilkerson) Figure out outlines. What should we do when merge |
361 // cannot produce a single outline? | 361 // cannot produce a single outline? |
362 manager.setSubscriptions({ | 362 manager.setSubscriptions({ |
363 server.AnalysisService.OUTLINE: [fileA, fileB] | 363 server.AnalysisService.OUTLINE: new Set.from([fileA, fileB]) |
364 }); | 364 }); |
365 // | 365 // |
366 // Outlines should be reported when they are recorded. | 366 // Outlines should be reported when they are recorded. |
367 // | 367 // |
368 server.Outline outline1 = serverOutline(0, 0); | 368 server.Outline outline1 = serverOutline(0, 0); |
369 server.Outline outline2 = serverOutline(5, 7); | 369 server.Outline outline2 = serverOutline(5, 7); |
370 manager.recordOutlines('a', fileA, [outline1, outline2]); | 370 manager.recordOutlines('a', fileA, [outline1, outline2]); |
371 // TODO(brianwilkerson) Figure out how to test this. | 371 // TODO(brianwilkerson) Figure out how to test this. |
372 // _verifyOutlines(fileA, [outline1, outline2]); | 372 // _verifyOutlines(fileA, [outline1, outline2]); |
373 // | 373 // |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 @override | 491 @override |
492 void sendNotification(server.Notification notification) { | 492 void sendNotification(server.Notification notification) { |
493 sentNotification = notification; | 493 sentNotification = notification; |
494 } | 494 } |
495 | 495 |
496 @override | 496 @override |
497 void sendResponse(server.Response response) { | 497 void sendResponse(server.Response response) { |
498 fail('Unexpected invocation of sendResponse'); | 498 fail('Unexpected invocation of sendResponse'); |
499 } | 499 } |
500 } | 500 } |
OLD | NEW |