| 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.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_server.dart'; |
| 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 8 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 9 import 'package:analysis_server/src/services/completion/local_computer.dart'; | 9 import 'package:analysis_server/src/services/completion/local_computer.dart'; |
| 10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 11 | 11 |
| 12 import '../../reflective_tests.dart'; | 12 import '../../reflective_tests.dart'; |
| 13 import 'completion_test_util.dart'; | 13 import 'completion_test_util.dart'; |
| 14 | 14 |
| 15 main() { | 15 main() { |
| 16 groupSep = ' | '; | 16 groupSep = ' | '; |
| 17 runReflectiveTests(LocalComputerTest); | 17 runReflectiveTests(LocalReferenceContributorTest); |
| 18 } | 18 } |
| 19 | 19 |
| 20 @reflectiveTest | 20 @reflectiveTest |
| 21 class LocalComputerTest extends AbstractSelectorSuggestionTest { | 21 class LocalReferenceContributorTest extends AbstractSelectorSuggestionTest { |
| 22 @override | 22 @override |
| 23 CompletionSuggestion assertSuggestLocalClass(String name, | 23 CompletionSuggestion assertSuggestLocalClass(String name, |
| 24 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 24 {CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 25 int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | 25 int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
| 26 return assertSuggestClass(name, | 26 return assertSuggestClass(name, |
| 27 kind: kind, relevance: relevance, isDeprecated: isDeprecated); | 27 kind: kind, relevance: relevance, isDeprecated: isDeprecated); |
| 28 } | 28 } |
| 29 | 29 |
| 30 @override | 30 @override |
| 31 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, | 31 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 CompletionSuggestion assertSuggestLocalTopLevelVar( | 87 CompletionSuggestion assertSuggestLocalTopLevelVar( |
| 88 String name, String returnType, | 88 String name, String returnType, |
| 89 {int relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE}) { | 89 {int relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE}) { |
| 90 return assertSuggestTopLevelVar(name, returnType, relevance); | 90 return assertSuggestTopLevelVar(name, returnType, relevance); |
| 91 } | 91 } |
| 92 | 92 |
| 93 @override | 93 @override |
| 94 CompletionSuggestion assertSuggestLocalVariable( | 94 CompletionSuggestion assertSuggestLocalVariable( |
| 95 String name, String returnType, | 95 String name, String returnType, |
| 96 {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { | 96 {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { |
| 97 // Local variables should only be suggested by LocalComputer | 97 // Local variables should only be suggested by LocalReferenceContributor |
| 98 CompletionSuggestion cs = assertSuggest(name, | 98 CompletionSuggestion cs = assertSuggest(name, |
| 99 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); | 99 csKind: CompletionSuggestionKind.INVOCATION, relevance: relevance); |
| 100 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 100 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 101 Element element = cs.element; | 101 Element element = cs.element; |
| 102 expect(element, isNotNull); | 102 expect(element, isNotNull); |
| 103 expect(element.kind, equals(ElementKind.LOCAL_VARIABLE)); | 103 expect(element.kind, equals(ElementKind.LOCAL_VARIABLE)); |
| 104 expect(element.name, equals(name)); | 104 expect(element.name, equals(name)); |
| 105 expect(element.parameters, isNull); | 105 expect(element.parameters, isNull); |
| 106 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | 106 expect(element.returnType, returnType != null ? returnType : 'dynamic'); |
| 107 assertHasNoParameterInfo(cs); | 107 assertHasNoParameterInfo(cs); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 138 void f() { | 138 void f() { |
| 139 ^ | 139 ^ |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 '''); | 142 '''); |
| 143 expect(computeFast(), isTrue); | 143 expect(computeFast(), isTrue); |
| 144 assertSuggestMethod('m', 'M2', 'void'); | 144 assertSuggestMethod('m', 'M2', 'void'); |
| 145 } | 145 } |
| 146 | 146 |
| 147 @override | 147 @override |
| 148 void setUpComputer() { | 148 void setUpContributor() { |
| 149 computer = new LocalComputer(); | 149 contributor = new LocalReferenceContributor(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 test_missing_params_function() { | 152 test_missing_params_function() { |
| 153 addTestSource('int f1{} main(){f^}'); | 153 addTestSource('int f1{} main(){f^}'); |
| 154 expect(computeFast(), isTrue); | 154 expect(computeFast(), isTrue); |
| 155 } | 155 } |
| 156 | 156 |
| 157 test_missing_params_method() { | 157 test_missing_params_method() { |
| 158 addTestSource('class C1{int f1{} main(){f^}}'); | 158 addTestSource('class C1{int f1{} main(){f^}}'); |
| 159 expect(computeFast(), isTrue); | 159 expect(computeFast(), isTrue); |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 expect(computeFast(), isTrue); | 764 expect(computeFast(), isTrue); |
| 765 assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD); | 765 assertSuggestMethod('m', 'B', null, relevance: DART_RELEVANCE_LOCAL_METHOD); |
| 766 } | 766 } |
| 767 | 767 |
| 768 test_shadowed_name() { | 768 test_shadowed_name() { |
| 769 addTestSource('var a; class A { var a; m() { ^ } }'); | 769 addTestSource('var a; class A { var a; m() { ^ } }'); |
| 770 expect(computeFast(), isTrue); | 770 expect(computeFast(), isTrue); |
| 771 assertSuggestLocalField('a', null); | 771 assertSuggestLocalField('a', null); |
| 772 } | 772 } |
| 773 } | 773 } |
| OLD | NEW |