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

Side by Side Diff: pkg/analysis_server/test/analysis/get_navigation_test.dart

Issue 2908633002: Make server forward getNavigation requests to plugins (Closed)
Patch Set: Created 3 years, 6 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 | « pkg/analysis_server/lib/src/domain_analysis.dart ('k') | no next file » | 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) 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 'package:analysis_server/protocol/protocol.dart'; 5 import 'package:analysis_server/protocol/protocol.dart';
6 import 'package:analysis_server/protocol/protocol_generated.dart'; 6 import 'package:analysis_server/protocol/protocol_generated.dart';
7 import 'package:analysis_server/src/domain_analysis.dart'; 7 import 'package:analysis_server/src/domain_analysis.dart';
8 import 'package:analyzer/file_system/file_system.dart'; 8 import 'package:analyzer/file_system/file_system.dart';
9 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 9 import 'package:analyzer_plugin/protocol/protocol_common.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 26 matching lines...) Expand all
37 main() { 37 main() {
38 var test = 0; 38 var test = 0;
39 print(test); 39 print(test);
40 } 40 }
41 '''); 41 ''');
42 await _getNavigation(testFile, testCode.indexOf('test);'), 0); 42 await _getNavigation(testFile, testCode.indexOf('test);'), 0);
43 assertHasRegion('test);'); 43 assertHasRegion('test);');
44 assertHasTarget('test = 0'); 44 assertHasTarget('test = 0');
45 } 45 }
46 46
47 test_fileDoesNotExist() { 47 test_fileDoesNotExist() async {
48 String file = '$projectPath/doesNotExist.dart'; 48 String file = '$projectPath/doesNotExist.dart';
49 return _checkInvalid(file, -1, -1); 49 Request request = _createGetNavigationRequest(file, 0, 100);
50 Response response = await serverChannel.sendRequest(request);
51 expect(response.error, isNull);
52 expect(response.result['files'], isEmpty);
53 expect(response.result['targets'], isEmpty);
54 expect(response.result['regions'], isEmpty);
50 } 55 }
51 56
52 test_fileOutsideOfRoot() async { 57 test_fileOutsideOfRoot() async {
53 testFile = '/outside.dart'; 58 testFile = '/outside.dart';
54 addTestFile(''' 59 addTestFile('''
55 main() { 60 main() {
56 var test = 0; 61 var test = 0;
57 print(test); 62 print(test);
58 } 63 }
59 '''); 64 ''');
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 var test = 0; 226 var test = 0;
222 print(test); 227 print(test);
223 } 228 }
224 '''); 229 ''');
225 await waitForTasksFinished(); 230 await waitForTasksFinished();
226 await _getNavigation(testFile, testCode.indexOf('test);'), 0); 231 await _getNavigation(testFile, testCode.indexOf('test);'), 0);
227 assertHasRegion('test);'); 232 assertHasRegion('test);');
228 assertHasTarget('test = 0'); 233 assertHasTarget('test = 0');
229 } 234 }
230 235
231 _checkInvalid(String file, int offset, int length) async {
232 Request request = _createGetNavigationRequest(file, offset, length);
233 Response response = await serverChannel.sendRequest(request);
234 expect(response.error, isNotNull);
235 expect(response.error.code, RequestErrorCode.GET_NAVIGATION_INVALID_FILE);
236 }
237
238 Request _createGetNavigationRequest(String file, int offset, int length) { 236 Request _createGetNavigationRequest(String file, int offset, int length) {
239 return new AnalysisGetNavigationParams(file, offset, length) 237 return new AnalysisGetNavigationParams(file, offset, length)
240 .toRequest(requestId); 238 .toRequest(requestId);
241 } 239 }
242 240
243 _getNavigation(String file, int offset, int length) async { 241 _getNavigation(String file, int offset, int length) async {
244 Request request = _createGetNavigationRequest(file, offset, length); 242 Request request = _createGetNavigationRequest(file, offset, length);
245 Response response = await serverChannel.sendRequest(request); 243 Response response = await serverChannel.sendRequest(request);
246 AnalysisGetNavigationResult result = 244 AnalysisGetNavigationResult result =
247 new AnalysisGetNavigationResult.fromResponse(response); 245 new AnalysisGetNavigationResult.fromResponse(response);
248 targetFiles = result.files; 246 targetFiles = result.files;
249 targets = result.targets; 247 targets = result.targets;
250 regions = result.regions; 248 regions = result.regions;
251 } 249 }
252 } 250 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_analysis.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698