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

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

Issue 640333002: Improve import prefix search results UI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/search/search_domain.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 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
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
319 test_label() { 300 test_label() {
320 addTestFile(''' 301 addTestFile('''
321 main() { 302 main() {
322 myLabel: 303 myLabel:
323 for (int i = 0; i < 10; i++) { 304 for (int i = 0; i < 10; i++) {
324 if (i == 2) { 305 if (i == 2) {
325 continue myLabel; // continue 306 continue myLabel; // continue
326 } 307 }
327 break myLabel; // break 308 break myLabel; // break
328 } 309 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 b.test(3); 609 b.test(3);
629 } 610 }
630 '''); 611 ''');
631 return findElementReferences('test(_) {} // of Derived', true).then((_) { 612 return findElementReferences('test(_) {} // of Derived', true).then((_) {
632 assertHasRef(SearchResultKind.INVOCATION, 'test(1);', true); 613 assertHasRef(SearchResultKind.INVOCATION, 'test(1);', true);
633 assertHasRef(SearchResultKind.INVOCATION, 'test(2);', false); 614 assertHasRef(SearchResultKind.INVOCATION, 'test(2);', false);
634 assertHasRef(SearchResultKind.INVOCATION, 'test(3);', true); 615 assertHasRef(SearchResultKind.INVOCATION, 'test(3);', true);
635 }); 616 });
636 } 617 }
637 618
619 test_prefix() {
620 addTestFile('''
621 import 'dart:async' as ppp;
622 main() {
623 ppp.Future a;
624 ppp.Stream b;
625 }
626 ''');
627 return findElementReferences("ppp;", false).then((_) {
628 expect(searchElement.kind, ElementKind.PREFIX);
629 expect(searchElement.name, 'ppp');
630 expect(searchElement.location.startLine, 1);
631 expect(results, hasLength(3));
632 assertHasResult(SearchResultKind.DECLARATION, 'ppp;');
633 assertHasResult(SearchResultKind.REFERENCE, 'ppp.Future');
634 assertHasResult(SearchResultKind.REFERENCE, 'ppp.Stream');
635 });
636 }
637
638 test_prefix_null() {
639 addTestFile('''
640 import 'dart:async';
641 main() {
642 Future a;
643 Stream b;
644 }
645 ''');
646 return findElementReferences("import ", false).then((_) {
647 expect(searchElement, isNull);
648 });
649 }
650
638 test_topLevelVariable_explicit() { 651 test_topLevelVariable_explicit() {
639 addTestFile(''' 652 addTestFile('''
640 var vvv = 1; 653 var vvv = 1;
641 main() { 654 main() {
642 print(vvv); 655 print(vvv);
643 vvv += 3; 656 vvv += 3;
644 vvv = 2; 657 vvv = 2;
645 vvv(); 658 vvv();
646 } 659 }
647 '''); 660 ''');
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 727 }
715 '''); 728 ''');
716 return findElementReferences('T> {', false).then((_) { 729 return findElementReferences('T> {', false).then((_) {
717 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); 730 expect(searchElement.kind, ElementKind.TYPE_PARAMETER);
718 expect(results, hasLength(2)); 731 expect(results, hasLength(2));
719 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); 732 assertHasResult(SearchResultKind.REFERENCE, 'T f;');
720 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); 733 assertHasResult(SearchResultKind.REFERENCE, 'T m()');
721 }); 734 });
722 } 735 }
723 } 736 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/search/search_domain.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698