| 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 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/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 } | 290 } |
| 291 '''); | 291 '''); |
| 292 return findElementReferences('mmm() {} // in B', false).then((_) { | 292 return findElementReferences('mmm() {} // in B', false).then((_) { |
| 293 expect(searchElement.kind, ElementKind.METHOD); | 293 expect(searchElement.kind, ElementKind.METHOD); |
| 294 assertHasResult(SearchResultKind.INVOCATION, 'mmm(10)'); | 294 assertHasResult(SearchResultKind.INVOCATION, 'mmm(10)'); |
| 295 assertHasResult(SearchResultKind.INVOCATION, 'mmm(20)'); | 295 assertHasResult(SearchResultKind.INVOCATION, 'mmm(20)'); |
| 296 assertHasResult(SearchResultKind.INVOCATION, 'mmm(30)'); | 296 assertHasResult(SearchResultKind.INVOCATION, 'mmm(30)'); |
| 297 }); | 297 }); |
| 298 } | 298 } |
| 299 | 299 |
| 300 test_label() { |
| 301 addTestFile(''' |
| 302 main() { |
| 303 myLabel: |
| 304 for (int i = 0; i < 10; i++) { |
| 305 if (i == 2) { |
| 306 continue myLabel; // continue |
| 307 } |
| 308 break myLabel; // break |
| 309 } |
| 310 } |
| 311 '''); |
| 312 return findElementReferences('myLabel; // break', false).then((_) { |
| 313 expect(searchElement.kind, ElementKind.LABEL); |
| 314 expect(results, hasLength(3)); |
| 315 assertHasResult(SearchResultKind.DECLARATION, 'myLabel:'); |
| 316 assertHasResult(SearchResultKind.REFERENCE, 'myLabel; // continue'); |
| 317 assertHasResult(SearchResultKind.REFERENCE, 'myLabel; // break'); |
| 318 }); |
| 319 } |
| 320 |
| 300 test_localVariable() { | 321 test_localVariable() { |
| 301 addTestFile(''' | 322 addTestFile(''' |
| 302 main() { | 323 main() { |
| 303 var vvv = 1; | 324 var vvv = 1; |
| 304 print(vvv); | 325 print(vvv); |
| 305 vvv += 3; | 326 vvv += 3; |
| 306 vvv = 2; | 327 vvv = 2; |
| 307 vvv(); | 328 vvv(); |
| 308 } | 329 } |
| 309 '''); | 330 '''); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 } | 695 } |
| 675 '''); | 696 '''); |
| 676 return findElementReferences('T> {', false).then((_) { | 697 return findElementReferences('T> {', false).then((_) { |
| 677 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); | 698 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); |
| 678 expect(results, hasLength(2)); | 699 expect(results, hasLength(2)); |
| 679 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); | 700 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); |
| 680 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); | 701 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); |
| 681 }); | 702 }); |
| 682 } | 703 } |
| 683 } | 704 } |
| OLD | NEW |