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

Side by Side Diff: pkg/analysis_server/test/services/completion/completion_test_util.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.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 (CompletionSuggestion cs) => cs.completion == completion, 107 (CompletionSuggestion cs) => cs.completion == completion,
108 orElse: () => null); 108 orElse: () => null);
109 if (suggestion != null) { 109 if (suggestion != null) {
110 failedCompletion('did not expect completion: $completion\n $suggestion'); 110 failedCompletion('did not expect completion: $completion\n $suggestion');
111 } 111 }
112 return null; 112 return null;
113 } 113 }
114 114
115 CompletionSuggestion assertSuggest(String completion, 115 CompletionSuggestion assertSuggest(String completion,
116 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, 116 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION,
117 int relevance: COMPLETION_RELEVANCE_DEFAULT, protocol.ElementKind elemKind : 117 int relevance: DART_RELEVANCE_DEFAULT, protocol.ElementKind elemKind:
118 null, bool isDeprecated: false, bool isPotential: false}) { 118 null, bool isDeprecated: false, bool isPotential: false}) {
119 CompletionSuggestion cs = 119 CompletionSuggestion cs =
120 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); 120 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind);
121 if (cs == null) { 121 if (cs == null) {
122 failedCompletion( 122 failedCompletion(
123 'expected $completion $csKind $elemKind', 123 'expected $completion $csKind $elemKind',
124 request.suggestions); 124 request.suggestions);
125 } 125 }
126 expect(cs.kind, equals(csKind)); 126 expect(cs.kind, equals(csKind));
127 if (isDeprecated) { 127 if (isDeprecated) {
128 expect(cs.relevance, equals(COMPLETION_RELEVANCE_LOW)); 128 expect(cs.relevance, equals(DART_RELEVANCE_LOW));
129 } else { 129 } else {
130 expect(cs.relevance, equals(relevance)); 130 expect(cs.relevance, equals(relevance));
131 } 131 }
132 expect(cs.selectionOffset, equals(completion.length)); 132 expect(cs.selectionOffset, equals(completion.length));
133 expect(cs.selectionLength, equals(0)); 133 expect(cs.selectionLength, equals(0));
134 expect(cs.isDeprecated, equals(isDeprecated)); 134 expect(cs.isDeprecated, equals(isDeprecated));
135 expect(cs.isPotential, equals(isPotential)); 135 expect(cs.isPotential, equals(isPotential));
136 return cs; 136 return cs;
137 } 137 }
138 138
139 void assertSuggestArgumentList(List<String> paramNames, 139 void assertSuggestArgumentList(List<String> paramNames,
140 List<String> paramTypes) { 140 List<String> paramTypes) {
141 CompletionSuggestionKind csKind = CompletionSuggestionKind.ARGUMENT_LIST; 141 CompletionSuggestionKind csKind = CompletionSuggestionKind.ARGUMENT_LIST;
142 CompletionSuggestion cs = getSuggest(csKind: csKind); 142 CompletionSuggestion cs = getSuggest(csKind: csKind);
143 if (cs == null) { 143 if (cs == null) {
144 failedCompletion('expected completion $csKind', request.suggestions); 144 failedCompletion('expected completion $csKind', request.suggestions);
145 } 145 }
146 assertSuggestArgumentList_params( 146 assertSuggestArgumentList_params(
147 paramNames, 147 paramNames,
148 paramTypes, 148 paramTypes,
149 cs.parameterNames, 149 cs.parameterNames,
150 cs.parameterTypes); 150 cs.parameterTypes);
151 expect(cs.relevance, COMPLETION_RELEVANCE_HIGH); 151 expect(cs.relevance, DART_RELEVANCE_HIGH);
152 } 152 }
153 153
154 void assertSuggestArgumentList_params(List<String> expectedNames, 154 void assertSuggestArgumentList_params(List<String> expectedNames,
155 List<String> expectedTypes, List<String> actualNames, 155 List<String> expectedTypes, List<String> actualNames,
156 List<String> actualTypes) { 156 List<String> actualTypes) {
157 if (actualNames != null && 157 if (actualNames != null &&
158 actualNames.length == expectedNames.length && 158 actualNames.length == expectedNames.length &&
159 actualTypes != null && 159 actualTypes != null &&
160 actualTypes.length == expectedTypes.length) { 160 actualTypes.length == expectedTypes.length) {
161 int index = 0; 161 int index = 0;
(...skipping 11 matching lines...) Expand all
173 StringBuffer msg = new StringBuffer(); 173 StringBuffer msg = new StringBuffer();
174 msg.writeln('Argument list not the same'); 174 msg.writeln('Argument list not the same');
175 msg.writeln(' Expected names: $expectedNames'); 175 msg.writeln(' Expected names: $expectedNames');
176 msg.writeln(' found: $actualNames'); 176 msg.writeln(' found: $actualNames');
177 msg.writeln(' Expected types: $expectedTypes'); 177 msg.writeln(' Expected types: $expectedTypes');
178 msg.writeln(' found: $actualTypes'); 178 msg.writeln(' found: $actualTypes');
179 fail(msg.toString()); 179 fail(msg.toString());
180 } 180 }
181 181
182 CompletionSuggestion assertSuggestClass(String name, {int relevance: 182 CompletionSuggestion assertSuggestClass(String name, {int relevance:
183 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind: 183 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind:
184 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { 184 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) {
185 CompletionSuggestion cs = assertSuggest( 185 CompletionSuggestion cs = assertSuggest(
186 name, 186 name,
187 csKind: kind, 187 csKind: kind,
188 relevance: relevance, 188 relevance: relevance,
189 isDeprecated: isDeprecated); 189 isDeprecated: isDeprecated);
190 protocol.Element element = cs.element; 190 protocol.Element element = cs.element;
191 expect(element, isNotNull); 191 expect(element, isNotNull);
192 expect(element.kind, equals(protocol.ElementKind.CLASS)); 192 expect(element.kind, equals(protocol.ElementKind.CLASS));
193 expect(element.name, equals(name)); 193 expect(element.name, equals(name));
194 expect(element.parameters, isNull); 194 expect(element.parameters, isNull);
195 expect(element.returnType, isNull); 195 expect(element.returnType, isNull);
196 assertHasNoParameterInfo(cs); 196 assertHasNoParameterInfo(cs);
197 return cs; 197 return cs;
198 } 198 }
199 199
200 CompletionSuggestion assertSuggestClassTypeAlias(String name, [int relevance = 200 CompletionSuggestion assertSuggestClassTypeAlias(String name, [int relevance =
201 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 201 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
202 CompletionSuggestionKind.INVOCATION]) { 202 CompletionSuggestionKind.INVOCATION]) {
203 CompletionSuggestion cs = 203 CompletionSuggestion cs =
204 assertSuggest(name, csKind: kind, relevance: relevance); 204 assertSuggest(name, csKind: kind, relevance: relevance);
205 protocol.Element element = cs.element; 205 protocol.Element element = cs.element;
206 expect(element, isNotNull); 206 expect(element, isNotNull);
207 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); 207 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS));
208 expect(element.name, equals(name)); 208 expect(element.name, equals(name));
209 expect(element.parameters, isNull); 209 expect(element.parameters, isNull);
210 expect(element.returnType, isNull); 210 expect(element.returnType, isNull);
211 assertHasNoParameterInfo(cs); 211 assertHasNoParameterInfo(cs);
212 return cs; 212 return cs;
213 } 213 }
214 214
215 CompletionSuggestion assertSuggestField(String name, String type, 215 CompletionSuggestion assertSuggestField(String name, String type,
216 {int relevance: COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kin d: 216 {int relevance: DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind:
217 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { 217 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) {
218 CompletionSuggestion cs = assertSuggest( 218 CompletionSuggestion cs = assertSuggest(
219 name, 219 name,
220 csKind: kind, 220 csKind: kind,
221 relevance: relevance, 221 relevance: relevance,
222 elemKind: protocol.ElementKind.FIELD, 222 elemKind: protocol.ElementKind.FIELD,
223 isDeprecated: isDeprecated); 223 isDeprecated: isDeprecated);
224 // The returnType represents the type of a field 224 // The returnType represents the type of a field
225 expect(cs.returnType, type != null ? type : 'dynamic'); 225 expect(cs.returnType, type != null ? type : 'dynamic');
226 protocol.Element element = cs.element; 226 protocol.Element element = cs.element;
227 expect(element, isNotNull); 227 expect(element, isNotNull);
228 expect(element.kind, equals(protocol.ElementKind.FIELD)); 228 expect(element.kind, equals(protocol.ElementKind.FIELD));
229 expect(element.name, equals(name)); 229 expect(element.name, equals(name));
230 expect(element.parameters, isNull); 230 expect(element.parameters, isNull);
231 // The returnType represents the type of a field 231 // The returnType represents the type of a field
232 expect(element.returnType, type != null ? type : 'dynamic'); 232 expect(element.returnType, type != null ? type : 'dynamic');
233 assertHasNoParameterInfo(cs); 233 assertHasNoParameterInfo(cs);
234 return cs; 234 return cs;
235 } 235 }
236 236
237 CompletionSuggestion assertSuggestFunction(String name, String returnType, 237 CompletionSuggestion assertSuggestFunction(String name, String returnType,
238 [bool isDeprecated = false, int relevance = COMPLETION_RELEVANCE_DEFAULT, 238 [bool isDeprecated = false, int relevance = DART_RELEVANCE_DEFAULT,
239 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 239 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
240 CompletionSuggestion cs = assertSuggest( 240 CompletionSuggestion cs = assertSuggest(
241 name, 241 name,
242 csKind: kind, 242 csKind: kind,
243 relevance: relevance, 243 relevance: relevance,
244 isDeprecated: isDeprecated); 244 isDeprecated: isDeprecated);
245 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 245 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
246 protocol.Element element = cs.element; 246 protocol.Element element = cs.element;
247 expect(element, isNotNull); 247 expect(element, isNotNull);
248 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); 248 expect(element.kind, equals(protocol.ElementKind.FUNCTION));
249 expect(element.name, equals(name)); 249 expect(element.name, equals(name));
250 expect(element.isDeprecated, equals(isDeprecated)); 250 expect(element.isDeprecated, equals(isDeprecated));
251 String param = element.parameters; 251 String param = element.parameters;
252 expect(param, isNotNull); 252 expect(param, isNotNull);
253 expect(param[0], equals('(')); 253 expect(param[0], equals('('));
254 expect(param[param.length - 1], equals(')')); 254 expect(param[param.length - 1], equals(')'));
255 expect( 255 expect(
256 element.returnType, 256 element.returnType,
257 equals(returnType != null ? returnType : 'dynamic')); 257 equals(returnType != null ? returnType : 'dynamic'));
258 assertHasParameterInfo(cs); 258 assertHasParameterInfo(cs);
259 return cs; 259 return cs;
260 } 260 }
261 261
262 CompletionSuggestion assertSuggestFunctionTypeAlias(String name, 262 CompletionSuggestion assertSuggestFunctionTypeAlias(String name,
263 String returnType, bool isDeprecated, [int relevance = 263 String returnType, bool isDeprecated, [int relevance =
264 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 264 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
265 CompletionSuggestionKind.INVOCATION]) { 265 CompletionSuggestionKind.INVOCATION]) {
266 CompletionSuggestion cs = assertSuggest( 266 CompletionSuggestion cs = assertSuggest(
267 name, 267 name,
268 csKind: kind, 268 csKind: kind,
269 relevance: relevance, 269 relevance: relevance,
270 isDeprecated: isDeprecated); 270 isDeprecated: isDeprecated);
271 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 271 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
272 protocol.Element element = cs.element; 272 protocol.Element element = cs.element;
273 expect(element, isNotNull); 273 expect(element, isNotNull);
274 expect(element.kind, equals(protocol.ElementKind.FUNCTION_TYPE_ALIAS)); 274 expect(element.kind, equals(protocol.ElementKind.FUNCTION_TYPE_ALIAS));
275 expect(element.name, equals(name)); 275 expect(element.name, equals(name));
276 expect(element.isDeprecated, equals(isDeprecated)); 276 expect(element.isDeprecated, equals(isDeprecated));
277 // TODO (danrubel) Determine why params are null 277 // TODO (danrubel) Determine why params are null
278 // String param = element.parameters; 278 // String param = element.parameters;
279 // expect(param, isNotNull); 279 // expect(param, isNotNull);
280 // expect(param[0], equals('(')); 280 // expect(param[0], equals('('));
281 // expect(param[param.length - 1], equals(')')); 281 // expect(param[param.length - 1], equals(')'));
282 expect( 282 expect(
283 element.returnType, 283 element.returnType,
284 equals(returnType != null ? returnType : 'dynamic')); 284 equals(returnType != null ? returnType : 'dynamic'));
285 // TODO (danrubel) Determine why param info is missing 285 // TODO (danrubel) Determine why param info is missing
286 // assertHasParameterInfo(cs); 286 // assertHasParameterInfo(cs);
287 return cs; 287 return cs;
288 } 288 }
289 289
290 CompletionSuggestion assertSuggestGetter(String name, String returnType, 290 CompletionSuggestion assertSuggestGetter(String name, String returnType,
291 {int relevance: COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kin d: 291 {int relevance: DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind:
292 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { 292 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) {
293 CompletionSuggestion cs = assertSuggest( 293 CompletionSuggestion cs = assertSuggest(
294 name, 294 name,
295 csKind: kind, 295 csKind: kind,
296 relevance: relevance, 296 relevance: relevance,
297 elemKind: protocol.ElementKind.GETTER, 297 elemKind: protocol.ElementKind.GETTER,
298 isDeprecated: isDeprecated); 298 isDeprecated: isDeprecated);
299 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 299 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
300 protocol.Element element = cs.element; 300 protocol.Element element = cs.element;
301 expect(element, isNotNull); 301 expect(element, isNotNull);
302 expect(element.kind, equals(protocol.ElementKind.GETTER)); 302 expect(element.kind, equals(protocol.ElementKind.GETTER));
303 expect(element.name, equals(name)); 303 expect(element.name, equals(name));
304 expect(element.parameters, isNull); 304 expect(element.parameters, isNull);
305 expect( 305 expect(
306 element.returnType, 306 element.returnType,
307 equals(returnType != null ? returnType : 'dynamic')); 307 equals(returnType != null ? returnType : 'dynamic'));
308 assertHasNoParameterInfo(cs); 308 assertHasNoParameterInfo(cs);
309 return cs; 309 return cs;
310 } 310 }
311 311
312 CompletionSuggestion assertSuggestLabel(String name, [int relevance = 312 CompletionSuggestion assertSuggestLabel(String name, [int relevance =
313 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 313 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
314 CompletionSuggestionKind.IDENTIFIER]) { 314 CompletionSuggestionKind.IDENTIFIER]) {
315 CompletionSuggestion cs = 315 CompletionSuggestion cs =
316 assertSuggest(name, csKind: kind, relevance: relevance); 316 assertSuggest(name, csKind: kind, relevance: relevance);
317 expect(cs.returnType, isNull); 317 expect(cs.returnType, isNull);
318 protocol.Element element = cs.element; 318 protocol.Element element = cs.element;
319 expect(element, isNotNull); 319 expect(element, isNotNull);
320 expect(element.flags, 0); 320 expect(element.flags, 0);
321 expect(element.kind, equals(protocol.ElementKind.LABEL)); 321 expect(element.kind, equals(protocol.ElementKind.LABEL));
322 expect(element.name, equals(name)); 322 expect(element.name, equals(name));
323 expect(element.parameters, isNull); 323 expect(element.parameters, isNull);
324 expect(element.returnType, isNull); 324 expect(element.returnType, isNull);
325 assertHasNoParameterInfo(cs); 325 assertHasNoParameterInfo(cs);
326 return cs; 326 return cs;
327 } 327 }
328 328
329 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, [int relevance 329 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, [int relevance
330 = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 330 = DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
331 CompletionSuggestionKind.INVOCATION]) { 331 CompletionSuggestionKind.INVOCATION]) {
332 // Library prefix should only be suggested by ImportedComputer 332 // Library prefix should only be suggested by ImportedComputer
333 if (computer is ImportedComputer) { 333 if (computer is ImportedComputer) {
334 CompletionSuggestion cs = 334 CompletionSuggestion cs =
335 assertSuggest(prefix, csKind: kind, relevance: relevance); 335 assertSuggest(prefix, csKind: kind, relevance: relevance);
336 protocol.Element element = cs.element; 336 protocol.Element element = cs.element;
337 expect(element, isNotNull); 337 expect(element, isNotNull);
338 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); 338 expect(element.kind, equals(protocol.ElementKind.LIBRARY));
339 expect(element.parameters, isNull); 339 expect(element.parameters, isNull);
340 expect(element.returnType, isNull); 340 expect(element.returnType, isNull);
341 assertHasNoParameterInfo(cs); 341 assertHasNoParameterInfo(cs);
342 return cs; 342 return cs;
343 } else { 343 } else {
344 return assertNotSuggested(prefix); 344 return assertNotSuggested(prefix);
345 } 345 }
346 } 346 }
347 347
348 CompletionSuggestion assertSuggestMethod(String name, String declaringType, 348 CompletionSuggestion assertSuggestMethod(String name, String declaringType,
349 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, 349 String returnType, {int relevance: DART_RELEVANCE_DEFAULT,
350 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 350 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
351 bool isDeprecated: false}) { 351 bool isDeprecated: false}) {
352 CompletionSuggestion cs = assertSuggest( 352 CompletionSuggestion cs = assertSuggest(
353 name, 353 name,
354 csKind: kind, 354 csKind: kind,
355 relevance: relevance, 355 relevance: relevance,
356 isDeprecated: isDeprecated); 356 isDeprecated: isDeprecated);
357 expect(cs.declaringType, equals(declaringType)); 357 expect(cs.declaringType, equals(declaringType));
358 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 358 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
359 protocol.Element element = cs.element; 359 protocol.Element element = cs.element;
360 expect(element, isNotNull); 360 expect(element, isNotNull);
361 expect(element.kind, equals(protocol.ElementKind.METHOD)); 361 expect(element.kind, equals(protocol.ElementKind.METHOD));
362 expect(element.name, equals(name)); 362 expect(element.name, equals(name));
363 String param = element.parameters; 363 String param = element.parameters;
364 expect(param, isNotNull); 364 expect(param, isNotNull);
365 expect(param[0], equals('(')); 365 expect(param[0], equals('('));
366 expect(param[param.length - 1], equals(')')); 366 expect(param[param.length - 1], equals(')'));
367 expect(element.returnType, returnType != null ? returnType : 'dynamic'); 367 expect(element.returnType, returnType != null ? returnType : 'dynamic');
368 assertHasParameterInfo(cs); 368 assertHasParameterInfo(cs);
369 return cs; 369 return cs;
370 } 370 }
371 371
372 CompletionSuggestion assertSuggestNamedConstructor(String name, 372 CompletionSuggestion assertSuggestNamedConstructor(String name,
373 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, 373 String returnType, [int relevance = DART_RELEVANCE_DEFAULT,
374 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 374 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
375 if (computer is InvocationComputer) { 375 if (computer is InvocationComputer) {
376 CompletionSuggestion cs = 376 CompletionSuggestion cs =
377 assertSuggest(name, csKind: kind, relevance: relevance); 377 assertSuggest(name, csKind: kind, relevance: relevance);
378 protocol.Element element = cs.element; 378 protocol.Element element = cs.element;
379 expect(element, isNotNull); 379 expect(element, isNotNull);
380 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR)); 380 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR));
381 expect(element.name, equals(name)); 381 expect(element.name, equals(name));
382 String param = element.parameters; 382 String param = element.parameters;
383 expect(param, isNotNull); 383 expect(param, isNotNull);
384 expect(param[0], equals('(')); 384 expect(param[0], equals('('));
385 expect(param[param.length - 1], equals(')')); 385 expect(param[param.length - 1], equals(')'));
386 expect(element.returnType, equals(returnType)); 386 expect(element.returnType, equals(returnType));
387 assertHasParameterInfo(cs); 387 assertHasParameterInfo(cs);
388 return cs; 388 return cs;
389 } else { 389 } else {
390 return assertNotSuggested(name); 390 return assertNotSuggested(name);
391 } 391 }
392 } 392 }
393 393
394 CompletionSuggestion assertSuggestParameter(String name, String returnType, 394 CompletionSuggestion assertSuggestParameter(String name, String returnType,
395 {int relevance: DART_RELEVANCE_PARAMETER}) { 395 {int relevance: DART_RELEVANCE_PARAMETER}) {
396 return assertNotSuggested(name); 396 return assertNotSuggested(name);
397 } 397 }
398 398
399 CompletionSuggestion assertSuggestSetter(String name, [int relevance = 399 CompletionSuggestion assertSuggestSetter(String name, [int relevance =
400 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 400 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
401 CompletionSuggestionKind.INVOCATION]) { 401 CompletionSuggestionKind.INVOCATION]) {
402 CompletionSuggestion cs = assertSuggest( 402 CompletionSuggestion cs = assertSuggest(
403 name, 403 name,
404 csKind: kind, 404 csKind: kind,
405 relevance: relevance, 405 relevance: relevance,
406 elemKind: protocol.ElementKind.SETTER); 406 elemKind: protocol.ElementKind.SETTER);
407 protocol.Element element = cs.element; 407 protocol.Element element = cs.element;
408 expect(element, isNotNull); 408 expect(element, isNotNull);
409 expect(element.kind, equals(protocol.ElementKind.SETTER)); 409 expect(element.kind, equals(protocol.ElementKind.SETTER));
410 expect(element.name, equals(name)); 410 expect(element.name, equals(name));
411 // TODO (danrubel) assert setter param 411 // TODO (danrubel) assert setter param
412 //expect(element.parameters, isNull); 412 //expect(element.parameters, isNull);
413 // TODO (danrubel) it would be better if this was always null 413 // TODO (danrubel) it would be better if this was always null
414 if (element.returnType != null) { 414 if (element.returnType != null) {
415 expect(element.returnType, 'dynamic'); 415 expect(element.returnType, 'dynamic');
416 } 416 }
417 assertHasNoParameterInfo(cs); 417 assertHasNoParameterInfo(cs);
418 return cs; 418 return cs;
419 } 419 }
420 420
421 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, 421 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType,
422 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki nd = 422 [int relevance = DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
423 CompletionSuggestionKind.INVOCATION]) { 423 CompletionSuggestionKind.INVOCATION]) {
424 CompletionSuggestion cs = 424 CompletionSuggestion cs =
425 assertSuggest(name, csKind: kind, relevance: relevance); 425 assertSuggest(name, csKind: kind, relevance: relevance);
426 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); 426 expect(cs.returnType, returnType != null ? returnType : 'dynamic');
427 protocol.Element element = cs.element; 427 protocol.Element element = cs.element;
428 expect(element, isNotNull); 428 expect(element, isNotNull);
429 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); 429 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE));
430 expect(element.name, equals(name)); 430 expect(element.name, equals(name));
431 expect(element.parameters, isNull); 431 expect(element.parameters, isNull);
432 expect(element.returnType, returnType != null ? returnType : 'dynamic'); 432 expect(element.returnType, returnType != null ? returnType : 'dynamic');
433 assertHasNoParameterInfo(cs); 433 assertHasNoParameterInfo(cs);
434 return cs; 434 return cs;
435 } 435 }
436 436
437 void assertSuggestTopLevelVarGetterSetter(String name, String returnType, 437 void assertSuggestTopLevelVarGetterSetter(String name, String returnType,
438 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { 438 [int relevance = DART_RELEVANCE_DEFAULT]) {
439 if (computer is ImportedComputer) { 439 if (computer is ImportedComputer) {
440 assertSuggestGetter(name, returnType); 440 assertSuggestGetter(name, returnType);
441 assertSuggestSetter(name); 441 assertSuggestSetter(name);
442 } else { 442 } else {
443 assertNotSuggested(name); 443 assertNotSuggested(name);
444 } 444 }
445 } 445 }
446 446
447 bool computeFast() { 447 bool computeFast() {
448 _computeFastCalled = true; 448 _computeFastCalled = true;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 579
580 /** 580 /**
581 * Assert that the ImportedComputer uses cached results to produce identical 581 * Assert that the ImportedComputer uses cached results to produce identical
582 * suggestions to the original set of suggestions. 582 * suggestions to the original set of suggestions.
583 */ 583 */
584 void assertCachedCompute(_) { 584 void assertCachedCompute(_) {
585 // Subclasses override 585 // Subclasses override
586 } 586 }
587 587
588 CompletionSuggestion assertSuggestImportedClass(String name, [int relevance = 588 CompletionSuggestion assertSuggestImportedClass(String name, [int relevance =
589 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 589 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
590 CompletionSuggestionKind.INVOCATION]) { 590 CompletionSuggestionKind.INVOCATION]) {
591 if (computer is ImportedComputer) { 591 if (computer is ImportedComputer) {
592 return assertSuggestClass(name, relevance: relevance, kind: kind); 592 return assertSuggestClass(name, relevance: relevance, kind: kind);
593 } else { 593 } else {
594 return assertNotSuggested(name); 594 return assertNotSuggested(name);
595 } 595 }
596 } 596 }
597 597
598 CompletionSuggestion assertSuggestImportedField(String name, String type, 598 CompletionSuggestion assertSuggestImportedField(String name, String type,
599 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) { 599 {int relevance: DART_RELEVANCE_INHERITED_FIELD}) {
600 return assertNotSuggested(name); 600 return assertNotSuggested(name);
601 } 601 }
602 602
603 CompletionSuggestion assertSuggestImportedFunction(String name, 603 CompletionSuggestion assertSuggestImportedFunction(String name,
604 String returnType, [bool isDeprecated = false, int relevance = 604 String returnType, [bool isDeprecated = false, int relevance =
605 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 605 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
606 CompletionSuggestionKind.INVOCATION]) { 606 CompletionSuggestionKind.INVOCATION]) {
607 if (computer is ImportedComputer) { 607 if (computer is ImportedComputer) {
608 return assertSuggestFunction( 608 return assertSuggestFunction(
609 name, 609 name,
610 returnType, 610 returnType,
611 isDeprecated, 611 isDeprecated,
612 relevance, 612 relevance,
613 kind); 613 kind);
614 } else { 614 } else {
615 return assertNotSuggested(name); 615 return assertNotSuggested(name);
616 } 616 }
617 } 617 }
618 618
619 CompletionSuggestion assertSuggestImportedFunctionTypeAlias(String name, 619 CompletionSuggestion assertSuggestImportedFunctionTypeAlias(String name,
620 String returnType, [bool isDeprecated = false, int relevance = 620 String returnType, [bool isDeprecated = false, int relevance =
621 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 621 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
622 CompletionSuggestionKind.INVOCATION]) { 622 CompletionSuggestionKind.INVOCATION]) {
623 if (computer is ImportedComputer) { 623 if (computer is ImportedComputer) {
624 return assertSuggestFunctionTypeAlias( 624 return assertSuggestFunctionTypeAlias(
625 name, 625 name,
626 returnType, 626 returnType,
627 isDeprecated, 627 isDeprecated,
628 relevance, 628 relevance,
629 kind); 629 kind);
630 } else { 630 } else {
631 return assertNotSuggested(name); 631 return assertNotSuggested(name);
(...skipping 10 matching lines...) Expand all
642 DART_RELEVANCE_INHERITED_METHOD}) { 642 DART_RELEVANCE_INHERITED_METHOD}) {
643 return assertNotSuggested(name); 643 return assertNotSuggested(name);
644 } 644 }
645 645
646 CompletionSuggestion assertSuggestImportedSetter(String name, {int relevance: 646 CompletionSuggestion assertSuggestImportedSetter(String name, {int relevance:
647 DART_RELEVANCE_INHERITED_ACCESSOR}) { 647 DART_RELEVANCE_INHERITED_ACCESSOR}) {
648 return assertNotSuggested(name); 648 return assertNotSuggested(name);
649 } 649 }
650 650
651 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, 651 CompletionSuggestion assertSuggestImportedTopLevelVar(String name,
652 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, 652 String returnType, [int relevance = DART_RELEVANCE_DEFAULT,
653 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 653 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
654 if (computer is ImportedComputer) { 654 if (computer is ImportedComputer) {
655 return assertSuggestTopLevelVar(name, returnType, relevance, kind); 655 return assertSuggestTopLevelVar(name, returnType, relevance, kind);
656 } else { 656 } else {
657 return assertNotSuggested(name); 657 return assertNotSuggested(name);
658 } 658 }
659 } 659 }
660 660
661 CompletionSuggestion assertSuggestInvocationClass(String name, [int relevance 661 CompletionSuggestion assertSuggestInvocationClass(String name, [int relevance
662 = COMPLETION_RELEVANCE_DEFAULT]) { 662 = DART_RELEVANCE_DEFAULT]) {
663 if (computer is InvocationComputer) { 663 if (computer is InvocationComputer) {
664 return assertSuggestClass(name, relevance: relevance); 664 return assertSuggestClass(name, relevance: relevance);
665 } else { 665 } else {
666 return assertNotSuggested(name); 666 return assertNotSuggested(name);
667 } 667 }
668 } 668 }
669 669
670 CompletionSuggestion assertSuggestInvocationField(String name, String type, 670 CompletionSuggestion assertSuggestInvocationField(String name, String type,
671 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { 671 {int relevance: DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) {
672 return assertNotSuggested(name); 672 return assertNotSuggested(name);
673 } 673 }
674 674
675 CompletionSuggestion assertSuggestInvocationGetter(String name, 675 CompletionSuggestion assertSuggestInvocationGetter(String name,
676 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, 676 String returnType, {int relevance: DART_RELEVANCE_DEFAULT,
677 bool isDeprecated: false}) { 677 bool isDeprecated: false}) {
678 if (computer is InvocationComputer) { 678 if (computer is InvocationComputer) {
679 return assertSuggestGetter( 679 return assertSuggestGetter(
680 name, 680 name,
681 returnType, 681 returnType,
682 relevance: relevance, 682 relevance: relevance,
683 isDeprecated: isDeprecated); 683 isDeprecated: isDeprecated);
684 } else { 684 } else {
685 return assertNotSuggested(name); 685 return assertNotSuggested(name);
686 } 686 }
687 } 687 }
688 688
689 CompletionSuggestion assertSuggestInvocationMethod(String name, 689 CompletionSuggestion assertSuggestInvocationMethod(String name,
690 String declaringType, String returnType, [int relevance = 690 String declaringType, String returnType, [int relevance =
691 COMPLETION_RELEVANCE_DEFAULT]) { 691 DART_RELEVANCE_DEFAULT]) {
692 if (computer is InvocationComputer) { 692 if (computer is InvocationComputer) {
693 return assertSuggestMethod( 693 return assertSuggestMethod(
694 name, 694 name,
695 declaringType, 695 declaringType,
696 returnType, 696 returnType,
697 relevance: relevance); 697 relevance: relevance);
698 } else { 698 } else {
699 return assertNotSuggested(name); 699 return assertNotSuggested(name);
700 } 700 }
701 } 701 }
702 702
703 CompletionSuggestion assertSuggestInvocationSetter(String name, [int relevance 703 CompletionSuggestion assertSuggestInvocationSetter(String name, [int relevance
704 = COMPLETION_RELEVANCE_DEFAULT]) { 704 = DART_RELEVANCE_DEFAULT]) {
705 if (computer is InvocationComputer) { 705 if (computer is InvocationComputer) {
706 return assertSuggestSetter(name); 706 return assertSuggestSetter(name);
707 } else { 707 } else {
708 return assertNotSuggested(name); 708 return assertNotSuggested(name);
709 } 709 }
710 } 710 }
711 711
712 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name, 712 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name,
713 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { 713 String returnType, [int relevance = DART_RELEVANCE_DEFAULT]) {
714 if (computer is InvocationComputer) { 714 if (computer is InvocationComputer) {
715 return assertSuggestTopLevelVar(name, returnType, relevance); 715 return assertSuggestTopLevelVar(name, returnType, relevance);
716 } else { 716 } else {
717 return assertNotSuggested(name); 717 return assertNotSuggested(name);
718 } 718 }
719 } 719 }
720 720
721 CompletionSuggestion assertSuggestLocalClass(String name, {int relevance: 721 CompletionSuggestion assertSuggestLocalClass(String name, {int relevance:
722 COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { 722 DART_RELEVANCE_DEFAULT, bool isDeprecated: false}) {
723 return assertNotSuggested(name); 723 return assertNotSuggested(name);
724 } 724 }
725 725
726 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, 726 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name,
727 {int relevance: COMPLETION_RELEVANCE_DEFAULT}) { 727 {int relevance: DART_RELEVANCE_DEFAULT}) {
728 return assertNotSuggested(name); 728 return assertNotSuggested(name);
729 } 729 }
730 730
731 CompletionSuggestion assertSuggestLocalField(String name, String type, 731 CompletionSuggestion assertSuggestLocalField(String name, String type,
732 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) { 732 {int relevance: DART_RELEVANCE_LOCAL_FIELD, bool deprecated: false}) {
733 return assertNotSuggested(name); 733 return assertNotSuggested(name);
734 } 734 }
735 735
736 CompletionSuggestion assertSuggestLocalFunction(String name, 736 CompletionSuggestion assertSuggestLocalFunction(String name,
737 String returnType, {bool deprecated: false, int relevance: 737 String returnType, {bool deprecated: false, int relevance:
738 DART_RELEVANCE_LOCAL_FUNCTION}) { 738 DART_RELEVANCE_LOCAL_FUNCTION}) {
739 return assertNotSuggested(name); 739 return assertNotSuggested(name);
740 } 740 }
741 741
742 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name, 742 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name,
743 String returnType, {bool deprecated: false, int relevance: 743 String returnType, {bool deprecated: false, int relevance:
744 COMPLETION_RELEVANCE_DEFAULT}) { 744 DART_RELEVANCE_DEFAULT}) {
745 return assertNotSuggested(name); 745 return assertNotSuggested(name);
746 } 746 }
747 747
748 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, 748 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType,
749 {int relevance: DART_RELEVANCE_LOCAL_ACCESSOR, bool deprecated: false}) { 749 {int relevance: DART_RELEVANCE_LOCAL_ACCESSOR, bool deprecated: false}) {
750 return assertNotSuggested(name); 750 return assertNotSuggested(name);
751 } 751 }
752 752
753 CompletionSuggestion assertSuggestLocalMethod(String name, 753 CompletionSuggestion assertSuggestLocalMethod(String name,
754 String declaringType, String returnType, {int relevance: 754 String declaringType, String returnType, {int relevance:
(...skipping 10 matching lines...) Expand all
765 String returnType, {int relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE }) { 765 String returnType, {int relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE }) {
766 return assertNotSuggested(name); 766 return assertNotSuggested(name);
767 } 767 }
768 768
769 CompletionSuggestion assertSuggestLocalVariable(String name, 769 CompletionSuggestion assertSuggestLocalVariable(String name,
770 String returnType, {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) { 770 String returnType, {int relevance: DART_RELEVANCE_LOCAL_VARIABLE}) {
771 return assertNotSuggested(name); 771 return assertNotSuggested(name);
772 } 772 }
773 773
774 CompletionSuggestion assertSuggestNonLocalClass(String name, [int relevance = 774 CompletionSuggestion assertSuggestNonLocalClass(String name, [int relevance =
775 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = 775 DART_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
776 CompletionSuggestionKind.INVOCATION]) { 776 CompletionSuggestionKind.INVOCATION]) {
777 return assertSuggestImportedClass(name, relevance, kind); 777 return assertSuggestImportedClass(name, relevance, kind);
778 } 778 }
779 779
780 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { 780 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) {
781 return super.computeFull( 781 return super.computeFull(
782 assertFunction, 782 assertFunction,
783 fullAnalysis: fullAnalysis).then(assertCachedCompute); 783 fullAnalysis: fullAnalysis).then(assertCachedCompute);
784 } 784 }
785 785
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 assertSuggestLocalVariable('f', null); 1229 assertSuggestLocalVariable('f', null);
1230 // Don't suggest locals out of scope 1230 // Don't suggest locals out of scope
1231 assertNotSuggested('r'); 1231 assertNotSuggested('r');
1232 assertNotSuggested('x'); 1232 assertNotSuggested('x');
1233 1233
1234 // imported elements are portially filtered 1234 // imported elements are portially filtered
1235 //assertSuggestImportedClass('A'); 1235 //assertSuggestImportedClass('A');
1236 assertNotSuggested('_B'); 1236 assertNotSuggested('_B');
1237 //assertSuggestImportedClass('C'); 1237 //assertSuggestImportedClass('C');
1238 // hidden element suggested as low relevance 1238 // hidden element suggested as low relevance
1239 assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); 1239 assertSuggestImportedClass('D', DART_RELEVANCE_LOW);
1240 assertSuggestImportedFunction('D1', null, true, COMPLETION_RELEVANCE_LOW); 1240 assertSuggestImportedFunction('D1', null, true, DART_RELEVANCE_LOW);
1241 assertSuggestLocalFunction('D2', 'Z'); 1241 assertSuggestLocalFunction('D2', 'Z');
1242 //assertSuggestImportedClass('EE'); 1242 //assertSuggestImportedClass('EE');
1243 // hidden element suggested as low relevance 1243 // hidden element suggested as low relevance
1244 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); 1244 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW);
1245 //assertSuggestLibraryPrefix('g'); 1245 //assertSuggestLibraryPrefix('g');
1246 assertNotSuggested('G'); 1246 assertNotSuggested('G');
1247 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW); 1247 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW);
1248 //assertSuggestImportedClass('Object'); 1248 //assertSuggestImportedClass('Object');
1249 //assertSuggestImportedFunction('min', 'num', false); 1249 //assertSuggestImportedFunction('min', 'num', false);
1250 //assertSuggestImportedFunction( 1250 //assertSuggestImportedFunction(
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 import "testB.dart" as x; 1453 import "testB.dart" as x;
1454 @deprecated class A {^} 1454 @deprecated class A {^}
1455 class _B {} 1455 class _B {}
1456 A T;'''); 1456 A T;''');
1457 computeFast(); 1457 computeFast();
1458 return computeFull((bool result) { 1458 return computeFull((bool result) {
1459 expect(request.replacementOffset, completionOffset); 1459 expect(request.replacementOffset, completionOffset);
1460 expect(request.replacementLength, 0); 1460 expect(request.replacementLength, 0);
1461 CompletionSuggestion suggestionA = assertSuggestLocalClass( 1461 CompletionSuggestion suggestionA = assertSuggestLocalClass(
1462 'A', 1462 'A',
1463 relevance: COMPLETION_RELEVANCE_LOW, 1463 relevance: DART_RELEVANCE_LOW,
1464 isDeprecated: true); 1464 isDeprecated: true);
1465 if (suggestionA != null) { 1465 if (suggestionA != null) {
1466 expect(suggestionA.element.isDeprecated, isTrue); 1466 expect(suggestionA.element.isDeprecated, isTrue);
1467 expect(suggestionA.element.isPrivate, isFalse); 1467 expect(suggestionA.element.isPrivate, isFalse);
1468 } 1468 }
1469 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); 1469 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B');
1470 if (suggestionB != null) { 1470 if (suggestionB != null) {
1471 expect(suggestionB.element.isDeprecated, isFalse); 1471 expect(suggestionB.element.isDeprecated, isFalse);
1472 expect(suggestionB.element.isPrivate, isTrue); 1472 expect(suggestionB.element.isPrivate, isTrue);
1473 } 1473 }
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 expect(request.replacementOffset, completionOffset); 2094 expect(request.replacementOffset, completionOffset);
2095 expect(request.replacementLength, 0); 2095 expect(request.replacementLength, 0);
2096 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); 2096 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z');
2097 if (methodA != null) { 2097 if (methodA != null) {
2098 expect(methodA.element.isDeprecated, isFalse); 2098 expect(methodA.element.isDeprecated, isFalse);
2099 expect(methodA.element.isPrivate, isFalse); 2099 expect(methodA.element.isPrivate, isFalse);
2100 } 2100 }
2101 CompletionSuggestion getterF = assertSuggestLocalGetter( 2101 CompletionSuggestion getterF = assertSuggestLocalGetter(
2102 'f', 2102 'f',
2103 'X', 2103 'X',
2104 relevance: COMPLETION_RELEVANCE_LOW, 2104 relevance: DART_RELEVANCE_LOW,
2105 deprecated: true); 2105 deprecated: true);
2106 if (getterF != null) { 2106 if (getterF != null) {
2107 expect(getterF.element.isDeprecated, isTrue); 2107 expect(getterF.element.isDeprecated, isTrue);
2108 expect(getterF.element.isPrivate, isFalse); 2108 expect(getterF.element.isPrivate, isFalse);
2109 } 2109 }
2110 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); 2110 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null);
2111 if (getterG != null) { 2111 if (getterG != null) {
2112 expect(getterG.element.isDeprecated, isFalse); 2112 expect(getterG.element.isDeprecated, isFalse);
2113 expect(getterG.element.isPrivate, isTrue); 2113 expect(getterG.element.isPrivate, isTrue);
2114 } 2114 }
2115 }); 2115 });
2116 } 2116 }
2117 2117
2118 test_MethodDeclaration_members() { 2118 test_MethodDeclaration_members() {
2119 // Block BlockFunctionBody MethodDeclaration 2119 // Block BlockFunctionBody MethodDeclaration
2120 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); 2120 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}');
2121 computeFast(); 2121 computeFast();
2122 return computeFull((bool result) { 2122 return computeFull((bool result) {
2123 expect(request.replacementOffset, completionOffset); 2123 expect(request.replacementOffset, completionOffset);
2124 expect(request.replacementLength, 0); 2124 expect(request.replacementLength, 0);
2125 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); 2125 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z');
2126 if (methodA != null) { 2126 if (methodA != null) {
2127 expect(methodA.element.isDeprecated, isFalse); 2127 expect(methodA.element.isDeprecated, isFalse);
2128 expect(methodA.element.isPrivate, isTrue); 2128 expect(methodA.element.isPrivate, isTrue);
2129 } 2129 }
2130 CompletionSuggestion getterF = assertSuggestLocalField( 2130 CompletionSuggestion getterF = assertSuggestLocalField(
2131 'f', 2131 'f',
2132 'X', 2132 'X',
2133 relevance: COMPLETION_RELEVANCE_LOW, 2133 relevance: DART_RELEVANCE_LOW,
2134 deprecated: true); 2134 deprecated: true);
2135 if (getterF != null) { 2135 if (getterF != null) {
2136 expect(getterF.element.isDeprecated, isTrue); 2136 expect(getterF.element.isDeprecated, isTrue);
2137 expect(getterF.element.isPrivate, isFalse); 2137 expect(getterF.element.isPrivate, isFalse);
2138 expect(getterF.element.parameters, isNull); 2138 expect(getterF.element.parameters, isNull);
2139 } 2139 }
2140 CompletionSuggestion getterG = assertSuggestLocalField('_g', null); 2140 CompletionSuggestion getterG = assertSuggestLocalField('_g', null);
2141 if (getterG != null) { 2141 if (getterG != null) {
2142 expect(getterG.element.isDeprecated, isFalse); 2142 expect(getterG.element.isDeprecated, isFalse);
2143 expect(getterG.element.isPrivate, isTrue); 2143 expect(getterG.element.isPrivate, isTrue);
2144 expect(getterF.element.parameters, isNull); 2144 expect(getterF.element.parameters, isNull);
2145 } 2145 }
2146 assertSuggestImportedClass('bool'); 2146 assertSuggestImportedClass('bool');
2147 }); 2147 });
2148 } 2148 }
2149 2149
2150 test_MethodDeclaration_parameters_named() { 2150 test_MethodDeclaration_parameters_named() {
2151 // Block BlockFunctionBody MethodDeclaration 2151 // Block BlockFunctionBody MethodDeclaration
2152 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); 2152 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}');
2153 computeFast(); 2153 computeFast();
2154 return computeFull((bool result) { 2154 return computeFull((bool result) {
2155 expect(request.replacementOffset, completionOffset); 2155 expect(request.replacementOffset, completionOffset);
2156 expect(request.replacementLength, 0); 2156 expect(request.replacementLength, 0);
2157 CompletionSuggestion methodA = assertSuggestLocalMethod( 2157 CompletionSuggestion methodA = assertSuggestLocalMethod(
2158 'a', 2158 'a',
2159 'A', 2159 'A',
2160 'Z', 2160 'Z',
2161 relevance: COMPLETION_RELEVANCE_LOW, 2161 relevance: DART_RELEVANCE_LOW,
2162 deprecated: true); 2162 deprecated: true);
2163 if (methodA != null) { 2163 if (methodA != null) {
2164 expect(methodA.element.isDeprecated, isTrue); 2164 expect(methodA.element.isDeprecated, isTrue);
2165 expect(methodA.element.isPrivate, isFalse); 2165 expect(methodA.element.isPrivate, isFalse);
2166 } 2166 }
2167 assertSuggestParameter('x', 'X'); 2167 assertSuggestParameter('x', 'X');
2168 assertSuggestParameter('y', null); 2168 assertSuggestParameter('y', null);
2169 assertSuggestParameter('b', null); 2169 assertSuggestParameter('b', null);
2170 assertSuggestImportedClass('int'); 2170 assertSuggestImportedClass('int');
2171 assertNotSuggested('_'); 2171 assertNotSuggested('_');
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 assertNotSuggested('bar2'); 2696 assertNotSuggested('bar2');
2697 assertNotSuggested('_B'); 2697 assertNotSuggested('_B');
2698 assertSuggestLocalClass('Y'); 2698 assertSuggestLocalClass('Y');
2699 assertSuggestLocalClass('C'); 2699 assertSuggestLocalClass('C');
2700 assertSuggestLocalVariable('f', null); 2700 assertSuggestLocalVariable('f', null);
2701 assertNotSuggested('x'); 2701 assertNotSuggested('x');
2702 assertNotSuggested('e'); 2702 assertNotSuggested('e');
2703 }); 2703 });
2704 } 2704 }
2705 } 2705 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698