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

Side by Side Diff: pkg/analysis_server/test/domain_completion_test.dart

Issue 1533613004: extract InheritedReferenceContributor from imported reference contributor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: include new tests in suite Created 5 years 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.domain.completion; 5 library test.domain.completion;
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/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 test_inDartDoc_reference3() async { 597 test_inDartDoc_reference3() async {
598 addTestFile(''' 598 addTestFile('''
599 /// The [m^] 599 /// The [m^]
600 main(aaa, bbb) {} 600 main(aaa, bbb) {}
601 '''); 601 ''');
602 await getSuggestions(); 602 await getSuggestions();
603 assertHasResult(CompletionSuggestionKind.INVOCATION, 'main', 603 assertHasResult(CompletionSuggestionKind.INVOCATION, 'main',
604 relevance: DART_RELEVANCE_LOCAL_FUNCTION); 604 relevance: DART_RELEVANCE_LOCAL_FUNCTION);
605 } 605 }
606 606
607 test_inherited() {
608 addFile('/libA.dart', 'class A {m() {}}');
609 addTestFile('''
610 import '/libA.dart';
611 class B extends A {
612 x() {^}
613 }
614 ''');
615 return getSuggestions().then((_) {
616 expect(replacementOffset, equals(completionOffset));
617 expect(replacementLength, equals(0));
618 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm');
619 });
620 }
621
607 test_keyword() { 622 test_keyword() {
608 addTestFile('library A; cl^'); 623 addTestFile('library A; cl^');
609 return getSuggestions().then((_) { 624 return getSuggestions().then((_) {
610 expect(replacementOffset, equals(completionOffset - 2)); 625 expect(replacementOffset, equals(completionOffset - 2));
611 expect(replacementLength, equals(2)); 626 expect(replacementLength, equals(2));
612 assertHasResult(CompletionSuggestionKind.KEYWORD, 'export', 627 assertHasResult(CompletionSuggestionKind.KEYWORD, 'export',
613 relevance: DART_RELEVANCE_HIGH); 628 relevance: DART_RELEVANCE_HIGH);
614 assertHasResult(CompletionSuggestionKind.KEYWORD, 'class', 629 assertHasResult(CompletionSuggestionKind.KEYWORD, 'class',
615 relevance: DART_RELEVANCE_HIGH); 630 relevance: DART_RELEVANCE_HIGH);
616 }); 631 });
617 } 632 }
618 633
619 test_local_named_constructor() { 634 test_local_named_constructor() {
620 addTestFile('class A {A.c(); x() {new A.^}}'); 635 addTestFile('class A {A.c(); x() {new A.^}}');
621 return getSuggestions().then((_) { 636 return getSuggestions().then((_) {
622 expect(replacementOffset, equals(completionOffset)); 637 expect(replacementOffset, equals(completionOffset));
623 expect(replacementLength, equals(0)); 638 expect(replacementLength, equals(0));
624 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c'); 639 assertHasResult(CompletionSuggestionKind.INVOCATION, 'c');
625 assertNoResult('A'); 640 assertNoResult('A');
626 }); 641 });
627 } 642 }
628 643
644 test_local_override() {
645 addFile('/libA.dart', 'class A {m() {}}');
646 addTestFile('''
647 import '/libA.dart';
648 class B extends A {
649 m() {}
650 x() {^}
651 }
652 ''');
653 return getSuggestions().then((_) {
654 expect(replacementOffset, equals(completionOffset));
655 expect(replacementLength, equals(0));
656 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm');
657 });
658 }
659
629 test_locals() { 660 test_locals() {
630 addTestFile('class A {var a; x() {var b;^}} class DateTime { }'); 661 addTestFile('class A {var a; x() {var b;^}} class DateTime { }');
631 return getSuggestions().then((_) { 662 return getSuggestions().then((_) {
632 expect(replacementOffset, equals(completionOffset)); 663 expect(replacementOffset, equals(completionOffset));
633 expect(replacementLength, equals(0)); 664 expect(replacementLength, equals(0));
634 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A'); 665 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A');
635 assertHasResult(CompletionSuggestionKind.INVOCATION, 'a', 666 assertHasResult(CompletionSuggestionKind.INVOCATION, 'a',
636 relevance: DART_RELEVANCE_LOCAL_FIELD); 667 relevance: DART_RELEVANCE_LOCAL_FIELD);
637 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b', 668 assertHasResult(CompletionSuggestionKind.INVOCATION, 'b',
638 relevance: DART_RELEVANCE_LOCAL_VARIABLE); 669 relevance: DART_RELEVANCE_LOCAL_VARIABLE);
(...skipping 15 matching lines...) Expand all
654 685
655 test_overrides() { 686 test_overrides() {
656 addFile('/libA.dart', 'class A {m() {}}'); 687 addFile('/libA.dart', 'class A {m() {}}');
657 addTestFile(''' 688 addTestFile('''
658 import '/libA.dart'; 689 import '/libA.dart';
659 class B extends A {m() {^}} 690 class B extends A {m() {^}}
660 '''); 691 ''');
661 return getSuggestions().then((_) { 692 return getSuggestions().then((_) {
662 expect(replacementOffset, equals(completionOffset)); 693 expect(replacementOffset, equals(completionOffset));
663 expect(replacementLength, equals(0)); 694 expect(replacementLength, equals(0));
664 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm', 695 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm');
665 relevance: DART_RELEVANCE_LOCAL_METHOD);
666 }); 696 });
667 } 697 }
668 698
669 test_partFile() { 699 test_partFile() {
670 addFile( 700 addFile(
671 '/project/bin/testA.dart', 701 '/project/bin/testA.dart',
672 ''' 702 '''
673 library libA; 703 library libA;
674 part "$testFile"; 704 part "$testFile";
675 import 'dart:html'; 705 import 'dart:html';
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 } 979 }
950 '''); 980 ''');
951 await waitForTasksFinished(); 981 await waitForTasksFinished();
952 Request request = 982 Request request =
953 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); 983 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0');
954 Response response = handler.handleRequest(request); 984 Response response = handler.handleRequest(request);
955 expect(response.error, isNotNull); 985 expect(response.error, isNotNull);
956 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); 986 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED);
957 } 987 }
958 } 988 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698