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.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/domain_completion.dart'; | 10 import 'package:analysis_server/src/domain_completion.dart'; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 test_ArgumentList_imported_function_named_param_label3() async { | 92 test_ArgumentList_imported_function_named_param_label3() async { |
93 addTestFile('main() { int.parse("16", ^: 16);}'); | 93 addTestFile('main() { int.parse("16", ^: 16);}'); |
94 await getSuggestions(); | 94 await getSuggestions(); |
95 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix: ', | 95 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'radix: ', |
96 relevance: DART_RELEVANCE_NAMED_PARAMETER); | 96 relevance: DART_RELEVANCE_NAMED_PARAMETER); |
97 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError: ', | 97 assertHasResult(CompletionSuggestionKind.NAMED_ARGUMENT, 'onError: ', |
98 relevance: DART_RELEVANCE_NAMED_PARAMETER); | 98 relevance: DART_RELEVANCE_NAMED_PARAMETER); |
99 expect(suggestions, hasLength(2)); | 99 expect(suggestions, hasLength(2)); |
100 } | 100 } |
101 | 101 |
| 102 test_catch() async { |
| 103 addTestFile('main() {try {} ^}'); |
| 104 await getSuggestions(); |
| 105 assertHasResult(CompletionSuggestionKind.KEYWORD, 'on', |
| 106 relevance: DART_RELEVANCE_KEYWORD); |
| 107 assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch', |
| 108 relevance: DART_RELEVANCE_KEYWORD); |
| 109 assertHasResult(CompletionSuggestionKind.KEYWORD, 'finally', |
| 110 relevance: DART_RELEVANCE_KEYWORD); |
| 111 expect(suggestions, hasLength(3)); |
| 112 } |
| 113 |
| 114 test_catch2() async { |
| 115 addTestFile('main() {try {} on Foo {} ^}'); |
| 116 await getSuggestions(); |
| 117 assertHasResult(CompletionSuggestionKind.KEYWORD, 'on', |
| 118 relevance: DART_RELEVANCE_KEYWORD); |
| 119 assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch', |
| 120 relevance: DART_RELEVANCE_KEYWORD); |
| 121 assertHasResult(CompletionSuggestionKind.KEYWORD, 'finally', |
| 122 relevance: DART_RELEVANCE_KEYWORD); |
| 123 assertHasResult(CompletionSuggestionKind.KEYWORD, 'for', |
| 124 relevance: DART_RELEVANCE_KEYWORD); |
| 125 suggestions.firstWhere( |
| 126 (CompletionSuggestion suggestion) => |
| 127 suggestion.kind != CompletionSuggestionKind.KEYWORD, orElse: () { |
| 128 fail('Expected suggestions other than keyword suggestions'); |
| 129 }); |
| 130 } |
| 131 |
| 132 test_catch3() async { |
| 133 addTestFile('main() {try {} catch (e) {} finally {} ^}'); |
| 134 await getSuggestions(); |
| 135 assertNoResult('on'); |
| 136 assertNoResult('catch'); |
| 137 assertNoResult('finally'); |
| 138 assertHasResult(CompletionSuggestionKind.KEYWORD, 'for', |
| 139 relevance: DART_RELEVANCE_KEYWORD); |
| 140 suggestions.firstWhere( |
| 141 (CompletionSuggestion suggestion) => |
| 142 suggestion.kind != CompletionSuggestionKind.KEYWORD, orElse: () { |
| 143 fail('Expected suggestions other than keyword suggestions'); |
| 144 }); |
| 145 } |
| 146 |
| 147 test_catch4() async { |
| 148 addTestFile('main() {try {} finally {} ^}'); |
| 149 await getSuggestions(); |
| 150 assertNoResult('on'); |
| 151 assertNoResult('catch'); |
| 152 assertNoResult('finally'); |
| 153 assertHasResult(CompletionSuggestionKind.KEYWORD, 'for', |
| 154 relevance: DART_RELEVANCE_KEYWORD); |
| 155 suggestions.firstWhere( |
| 156 (CompletionSuggestion suggestion) => |
| 157 suggestion.kind != CompletionSuggestionKind.KEYWORD, orElse: () { |
| 158 fail('Expected suggestions other than keyword suggestions'); |
| 159 }); |
| 160 } |
| 161 |
| 162 test_catch5() async { |
| 163 addTestFile('main() {try {} ^ finally {}}'); |
| 164 await getSuggestions(); |
| 165 assertHasResult(CompletionSuggestionKind.KEYWORD, 'on', |
| 166 relevance: DART_RELEVANCE_KEYWORD); |
| 167 assertHasResult(CompletionSuggestionKind.KEYWORD, 'catch', |
| 168 relevance: DART_RELEVANCE_KEYWORD); |
| 169 expect(suggestions, hasLength(2)); |
| 170 } |
| 171 |
102 test_html() { | 172 test_html() { |
103 testFile = '/project/web/test.html'; | 173 testFile = '/project/web/test.html'; |
104 addTestFile(''' | 174 addTestFile(''' |
105 <html>^</html> | 175 <html>^</html> |
106 '''); | 176 '''); |
107 return getSuggestions().then((_) { | 177 return getSuggestions().then((_) { |
108 expect(replacementOffset, equals(completionOffset)); | 178 expect(replacementOffset, equals(completionOffset)); |
109 expect(replacementLength, equals(0)); | 179 expect(replacementLength, equals(0)); |
110 expect(suggestions, hasLength(0)); | 180 expect(suggestions, hasLength(0)); |
111 }); | 181 }); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 } | 698 } |
629 '''); | 699 '''); |
630 await waitForTasksFinished(); | 700 await waitForTasksFinished(); |
631 Request request = | 701 Request request = |
632 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); | 702 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); |
633 Response response = handler.handleRequest(request); | 703 Response response = handler.handleRequest(request); |
634 expect(response.error, isNotNull); | 704 expect(response.error, isNotNull); |
635 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 705 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
636 } | 706 } |
637 } | 707 } |
OLD | NEW |