| 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_prefix() { |
| 301 addTestFile(''' |
| 302 import 'dart:async' as ppp; |
| 303 main() { |
| 304 ppp.Future a; |
| 305 ppp.Stream b; |
| 306 } |
| 307 '''); |
| 308 return findElementReferences("ppp;", false).then((_) { |
| 309 expect(searchElement.kind, ElementKind.PREFIX); |
| 310 expect(searchElement.name, 'ppp'); |
| 311 expect(searchElement.location.startLine, 1); |
| 312 expect(results, hasLength(3)); |
| 313 assertHasResult(SearchResultKind.DECLARATION, 'ppp;'); |
| 314 assertHasResult(SearchResultKind.REFERENCE, 'ppp.Future'); |
| 315 assertHasResult(SearchResultKind.REFERENCE, 'ppp.Stream'); |
| 316 }); |
| 317 } |
| 318 |
| 300 test_label() { | 319 test_label() { |
| 301 addTestFile(''' | 320 addTestFile(''' |
| 302 main() { | 321 main() { |
| 303 myLabel: | 322 myLabel: |
| 304 for (int i = 0; i < 10; i++) { | 323 for (int i = 0; i < 10; i++) { |
| 305 if (i == 2) { | 324 if (i == 2) { |
| 306 continue myLabel; // continue | 325 continue myLabel; // continue |
| 307 } | 326 } |
| 308 break myLabel; // break | 327 break myLabel; // break |
| 309 } | 328 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 } | 714 } |
| 696 '''); | 715 '''); |
| 697 return findElementReferences('T> {', false).then((_) { | 716 return findElementReferences('T> {', false).then((_) { |
| 698 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); | 717 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); |
| 699 expect(results, hasLength(2)); | 718 expect(results, hasLength(2)); |
| 700 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); | 719 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); |
| 701 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); | 720 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); |
| 702 }); | 721 }); |
| 703 } | 722 } |
| 704 } | 723 } |
| OLD | NEW |