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

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

Issue 904603004: rename completion constants and cleanup comment (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
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.keyword; 5 library test.services.completion.dart.keyword;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.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/keyword_computer.dart'; 9 import 'package:analysis_server/src/services/completion/keyword_computer.dart';
10 import 'package:analyzer/src/generated/scanner.dart'; 10 import 'package:analyzer/src/generated/scanner.dart';
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 addTestSource('class A {} ^'); 69 addTestSource('class A {} ^');
70 expect(computeFast(), isTrue); 70 expect(computeFast(), isTrue);
71 assertSuggestKeywords( 71 assertSuggestKeywords(
72 [ 72 [
73 Keyword.ABSTRACT, 73 Keyword.ABSTRACT,
74 Keyword.CLASS, 74 Keyword.CLASS,
75 Keyword.CONST, 75 Keyword.CONST,
76 Keyword.FINAL, 76 Keyword.FINAL,
77 Keyword.TYPEDEF, 77 Keyword.TYPEDEF,
78 Keyword.VAR], 78 Keyword.VAR],
79 COMPLETION_RELEVANCE_HIGH); 79 DART_RELEVANCE_HIGH);
80 } 80 }
81 81
82 test_after_class2() { 82 test_after_class2() {
83 addTestSource('class A {} c^'); 83 addTestSource('class A {} c^');
84 expect(computeFast(), isTrue); 84 expect(computeFast(), isTrue);
85 assertSuggestKeywords( 85 assertSuggestKeywords(
86 [ 86 [
87 Keyword.ABSTRACT, 87 Keyword.ABSTRACT,
88 Keyword.CLASS, 88 Keyword.CLASS,
89 Keyword.CONST, 89 Keyword.CONST,
90 Keyword.FINAL, 90 Keyword.FINAL,
91 Keyword.TYPEDEF, 91 Keyword.TYPEDEF,
92 Keyword.VAR], 92 Keyword.VAR],
93 COMPLETION_RELEVANCE_HIGH); 93 DART_RELEVANCE_HIGH);
94 } 94 }
95 95
96 test_after_import() { 96 test_after_import() {
97 addTestSource('import foo; ^'); 97 addTestSource('import foo; ^');
98 expect(computeFast(), isTrue); 98 expect(computeFast(), isTrue);
99 assertSuggestKeywords( 99 assertSuggestKeywords(
100 [ 100 [
101 Keyword.ABSTRACT, 101 Keyword.ABSTRACT,
102 Keyword.CLASS, 102 Keyword.CLASS,
103 Keyword.CONST, 103 Keyword.CONST,
104 Keyword.EXPORT, 104 Keyword.EXPORT,
105 Keyword.FINAL, 105 Keyword.FINAL,
106 Keyword.IMPORT, 106 Keyword.IMPORT,
107 Keyword.PART, 107 Keyword.PART,
108 Keyword.TYPEDEF, 108 Keyword.TYPEDEF,
109 Keyword.VAR], 109 Keyword.VAR],
110 COMPLETION_RELEVANCE_HIGH); 110 DART_RELEVANCE_HIGH);
111 } 111 }
112 112
113 test_after_import2() { 113 test_after_import2() {
114 addTestSource('import foo; c^'); 114 addTestSource('import foo; c^');
115 expect(computeFast(), isTrue); 115 expect(computeFast(), isTrue);
116 assertSuggestKeywords( 116 assertSuggestKeywords(
117 [ 117 [
118 Keyword.ABSTRACT, 118 Keyword.ABSTRACT,
119 Keyword.CLASS, 119 Keyword.CLASS,
120 Keyword.CONST, 120 Keyword.CONST,
121 Keyword.EXPORT, 121 Keyword.EXPORT,
122 Keyword.FINAL, 122 Keyword.FINAL,
123 Keyword.IMPORT, 123 Keyword.IMPORT,
124 Keyword.PART, 124 Keyword.PART,
125 Keyword.TYPEDEF, 125 Keyword.TYPEDEF,
126 Keyword.VAR], 126 Keyword.VAR],
127 COMPLETION_RELEVANCE_HIGH); 127 DART_RELEVANCE_HIGH);
128 } 128 }
129 129
130 test_before_import() { 130 test_before_import() {
131 addTestSource('^ import foo;'); 131 addTestSource('^ import foo;');
132 expect(computeFast(), isTrue); 132 expect(computeFast(), isTrue);
133 assertSuggestKeywords( 133 assertSuggestKeywords(
134 [Keyword.EXPORT, Keyword.IMPORT, Keyword.LIBRARY, Keyword.PART], 134 [Keyword.EXPORT, Keyword.IMPORT, Keyword.LIBRARY, Keyword.PART],
135 COMPLETION_RELEVANCE_HIGH); 135 DART_RELEVANCE_HIGH);
136 } 136 }
137 137
138 test_class() { 138 test_class() {
139 addTestSource('class A ^'); 139 addTestSource('class A ^');
140 expect(computeFast(), isTrue); 140 expect(computeFast(), isTrue);
141 assertSuggestKeywords( 141 assertSuggestKeywords(
142 [Keyword.EXTENDS, Keyword.IMPLEMENTS], 142 [Keyword.EXTENDS, Keyword.IMPLEMENTS],
143 COMPLETION_RELEVANCE_HIGH); 143 DART_RELEVANCE_HIGH);
144 } 144 }
145 145
146 test_class2() { 146 test_class2() {
147 addTestSource('class A e^'); 147 addTestSource('class A e^');
148 expect(computeFast(), isTrue); 148 expect(computeFast(), isTrue);
149 assertSuggestKeywords( 149 assertSuggestKeywords(
150 [Keyword.EXTENDS, Keyword.IMPLEMENTS], 150 [Keyword.EXTENDS, Keyword.IMPLEMENTS],
151 COMPLETION_RELEVANCE_HIGH); 151 DART_RELEVANCE_HIGH);
152 } 152 }
153 153
154 test_class3() { 154 test_class3() {
155 addTestSource('class A e^ { }'); 155 addTestSource('class A e^ { }');
156 expect(computeFast(), isTrue); 156 expect(computeFast(), isTrue);
157 assertSuggestKeywords( 157 assertSuggestKeywords(
158 [Keyword.EXTENDS, Keyword.IMPLEMENTS], 158 [Keyword.EXTENDS, Keyword.IMPLEMENTS],
159 COMPLETION_RELEVANCE_HIGH); 159 DART_RELEVANCE_HIGH);
160 } 160 }
161 161
162 test_class_extends() { 162 test_class_extends() {
163 addTestSource('class A extends foo ^'); 163 addTestSource('class A extends foo ^');
164 expect(computeFast(), isTrue); 164 expect(computeFast(), isTrue);
165 assertSuggestKeywords( 165 assertSuggestKeywords(
166 [Keyword.IMPLEMENTS, Keyword.WITH], 166 [Keyword.IMPLEMENTS, Keyword.WITH],
167 COMPLETION_RELEVANCE_HIGH); 167 DART_RELEVANCE_HIGH);
168 } 168 }
169 169
170 test_class_extends2() { 170 test_class_extends2() {
171 addTestSource('class A extends foo i^'); 171 addTestSource('class A extends foo i^');
172 expect(computeFast(), isTrue); 172 expect(computeFast(), isTrue);
173 assertSuggestKeywords( 173 assertSuggestKeywords(
174 [Keyword.IMPLEMENTS, Keyword.WITH], 174 [Keyword.IMPLEMENTS, Keyword.WITH],
175 COMPLETION_RELEVANCE_HIGH); 175 DART_RELEVANCE_HIGH);
176 } 176 }
177 177
178 test_class_extends3() { 178 test_class_extends3() {
179 addTestSource('class A extends foo i^ { }'); 179 addTestSource('class A extends foo i^ { }');
180 expect(computeFast(), isTrue); 180 expect(computeFast(), isTrue);
181 assertSuggestKeywords( 181 assertSuggestKeywords(
182 [Keyword.IMPLEMENTS, Keyword.WITH], 182 [Keyword.IMPLEMENTS, Keyword.WITH],
183 COMPLETION_RELEVANCE_HIGH); 183 DART_RELEVANCE_HIGH);
184 } 184 }
185 185
186 test_class_extends_name() { 186 test_class_extends_name() {
187 addTestSource('class A extends ^'); 187 addTestSource('class A extends ^');
188 expect(computeFast(), isTrue); 188 expect(computeFast(), isTrue);
189 assertSuggestKeywords([]); 189 assertSuggestKeywords([]);
190 } 190 }
191 191
192 test_class_implements() { 192 test_class_implements() {
193 addTestSource('class A ^ implements foo'); 193 addTestSource('class A ^ implements foo');
194 expect(computeFast(), isTrue); 194 expect(computeFast(), isTrue);
195 assertSuggestKeywords([Keyword.EXTENDS], COMPLETION_RELEVANCE_HIGH); 195 assertSuggestKeywords([Keyword.EXTENDS], DART_RELEVANCE_HIGH);
196 } 196 }
197 197
198 test_class_implements2() { 198 test_class_implements2() {
199 addTestSource('class A e^ implements foo'); 199 addTestSource('class A e^ implements foo');
200 expect(computeFast(), isTrue); 200 expect(computeFast(), isTrue);
201 // TODO (danrubel) refinement: don't suggest implements 201 // TODO (danrubel) refinement: don't suggest implements
202 assertSuggestKeywords( 202 assertSuggestKeywords(
203 [Keyword.EXTENDS, Keyword.IMPLEMENTS], 203 [Keyword.EXTENDS, Keyword.IMPLEMENTS],
204 COMPLETION_RELEVANCE_HIGH); 204 DART_RELEVANCE_HIGH);
205 } 205 }
206 206
207 test_class_implements3() { 207 test_class_implements3() {
208 addTestSource('class A e^ implements foo { }'); 208 addTestSource('class A e^ implements foo { }');
209 expect(computeFast(), isTrue); 209 expect(computeFast(), isTrue);
210 // TODO (danrubel) refinement: don't suggest implements 210 // TODO (danrubel) refinement: don't suggest implements
211 assertSuggestKeywords( 211 assertSuggestKeywords(
212 [Keyword.EXTENDS, Keyword.IMPLEMENTS], 212 [Keyword.EXTENDS, Keyword.IMPLEMENTS],
213 COMPLETION_RELEVANCE_HIGH); 213 DART_RELEVANCE_HIGH);
214 } 214 }
215 215
216 test_class_implements_name() { 216 test_class_implements_name() {
217 addTestSource('class A implements ^'); 217 addTestSource('class A implements ^');
218 expect(computeFast(), isTrue); 218 expect(computeFast(), isTrue);
219 assertSuggestKeywords([]); 219 assertSuggestKeywords([]);
220 } 220 }
221 221
222 test_class_name() { 222 test_class_name() {
223 addTestSource('class ^'); 223 addTestSource('class ^');
224 expect(computeFast(), isTrue); 224 expect(computeFast(), isTrue);
225 assertSuggestKeywords([]); 225 assertSuggestKeywords([]);
226 } 226 }
227 227
228 test_class_with() { 228 test_class_with() {
229 addTestSource('class A extends foo with bar ^'); 229 addTestSource('class A extends foo with bar ^');
230 expect(computeFast(), isTrue); 230 expect(computeFast(), isTrue);
231 assertSuggestKeywords([Keyword.IMPLEMENTS], COMPLETION_RELEVANCE_HIGH); 231 assertSuggestKeywords([Keyword.IMPLEMENTS], DART_RELEVANCE_HIGH);
232 } 232 }
233 233
234 test_class_with2() { 234 test_class_with2() {
235 addTestSource('class A extends foo with bar i^'); 235 addTestSource('class A extends foo with bar i^');
236 expect(computeFast(), isTrue); 236 expect(computeFast(), isTrue);
237 assertSuggestKeywords([Keyword.IMPLEMENTS], COMPLETION_RELEVANCE_HIGH); 237 assertSuggestKeywords([Keyword.IMPLEMENTS], DART_RELEVANCE_HIGH);
238 } 238 }
239 239
240 test_class_with3() { 240 test_class_with3() {
241 addTestSource('class A extends foo with bar i^ { }'); 241 addTestSource('class A extends foo with bar i^ { }');
242 expect(computeFast(), isTrue); 242 expect(computeFast(), isTrue);
243 assertSuggestKeywords([Keyword.IMPLEMENTS], COMPLETION_RELEVANCE_HIGH); 243 assertSuggestKeywords([Keyword.IMPLEMENTS], DART_RELEVANCE_HIGH);
244 } 244 }
245 245
246 test_class_with_name() { 246 test_class_with_name() {
247 addTestSource('class A extends foo with ^'); 247 addTestSource('class A extends foo with ^');
248 expect(computeFast(), isTrue); 248 expect(computeFast(), isTrue);
249 assertSuggestKeywords([]); 249 assertSuggestKeywords([]);
250 } 250 }
251 251
252 test_empty() { 252 test_empty() {
253 addTestSource('^'); 253 addTestSource('^');
254 expect(computeFast(), isTrue); 254 expect(computeFast(), isTrue);
255 assertSuggestKeywords( 255 assertSuggestKeywords(
256 [ 256 [
257 Keyword.ABSTRACT, 257 Keyword.ABSTRACT,
258 Keyword.CLASS, 258 Keyword.CLASS,
259 Keyword.CONST, 259 Keyword.CONST,
260 Keyword.EXPORT, 260 Keyword.EXPORT,
261 Keyword.FINAL, 261 Keyword.FINAL,
262 Keyword.IMPORT, 262 Keyword.IMPORT,
263 Keyword.LIBRARY, 263 Keyword.LIBRARY,
264 Keyword.PART, 264 Keyword.PART,
265 Keyword.TYPEDEF, 265 Keyword.TYPEDEF,
266 Keyword.VAR], 266 Keyword.VAR],
267 COMPLETION_RELEVANCE_HIGH); 267 DART_RELEVANCE_HIGH);
268 } 268 }
269 269
270 test_function_body() { 270 test_function_body() {
271 addTestSource('main() {^}'); 271 addTestSource('main() {^}');
272 expect(computeFast(), isTrue); 272 expect(computeFast(), isTrue);
273 assertSuggestKeywords( 273 assertSuggestKeywords(
274 [ 274 [
275 Keyword.ASSERT, 275 Keyword.ASSERT,
276 Keyword.CASE, 276 Keyword.CASE,
277 Keyword.CONTINUE, 277 Keyword.CONTINUE,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 [ 343 [
344 Keyword.ABSTRACT, 344 Keyword.ABSTRACT,
345 Keyword.CLASS, 345 Keyword.CLASS,
346 Keyword.CONST, 346 Keyword.CONST,
347 Keyword.EXPORT, 347 Keyword.EXPORT,
348 Keyword.FINAL, 348 Keyword.FINAL,
349 Keyword.IMPORT, 349 Keyword.IMPORT,
350 Keyword.PART, 350 Keyword.PART,
351 Keyword.TYPEDEF, 351 Keyword.TYPEDEF,
352 Keyword.VAR], 352 Keyword.VAR],
353 COMPLETION_RELEVANCE_HIGH); 353 DART_RELEVANCE_HIGH);
354 } 354 }
355 355
356 test_library_name() { 356 test_library_name() {
357 addTestSource('library ^'); 357 addTestSource('library ^');
358 expect(computeFast(), isTrue); 358 expect(computeFast(), isTrue);
359 assertSuggestKeywords([]); 359 assertSuggestKeywords([]);
360 } 360 }
361 361
362 test_method_body() { 362 test_method_body() {
363 addTestSource('class A { foo() {^}}'); 363 addTestSource('class A { foo() {^}}');
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 [ 398 [
399 Keyword.ABSTRACT, 399 Keyword.ABSTRACT,
400 Keyword.CLASS, 400 Keyword.CLASS,
401 Keyword.CONST, 401 Keyword.CONST,
402 Keyword.EXPORT, 402 Keyword.EXPORT,
403 Keyword.FINAL, 403 Keyword.FINAL,
404 Keyword.IMPORT, 404 Keyword.IMPORT,
405 Keyword.PART, 405 Keyword.PART,
406 Keyword.TYPEDEF, 406 Keyword.TYPEDEF,
407 Keyword.VAR], 407 Keyword.VAR],
408 COMPLETION_RELEVANCE_HIGH); 408 DART_RELEVANCE_HIGH);
409 } 409 }
410 410
411 test_partial_class() { 411 test_partial_class() {
412 addTestSource('cl^'); 412 addTestSource('cl^');
413 expect(computeFast(), isTrue); 413 expect(computeFast(), isTrue);
414 assertSuggestKeywords( 414 assertSuggestKeywords(
415 [ 415 [
416 Keyword.ABSTRACT, 416 Keyword.ABSTRACT,
417 Keyword.CLASS, 417 Keyword.CLASS,
418 Keyword.CONST, 418 Keyword.CONST,
419 Keyword.EXPORT, 419 Keyword.EXPORT,
420 Keyword.FINAL, 420 Keyword.FINAL,
421 Keyword.IMPORT, 421 Keyword.IMPORT,
422 Keyword.LIBRARY, 422 Keyword.LIBRARY,
423 Keyword.PART, 423 Keyword.PART,
424 Keyword.TYPEDEF, 424 Keyword.TYPEDEF,
425 Keyword.VAR], 425 Keyword.VAR],
426 COMPLETION_RELEVANCE_HIGH); 426 DART_RELEVANCE_HIGH);
427 } 427 }
428 428
429 test_partial_class2() { 429 test_partial_class2() {
430 addTestSource('library a; cl^'); 430 addTestSource('library a; cl^');
431 expect(computeFast(), isTrue); 431 expect(computeFast(), isTrue);
432 assertSuggestKeywords( 432 assertSuggestKeywords(
433 [ 433 [
434 Keyword.ABSTRACT, 434 Keyword.ABSTRACT,
435 Keyword.CLASS, 435 Keyword.CLASS,
436 Keyword.CONST, 436 Keyword.CONST,
437 Keyword.EXPORT, 437 Keyword.EXPORT,
438 Keyword.FINAL, 438 Keyword.FINAL,
439 Keyword.IMPORT, 439 Keyword.IMPORT,
440 Keyword.PART, 440 Keyword.PART,
441 Keyword.TYPEDEF, 441 Keyword.TYPEDEF,
442 Keyword.VAR], 442 Keyword.VAR],
443 COMPLETION_RELEVANCE_HIGH); 443 DART_RELEVANCE_HIGH);
444 } 444 }
445 445
446 void _appendKeywords(StringBuffer msg, Iterable<Keyword> keywords) { 446 void _appendKeywords(StringBuffer msg, Iterable<Keyword> keywords) {
447 List<Keyword> sorted = keywords.toList(); 447 List<Keyword> sorted = keywords.toList();
448 sorted.sort((k1, k2) => k1.name.compareTo(k2.name)); 448 sorted.sort((k1, k2) => k1.name.compareTo(k2.name));
449 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},')); 449 sorted.forEach((k) => msg.writeln(' Keyword.${k.name},'));
450 } 450 }
451 451
452 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) { 452 bool _equalSets(Iterable<Keyword> iter1, Iterable<Keyword> iter2) {
453 if (iter1.length != iter2.length) return false; 453 if (iter1.length != iter2.length) return false;
454 if (iter1.any((k) => !iter2.contains(k))) return false; 454 if (iter1.any((k) => !iter2.contains(k))) return false;
455 if (iter2.any((k) => !iter1.contains(k))) return false; 455 if (iter2.any((k) => !iter1.contains(k))) return false;
456 return true; 456 return true;
457 } 457 }
458 } 458 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698