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

Side by Side Diff: pkg/analysis_server/test/search/element_references_test.dart

Issue 2176173004: Issue 26926. Don't search hierarchy for static class members. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
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 library test.search.element_references; 5 library test.search.element_references;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/services/index/index.dart'; 10 import 'package:analysis_server/src/services/index/index.dart';
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 assertHasResult(SearchResultKind.DECLARATION, 'fff; // in B'); 261 assertHasResult(SearchResultKind.DECLARATION, 'fff; // in B');
262 assertHasResult(SearchResultKind.DECLARATION, 'fff; // in C'); 262 assertHasResult(SearchResultKind.DECLARATION, 'fff; // in C');
263 assertHasResult(SearchResultKind.WRITE, 'fff = 10;'); 263 assertHasResult(SearchResultKind.WRITE, 'fff = 10;');
264 assertHasResult(SearchResultKind.WRITE, 'fff = 20;'); 264 assertHasResult(SearchResultKind.WRITE, 'fff = 20;');
265 assertHasResult(SearchResultKind.WRITE, 'fff = 30;'); 265 assertHasResult(SearchResultKind.WRITE, 'fff = 30;');
266 } 266 }
267 267
268 test_hierarchy_method() async { 268 test_hierarchy_method() async {
269 addTestFile(''' 269 addTestFile('''
270 class A { 270 class A {
271 mmm() {} // in A 271 mmm(_) {} // in A
272 } 272 }
273 class B extends A { 273 class B extends A {
274 mmm() {} // in B 274 mmm(_) {} // in B
275 } 275 }
276 class C extends B { 276 class C extends B {
277 mmm() {} // in C 277 mmm(_) {} // in C
278 } 278 }
279 main(A a, B b, C c) { 279 main(A a, B b, C c) {
280 a.mmm(10); 280 a.mmm(10);
281 b.mmm(20); 281 b.mmm(20);
282 c.mmm(30); 282 c.mmm(30);
283 } 283 }
284 '''); 284 ''');
285 await findElementReferences('mmm() {} // in B', false); 285 await findElementReferences('mmm(_) {} // in B', false);
286 expect(searchElement.kind, ElementKind.METHOD); 286 expect(searchElement.kind, ElementKind.METHOD);
287 assertHasResult(SearchResultKind.INVOCATION, 'mmm(10)'); 287 assertHasResult(SearchResultKind.INVOCATION, 'mmm(10)');
288 assertHasResult(SearchResultKind.INVOCATION, 'mmm(20)'); 288 assertHasResult(SearchResultKind.INVOCATION, 'mmm(20)');
289 assertHasResult(SearchResultKind.INVOCATION, 'mmm(30)'); 289 assertHasResult(SearchResultKind.INVOCATION, 'mmm(30)');
290 } 290 }
291 291
292 test_hierarchy_method_static() async {
293 addTestFile('''
294 class A {
295 static void mmm(_) {} // in A
296 }
297 class B extends A {
298 static void mmm(_) {} // in B
299 }
300 class C extends B {
301 static void mmm(_) {} // in C
302 }
303 main() {
304 A.mmm(10);
305 B.mmm(20);
306 C.mmm(30);
307 }
308 ''');
309 await findElementReferences('mmm(_) {} // in B', false);
310 expect(searchElement.kind, ElementKind.METHOD);
311 expect(results, hasLength(1));
312 assertHasResult(SearchResultKind.INVOCATION, 'mmm(20)');
313 }
314
292 test_label() async { 315 test_label() async {
293 addTestFile(''' 316 addTestFile('''
294 main() { 317 main() {
295 myLabel: 318 myLabel:
296 for (int i = 0; i < 10; i++) { 319 for (int i = 0; i < 10; i++) {
297 if (i == 2) { 320 if (i == 2) {
298 continue myLabel; // continue 321 continue myLabel; // continue
299 } 322 }
300 break myLabel; // break 323 break myLabel; // break
301 } 324 }
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 print(vvv); 730 print(vvv);
708 } 731 }
709 '''); 732 ''');
710 Request request = new SearchFindElementReferencesParams(testFile, 0, false) 733 Request request = new SearchFindElementReferencesParams(testFile, 0, false)
711 .toRequest('0'); 734 .toRequest('0');
712 Response response = await waitResponse(request); 735 Response response = await waitResponse(request);
713 expect(response.error, isNotNull); 736 expect(response.error, isNotNull);
714 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); 737 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED);
715 } 738 }
716 } 739 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698