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

Side by Side Diff: pkg/analysis_server/test/services/completion/local_reference_contributor_test.dart

Issue 1157113004: add enum suggestions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 6 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.services.completion.dart.local; 5 library test.services.completion.dart.local;
6 6
7 import 'package:analysis_server/src/protocol_server.dart'; 7 import 'package:analysis_server/src/protocol.dart' as protocol
8 show Element, ElementKind;
9 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind;
8 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 10 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
9 import 'package:analysis_server/src/services/completion/local_reference_contribu tor.dart'; 11 import 'package:analysis_server/src/services/completion/local_reference_contribu tor.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; 12 import 'package:test_reflective_loader/test_reflective_loader.dart';
11 import 'package:unittest/unittest.dart'; 13 import 'package:unittest/unittest.dart';
12 14
13 import 'completion_test_util.dart'; 15 import 'completion_test_util.dart';
14 16
15 main() { 17 main() {
16 groupSep = ' | '; 18 groupSep = ' | ';
17 defineReflectiveTests(LocalReferenceContributorTest); 19 defineReflectiveTests(LocalReferenceContributorTest);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 93 }
92 94
93 @override 95 @override
94 CompletionSuggestion assertSuggestLocalVariable( 96 CompletionSuggestion assertSuggestLocalVariable(
95 String name, String returnType, 97 String name, String returnType,
96 {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { 98 {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) {
97 // Local variables should only be suggested by LocalReferenceContributor 99 // Local variables should only be suggested by LocalReferenceContributor
98 CompletionSuggestion cs = assertSuggest(name, 100 CompletionSuggestion cs = assertSuggest(name,
99 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); 101 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance);
100 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 102 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
101 Element element = cs.element; 103 protocol.Element element = cs.element;
102 expect(element, isNotNull); 104 expect(element, isNotNull);
103 expect(element.kind, equals(ElementKind.LOCAL_VARIABLE)); 105 expect(element.kind, equals(protocol.ElementKind.LOCAL_VARIABLE));
104 expect(element.name, equals(name)); 106 expect(element.name, equals(name));
105 expect(element.parameters, isNull); 107 expect(element.parameters, isNull);
106 expect(element.returnType, returnType != null ? returnType : 'dynamic'); 108 expect(element.returnType, returnType != null ? returnType : 'dynamic');
107 assertHasNoParameterInfo(cs); 109 assertHasNoParameterInfo(cs);
108 return cs; 110 return cs;
109 } 111 }
110 112
111 CompletionSuggestion assertSuggestParameter(String name, String returnType, 113 CompletionSuggestion assertSuggestParameter(String name, String returnType,
112 {int relevance: DART_RELEVANCE_PARAMETER}) { 114 {int relevance: DART_RELEVANCE_PARAMETER}) {
113 CompletionSuggestion cs = assertSuggest(name, 115 CompletionSuggestion cs = assertSuggest(name,
114 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); 116 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance);
115 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 117 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
116 Element element = cs.element; 118 protocol.Element element = cs.element;
117 expect(element, isNotNull); 119 expect(element, isNotNull);
118 expect(element.kind, equals(ElementKind.PARAMETER)); 120 expect(element.kind, equals(protocol.ElementKind.PARAMETER));
119 expect(element.name, equals(name)); 121 expect(element.name, equals(name));
120 expect(element.parameters, isNull); 122 expect(element.parameters, isNull);
121 expect(element.returnType, 123 expect(element.returnType,
122 equals(returnType != null ? returnType : 'dynamic')); 124 equals(returnType != null ? returnType : 'dynamic'));
123 return cs; 125 return cs;
124 } 126 }
125 127
126 fail_mixin_ordering() { 128 fail_mixin_ordering() {
127 // TODO(paulberry): Duplicates aren't being removed, so we see both M1.m() 129 // TODO(paulberry): Duplicates aren't being removed, so we see both M1.m()
128 // and M2.m(). 130 // and M2.m().
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 break; 457 break;
456 foo: case 2: 458 foo: case 2:
457 continue ^; 459 continue ^;
458 case 3: 460 case 3:
459 break; 461 break;
460 '''); 462 ''');
461 expect(computeFast(), isTrue); 463 expect(computeFast(), isTrue);
462 assertSuggestLabel('foo'); 464 assertSuggestLabel('foo');
463 } 465 }
464 466
467 test_enum() {
468 addTestSource('enum E { one, two } main() {^}');
469 expect(computeFast(), isTrue);
470 assertSuggestEnum('E');
471 assertNotSuggested('one');
472 assertNotSuggested('two');
473 }
474
475 test_enum_deprecated() {
476 addTestSource('@deprecated enum E { one, two } main() {^}');
477 expect(computeFast(), isTrue);
478 assertSuggestEnum('E', isDeprecated: true);
479 assertNotSuggested('one');
480 assertNotSuggested('two');
481 }
482
465 test_function_parameters_mixed_required_and_named() { 483 test_function_parameters_mixed_required_and_named() {
466 addTestSource(''' 484 addTestSource('''
467 void m(x, {int y}) {} 485 void m(x, {int y}) {}
468 class B extends A { 486 class B extends A {
469 main() {^} 487 main() {^}
470 } 488 }
471 '''); 489 ''');
472 expect(computeFast(), isTrue); 490 expect(computeFast(), isTrue);
473 CompletionSuggestion suggestion = assertSuggestLocalFunction('m', 'void'); 491 CompletionSuggestion suggestion = assertSuggestLocalFunction('m', 'void');
474 expect(suggestion.parameterNames, hasLength(2)); 492 expect(suggestion.parameterNames, hasLength(2));
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 expect(computeFast(), isTrue); 782 expect(computeFast(), isTrue);
765 assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD); 783 assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD);
766 } 784 }
767 785
768 test_shadowed_name() { 786 test_shadowed_name() {
769 addTestSource('var a; class A { var a; m() { ^ } }'); 787 addTestSource('var a; class A { var a; m() { ^ } }');
770 expect(computeFast(), isTrue); 788 expect(computeFast(), isTrue);
771 assertSuggestLocalField('a', null); 789 assertSuggestLocalField('a', null);
772 } 790 }
773 } 791 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698