OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 6 |
7 import 'package:analysis_server/protocol/protocol.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/protocol/protocol_constants.dart'; |
8 import 'package:analysis_server/protocol/protocol_generated.dart'; | 9 import 'package:analysis_server/protocol/protocol_generated.dart'; |
9 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
10 import 'package:analysis_server/src/constants.dart'; | |
11 import 'package:analysis_server/src/domain_server.dart'; | 11 import 'package:analysis_server/src/domain_server.dart'; |
12 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 12 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
13 import 'package:analyzer/file_system/file_system.dart'; | 13 import 'package:analyzer/file_system/file_system.dart'; |
14 import 'package:analyzer/file_system/memory_file_system.dart'; | 14 import 'package:analyzer/file_system/memory_file_system.dart'; |
15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
16 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
17 import 'package:analyzer/src/generated/sdk.dart'; | 17 import 'package:analyzer/src/generated/sdk.dart'; |
18 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 18 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
19 import 'package:plugin/manager.dart'; | 19 import 'package:plugin/manager.dart'; |
20 import 'package:plugin/plugin.dart'; | 20 import 'package:plugin/plugin.dart'; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 resourceProvider.newFolder('/pkg/lib'); | 129 resourceProvider.newFolder('/pkg/lib'); |
130 resourceProvider.newFile('/pkg/lib/test.dart', 'class C {}'); | 130 resourceProvider.newFile('/pkg/lib/test.dart', 'class C {}'); |
131 server.setAnalysisRoots('0', ['/pkg'], [], {}); | 131 server.setAnalysisRoots('0', ['/pkg'], [], {}); |
132 // Pump the event queue to make sure the server has finished any | 132 // Pump the event queue to make sure the server has finished any |
133 // analysis. | 133 // analysis. |
134 return pumpEventQueue().then((_) { | 134 return pumpEventQueue().then((_) { |
135 List<Notification> notifications = channel.notificationsReceived; | 135 List<Notification> notifications = channel.notificationsReceived; |
136 expect(notifications, isNotEmpty); | 136 expect(notifications, isNotEmpty); |
137 // expect at least one notification indicating analysis is in progress | 137 // expect at least one notification indicating analysis is in progress |
138 expect(notifications.any((Notification notification) { | 138 expect(notifications.any((Notification notification) { |
139 if (notification.event == SERVER_STATUS) { | 139 if (notification.event == SERVER_NOTIFICATION_STATUS) { |
140 var params = new ServerStatusParams.fromNotification(notification); | 140 var params = new ServerStatusParams.fromNotification(notification); |
141 if (params.analysis != null) { | 141 if (params.analysis != null) { |
142 return params.analysis.isAnalyzing; | 142 return params.analysis.isAnalyzing; |
143 } | 143 } |
144 } | 144 } |
145 return false; | 145 return false; |
146 }), isTrue); | 146 }), isTrue); |
147 // the last notification should indicate that analysis is complete | 147 // the last notification should indicate that analysis is complete |
148 Notification notification = notifications[notifications.length - 1]; | 148 Notification notification = notifications[notifications.length - 1]; |
149 var params = new ServerStatusParams.fromNotification(notification); | 149 var params = new ServerStatusParams.fromNotification(notification); |
(...skipping 11 matching lines...) Expand all Loading... |
161 exclude: | 161 exclude: |
162 - 'samples/**' | 162 - 'samples/**' |
163 '''); | 163 '''); |
164 server.setAnalysisRoots('0', ['/project'], [], {}); | 164 server.setAnalysisRoots('0', ['/project'], [], {}); |
165 server.setAnalysisSubscriptions(<AnalysisService, Set<String>>{ | 165 server.setAnalysisSubscriptions(<AnalysisService, Set<String>>{ |
166 AnalysisService.NAVIGATION: new Set<String>.from([path]) | 166 AnalysisService.NAVIGATION: new Set<String>.from([path]) |
167 }); | 167 }); |
168 // the file is excluded, so no navigation notification | 168 // the file is excluded, so no navigation notification |
169 await server.onAnalysisComplete; | 169 await server.onAnalysisComplete; |
170 expect(channel.notificationsReceived.any((notification) { | 170 expect(channel.notificationsReceived.any((notification) { |
171 return notification.event == ANALYSIS_NAVIGATION; | 171 return notification.event == ANALYSIS_NOTIFICATION_NAVIGATION; |
172 }), isFalse); | 172 }), isFalse); |
173 } | 173 } |
174 | 174 |
175 test_setAnalysisSubscriptions_fileInIgnoredFolder_oldOptions() async { | 175 test_setAnalysisSubscriptions_fileInIgnoredFolder_oldOptions() async { |
176 String path = '/project/samples/sample.dart'; | 176 String path = '/project/samples/sample.dart'; |
177 resourceProvider.newFile(path, ''); | 177 resourceProvider.newFile(path, ''); |
178 resourceProvider.newFile( | 178 resourceProvider.newFile( |
179 '/project/.analysis_options', | 179 '/project/.analysis_options', |
180 r''' | 180 r''' |
181 analyzer: | 181 analyzer: |
182 exclude: | 182 exclude: |
183 - 'samples/**' | 183 - 'samples/**' |
184 '''); | 184 '''); |
185 server.setAnalysisRoots('0', ['/project'], [], {}); | 185 server.setAnalysisRoots('0', ['/project'], [], {}); |
186 server.setAnalysisSubscriptions(<AnalysisService, Set<String>>{ | 186 server.setAnalysisSubscriptions(<AnalysisService, Set<String>>{ |
187 AnalysisService.NAVIGATION: new Set<String>.from([path]) | 187 AnalysisService.NAVIGATION: new Set<String>.from([path]) |
188 }); | 188 }); |
189 // the file is excluded, so no navigation notification | 189 // the file is excluded, so no navigation notification |
190 await server.onAnalysisComplete; | 190 await server.onAnalysisComplete; |
191 expect(channel.notificationsReceived.any((notification) { | 191 expect(channel.notificationsReceived.any((notification) { |
192 return notification.event == ANALYSIS_NAVIGATION; | 192 return notification.event == ANALYSIS_NOTIFICATION_NAVIGATION; |
193 }), isFalse); | 193 }), isFalse); |
194 } | 194 } |
195 | 195 |
196 Future test_shutdown() { | 196 Future test_shutdown() { |
197 server.handlers = [new ServerDomainHandler(server)]; | 197 server.handlers = [new ServerDomainHandler(server)]; |
198 var request = new Request('my28', SERVER_SHUTDOWN); | 198 var request = new Request('my28', SERVER_REQUEST_SHUTDOWN); |
199 return channel.sendRequest(request).then((Response response) { | 199 return channel.sendRequest(request).then((Response response) { |
200 expect(response.id, equals('my28')); | 200 expect(response.id, equals('my28')); |
201 expect(response.error, isNull); | 201 expect(response.error, isNull); |
202 }); | 202 }); |
203 } | 203 } |
204 | 204 |
205 Future test_unknownRequest() { | 205 Future test_unknownRequest() { |
206 server.handlers = [new EchoHandler()]; | 206 server.handlers = [new EchoHandler()]; |
207 var request = new Request('my22', 'randomRequest'); | 207 var request = new Request('my22', 'randomRequest'); |
208 return channel.sendRequest(request).then((Response response) { | 208 return channel.sendRequest(request).then((Response response) { |
209 expect(response.id, equals('my22')); | 209 expect(response.id, equals('my22')); |
210 expect(response.error, isNotNull); | 210 expect(response.error, isNotNull); |
211 }); | 211 }); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 class EchoHandler implements RequestHandler { | 215 class EchoHandler implements RequestHandler { |
216 @override | 216 @override |
217 Response handleRequest(Request request) { | 217 Response handleRequest(Request request) { |
218 if (request.method == 'echo') { | 218 if (request.method == 'echo') { |
219 return new Response(request.id, result: {'echo': true}); | 219 return new Response(request.id, result: {'echo': true}); |
220 } | 220 } |
221 return null; | 221 return null; |
222 } | 222 } |
223 } | 223 } |
OLD | NEW |