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

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

Issue 845553005: Change code completion relevance from CompletionRelevance.LOW/DEFAULT/HIGH to int (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 (CompletionSuggestion cs) => cs.completion == completion, 91 (CompletionSuggestion cs) => cs.completion == completion,
92 orElse: () => null); 92 orElse: () => null);
93 if (suggestion != null) { 93 if (suggestion != null) {
94 failedCompletion('did not expect completion: $completion\n $suggestion'); 94 failedCompletion('did not expect completion: $completion\n $suggestion');
95 } 95 }
96 return null; 96 return null;
97 } 97 }
98 98
99 CompletionSuggestion assertSuggest(String completion, 99 CompletionSuggestion assertSuggest(String completion,
100 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION, 100 {CompletionSuggestionKind csKind: CompletionSuggestionKind.INVOCATION,
101 CompletionRelevance relevance: CompletionRelevance.DEFAULT, 101 int relevance: COMPLETION_RELEVANCE_DEFAULT,
102 protocol.ElementKind elemKind: null, bool isDeprecated: false, bool isPote ntial: 102 protocol.ElementKind elemKind: null, bool isDeprecated: false, bool isPote ntial:
103 false}) { 103 false}) {
104 CompletionSuggestion cs = 104 CompletionSuggestion cs =
105 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind); 105 getSuggest(completion: completion, csKind: csKind, elemKind: elemKind);
106 if (cs == null) { 106 if (cs == null) {
107 failedCompletion('expected $completion $csKind', request.suggestions); 107 failedCompletion('expected $completion $csKind', request.suggestions);
108 } 108 }
109 expect(cs.kind, equals(csKind)); 109 expect(cs.kind, equals(csKind));
110 if (isDeprecated) { 110 if (isDeprecated) {
111 expect(cs.relevance, equals(CompletionRelevance.LOW)); 111 expect(cs.relevance, equals(COMPLETION_RELEVANCE_LOW));
112 } else { 112 } else {
113 expect(cs.relevance, equals(relevance)); 113 expect(cs.relevance, equals(relevance));
114 } 114 }
115 expect(cs.selectionOffset, equals(completion.length)); 115 expect(cs.selectionOffset, equals(completion.length));
116 expect(cs.selectionLength, equals(0)); 116 expect(cs.selectionLength, equals(0));
117 expect(cs.isDeprecated, equals(isDeprecated)); 117 expect(cs.isDeprecated, equals(isDeprecated));
118 expect(cs.isPotential, equals(isPotential)); 118 expect(cs.isPotential, equals(isPotential));
119 return cs; 119 return cs;
120 } 120 }
121 121
122 void assertSuggestArgumentList(List<String> paramNames, 122 void assertSuggestArgumentList(List<String> paramNames,
123 List<String> paramTypes) { 123 List<String> paramTypes) {
124 CompletionSuggestionKind csKind = CompletionSuggestionKind.ARGUMENT_LIST; 124 CompletionSuggestionKind csKind = CompletionSuggestionKind.ARGUMENT_LIST;
125 CompletionSuggestion cs = getSuggest(csKind: csKind); 125 CompletionSuggestion cs = getSuggest(csKind: csKind);
126 if (cs == null) { 126 if (cs == null) {
127 failedCompletion('expected completion $csKind', request.suggestions); 127 failedCompletion('expected completion $csKind', request.suggestions);
128 } 128 }
129 assertSuggestArgumentList_params( 129 assertSuggestArgumentList_params(
130 paramNames, 130 paramNames,
131 paramTypes, 131 paramTypes,
132 cs.parameterNames, 132 cs.parameterNames,
133 cs.parameterTypes); 133 cs.parameterTypes);
134 expect(cs.relevance, CompletionRelevance.HIGH); 134 expect(cs.relevance, COMPLETION_RELEVANCE_HIGH);
135 } 135 }
136 136
137 void assertSuggestArgumentList_params(List<String> expectedNames, 137 void assertSuggestArgumentList_params(List<String> expectedNames,
138 List<String> expectedTypes, List<String> actualNames, 138 List<String> expectedTypes, List<String> actualNames,
139 List<String> actualTypes) { 139 List<String> actualTypes) {
140 if (actualNames != null && 140 if (actualNames != null &&
141 actualNames.length == expectedNames.length && 141 actualNames.length == expectedNames.length &&
142 actualTypes != null && 142 actualTypes != null &&
143 actualTypes.length == expectedTypes.length) { 143 actualTypes.length == expectedTypes.length) {
144 int index = 0; 144 int index = 0;
(...skipping 11 matching lines...) Expand all
156 StringBuffer msg = new StringBuffer(); 156 StringBuffer msg = new StringBuffer();
157 msg.writeln('Argument list not the same'); 157 msg.writeln('Argument list not the same');
158 msg.writeln(' Expected names: $expectedNames'); 158 msg.writeln(' Expected names: $expectedNames');
159 msg.writeln(' found: $actualNames'); 159 msg.writeln(' found: $actualNames');
160 msg.writeln(' Expected types: $expectedTypes'); 160 msg.writeln(' Expected types: $expectedTypes');
161 msg.writeln(' found: $actualTypes'); 161 msg.writeln(' found: $actualTypes');
162 fail(msg.toString()); 162 fail(msg.toString());
163 } 163 }
164 164
165 CompletionSuggestion assertSuggestClass(String name, 165 CompletionSuggestion assertSuggestClass(String name,
166 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 166 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
167 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 167 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
168 CompletionSuggestion cs = 168 CompletionSuggestion cs =
169 assertSuggest(name, csKind: kind, relevance: relevance); 169 assertSuggest(name, csKind: kind, relevance: relevance);
170 protocol.Element element = cs.element; 170 protocol.Element element = cs.element;
171 expect(element, isNotNull); 171 expect(element, isNotNull);
172 expect(element.kind, equals(protocol.ElementKind.CLASS)); 172 expect(element.kind, equals(protocol.ElementKind.CLASS));
173 expect(element.name, equals(name)); 173 expect(element.name, equals(name));
174 expect(element.parameters, isNull); 174 expect(element.parameters, isNull);
175 expect(element.returnType, isNull); 175 expect(element.returnType, isNull);
176 return cs; 176 return cs;
177 } 177 }
178 178
179 CompletionSuggestion assertSuggestClassTypeAlias(String name, 179 CompletionSuggestion assertSuggestClassTypeAlias(String name,
180 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 180 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
181 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 181 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
182 CompletionSuggestion cs = 182 CompletionSuggestion cs =
183 assertSuggest(name, csKind: kind, relevance: relevance); 183 assertSuggest(name, csKind: kind, relevance: relevance);
184 protocol.Element element = cs.element; 184 protocol.Element element = cs.element;
185 expect(element, isNotNull); 185 expect(element, isNotNull);
186 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); 186 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS));
187 expect(element.name, equals(name)); 187 expect(element.name, equals(name));
188 expect(element.parameters, isNull); 188 expect(element.parameters, isNull);
189 expect(element.returnType, isNull); 189 expect(element.returnType, isNull);
190 return cs; 190 return cs;
191 } 191 }
192 192
193 CompletionSuggestion assertSuggestField(String name, 193 CompletionSuggestion assertSuggestField(String name,
194 {CompletionRelevance relevance: CompletionRelevance.DEFAULT, 194 {int relevance: COMPLETION_RELEVANCE_DEFAULT,
195 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 195 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
196 bool isDeprecated: false}) { 196 bool isDeprecated: false}) {
197 CompletionSuggestion cs = assertSuggest( 197 CompletionSuggestion cs = assertSuggest(
198 name, 198 name,
199 csKind: kind, 199 csKind: kind,
200 relevance: relevance, 200 relevance: relevance,
201 elemKind: protocol.ElementKind.FIELD, 201 elemKind: protocol.ElementKind.FIELD,
202 isDeprecated: isDeprecated); 202 isDeprecated: isDeprecated);
203 expect(cs.returnType, isNull); 203 expect(cs.returnType, isNull);
204 protocol.Element element = cs.element; 204 protocol.Element element = cs.element;
205 expect(element, isNotNull); 205 expect(element, isNotNull);
206 expect(element.kind, equals(protocol.ElementKind.FIELD)); 206 expect(element.kind, equals(protocol.ElementKind.FIELD));
207 expect(element.name, equals(name)); 207 expect(element.name, equals(name));
208 expect(element.parameters, isNull); 208 expect(element.parameters, isNull);
209 // TODO (danrubel) return type should be null and there should be 209 // TODO (danrubel) return type should be null and there should be
210 // something that represents the type of the field 210 // something that represents the type of the field
211 if (element.returnType != null) { 211 if (element.returnType != null) {
212 expect(element.returnType, 'dynamic'); 212 expect(element.returnType, 'dynamic');
213 } 213 }
214 return cs; 214 return cs;
215 } 215 }
216 216
217 CompletionSuggestion assertSuggestFunction(String name, String returnType, 217 CompletionSuggestion assertSuggestFunction(String name, String returnType,
218 bool isDeprecated, [CompletionRelevance relevance = CompletionRelevance.DE FAULT, 218 bool isDeprecated, [int relevance = COMPLETION_RELEVANCE_DEFAULT,
219 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 219 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
220 CompletionSuggestion cs = assertSuggest( 220 CompletionSuggestion cs = assertSuggest(
221 name, 221 name,
222 csKind: kind, 222 csKind: kind,
223 relevance: relevance, 223 relevance: relevance,
224 isDeprecated: isDeprecated); 224 isDeprecated: isDeprecated);
225 expect(cs.returnType, equals(returnType)); 225 expect(cs.returnType, equals(returnType));
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.FUNCTION)); 228 expect(element.kind, equals(protocol.ElementKind.FUNCTION));
229 expect(element.name, equals(name)); 229 expect(element.name, equals(name));
230 expect(element.isDeprecated, equals(isDeprecated)); 230 expect(element.isDeprecated, equals(isDeprecated));
231 String param = element.parameters; 231 String param = element.parameters;
232 expect(param, isNotNull); 232 expect(param, isNotNull);
233 expect(param[0], equals('(')); 233 expect(param[0], equals('('));
234 expect(param[param.length - 1], equals(')')); 234 expect(param[param.length - 1], equals(')'));
235 expect( 235 expect(
236 element.returnType, 236 element.returnType,
237 equals(returnType != null ? returnType : 'dynamic')); 237 equals(returnType != null ? returnType : 'dynamic'));
238 return cs; 238 return cs;
239 } 239 }
240 240
241 CompletionSuggestion assertSuggestFunctionTypeAlias(String name, 241 CompletionSuggestion assertSuggestFunctionTypeAlias(String name,
242 String returnType, bool isDeprecated, [CompletionRelevance relevance = 242 String returnType, bool isDeprecated, [int relevance =
243 CompletionRelevance.DEFAULT, CompletionSuggestionKind kind = 243 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
244 CompletionSuggestionKind.INVOCATION]) { 244 CompletionSuggestionKind.INVOCATION]) {
245 CompletionSuggestion cs = assertSuggest( 245 CompletionSuggestion cs = assertSuggest(
246 name, 246 name,
247 csKind: kind, 247 csKind: kind,
248 relevance: relevance, 248 relevance: relevance,
249 isDeprecated: isDeprecated); 249 isDeprecated: isDeprecated);
250 expect(cs.returnType, equals(returnType)); 250 expect(cs.returnType, equals(returnType));
251 protocol.Element element = cs.element; 251 protocol.Element element = cs.element;
252 expect(element, isNotNull); 252 expect(element, isNotNull);
253 expect(element.kind, equals(protocol.ElementKind.FUNCTION_TYPE_ALIAS)); 253 expect(element.kind, equals(protocol.ElementKind.FUNCTION_TYPE_ALIAS));
254 expect(element.name, equals(name)); 254 expect(element.name, equals(name));
255 expect(element.isDeprecated, equals(isDeprecated)); 255 expect(element.isDeprecated, equals(isDeprecated));
256 // TODO (danrubel) Determine why params are null 256 // TODO (danrubel) Determine why params are null
257 // String param = element.parameters; 257 // String param = element.parameters;
258 // expect(param, isNotNull); 258 // expect(param, isNotNull);
259 // expect(param[0], equals('(')); 259 // expect(param[0], equals('('));
260 // expect(param[param.length - 1], equals(')')); 260 // expect(param[param.length - 1], equals(')'));
261 // TODO (danrubel) Determine why return type is null 261 // TODO (danrubel) Determine why return type is null
262 // expect( 262 // expect(
263 // element.returnType, 263 // element.returnType,
264 // equals(returnType != null ? returnType : 'dynamic')); 264 // equals(returnType != null ? returnType : 'dynamic'));
265 return cs; 265 return cs;
266 } 266 }
267 267
268 CompletionSuggestion assertSuggestGetter(String name, String returnType, 268 CompletionSuggestion assertSuggestGetter(String name, String returnType,
269 {CompletionRelevance relevance: CompletionRelevance.DEFAULT, 269 {int relevance: COMPLETION_RELEVANCE_DEFAULT,
270 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, 270 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION,
271 bool isDeprecated: false}) { 271 bool isDeprecated: false}) {
272 CompletionSuggestion cs = assertSuggest( 272 CompletionSuggestion cs = assertSuggest(
273 name, 273 name,
274 csKind: kind, 274 csKind: kind,
275 relevance: relevance, 275 relevance: relevance,
276 elemKind: protocol.ElementKind.GETTER, 276 elemKind: protocol.ElementKind.GETTER,
277 isDeprecated: isDeprecated); 277 isDeprecated: isDeprecated);
278 expect(cs.returnType, equals(returnType)); 278 expect(cs.returnType, equals(returnType));
279 protocol.Element element = cs.element; 279 protocol.Element element = cs.element;
280 expect(element, isNotNull); 280 expect(element, isNotNull);
281 expect(element.kind, equals(protocol.ElementKind.GETTER)); 281 expect(element.kind, equals(protocol.ElementKind.GETTER));
282 expect(element.name, equals(name)); 282 expect(element.name, equals(name));
283 //TODO (danrubel) getter should have parameters 283 //TODO (danrubel) getter should have parameters
284 // but not used in code completion 284 // but not used in code completion
285 //expect(element.parameters, '()'); 285 //expect(element.parameters, '()');
286 expect( 286 expect(
287 element.returnType, 287 element.returnType,
288 equals(returnType != null ? returnType : 'dynamic')); 288 equals(returnType != null ? returnType : 'dynamic'));
289 return cs; 289 return cs;
290 } 290 }
291 291
292 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, 292 CompletionSuggestion assertSuggestLibraryPrefix(String prefix,
293 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 293 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
294 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 294 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
295 // Library prefix should only be suggested by ImportedComputer 295 // Library prefix should only be suggested by ImportedComputer
296 if (computer is ImportedComputer) { 296 if (computer is ImportedComputer) {
297 CompletionSuggestion cs = 297 CompletionSuggestion cs =
298 assertSuggest(prefix, csKind: kind, relevance: relevance); 298 assertSuggest(prefix, csKind: kind, relevance: relevance);
299 protocol.Element element = cs.element; 299 protocol.Element element = cs.element;
300 expect(element, isNotNull); 300 expect(element, isNotNull);
301 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); 301 expect(element.kind, equals(protocol.ElementKind.LIBRARY));
302 expect(element.parameters, isNull); 302 expect(element.parameters, isNull);
303 expect(element.returnType, isNull); 303 expect(element.returnType, isNull);
304 return cs; 304 return cs;
305 } else { 305 } else {
306 return assertNotSuggested(prefix); 306 return assertNotSuggested(prefix);
307 } 307 }
308 } 308 }
309 309
310 CompletionSuggestion assertSuggestLocalVariable(String name, 310 CompletionSuggestion assertSuggestLocalVariable(String name,
311 String returnType, [CompletionRelevance relevance = CompletionRelevance.DE FAULT, 311 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT,
312 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 312 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
313 // Local variables should only be suggested by LocalComputer 313 // Local variables should only be suggested by LocalComputer
314 if (computer is LocalComputer) { 314 if (computer is LocalComputer) {
315 CompletionSuggestion cs = 315 CompletionSuggestion cs =
316 assertSuggest(name, csKind: kind, relevance: relevance); 316 assertSuggest(name, csKind: kind, relevance: relevance);
317 expect(cs.returnType, equals(returnType)); 317 expect(cs.returnType, equals(returnType));
318 protocol.Element element = cs.element; 318 protocol.Element element = cs.element;
319 expect(element, isNotNull); 319 expect(element, isNotNull);
320 expect(element.kind, equals(protocol.ElementKind.LOCAL_VARIABLE)); 320 expect(element.kind, equals(protocol.ElementKind.LOCAL_VARIABLE));
321 expect(element.name, equals(name)); 321 expect(element.name, equals(name));
322 expect(element.parameters, isNull); 322 expect(element.parameters, isNull);
323 expect( 323 expect(
324 element.returnType, 324 element.returnType,
325 equals(returnType != null ? returnType : 'dynamic')); 325 equals(returnType != null ? returnType : 'dynamic'));
326 return cs; 326 return cs;
327 } else { 327 } else {
328 return assertNotSuggested(name); 328 return assertNotSuggested(name);
329 } 329 }
330 } 330 }
331 331
332 CompletionSuggestion assertSuggestMethod(String name, String declaringType, 332 CompletionSuggestion assertSuggestMethod(String name, String declaringType,
333 String returnType, [CompletionRelevance relevance = CompletionRelevance.DE FAULT, 333 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT,
334 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 334 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
335 CompletionSuggestion cs = 335 CompletionSuggestion cs =
336 assertSuggest(name, csKind: kind, relevance: relevance); 336 assertSuggest(name, csKind: kind, relevance: relevance);
337 expect(cs.declaringType, equals(declaringType)); 337 expect(cs.declaringType, equals(declaringType));
338 expect(cs.returnType, equals(returnType)); 338 expect(cs.returnType, equals(returnType));
339 protocol.Element element = cs.element; 339 protocol.Element element = cs.element;
340 expect(element, isNotNull); 340 expect(element, isNotNull);
341 expect(element.kind, equals(protocol.ElementKind.METHOD)); 341 expect(element.kind, equals(protocol.ElementKind.METHOD));
342 expect(element.name, equals(name)); 342 expect(element.name, equals(name));
343 String param = element.parameters; 343 String param = element.parameters;
344 expect(param, isNotNull); 344 expect(param, isNotNull);
345 expect(param[0], equals('(')); 345 expect(param[0], equals('('));
346 expect(param[param.length - 1], equals(')')); 346 expect(param[param.length - 1], equals(')'));
347 expect( 347 expect(
348 element.returnType, 348 element.returnType,
349 equals(returnType != null ? returnType : 'dynamic')); 349 equals(returnType != null ? returnType : 'dynamic'));
350 return cs; 350 return cs;
351 } 351 }
352 352
353 CompletionSuggestion assertSuggestNamedConstructor(String name, 353 CompletionSuggestion assertSuggestNamedConstructor(String name,
354 String returnType, [CompletionRelevance relevance = CompletionRelevance.DE FAULT, 354 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT,
355 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 355 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
356 if (computer is InvocationComputer) { 356 if (computer is InvocationComputer) {
357 CompletionSuggestion cs = 357 CompletionSuggestion cs =
358 assertSuggest(name, csKind: kind, relevance: relevance); 358 assertSuggest(name, csKind: kind, relevance: relevance);
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.CONSTRUCTOR)); 361 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR));
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, equals(returnType)); 367 expect(element.returnType, equals(returnType));
368 return cs; 368 return cs;
369 } else { 369 } else {
370 return assertNotSuggested(name); 370 return assertNotSuggested(name);
371 } 371 }
372 } 372 }
373 373
374 CompletionSuggestion assertSuggestParameter(String name, String returnType, 374 CompletionSuggestion assertSuggestParameter(String name, String returnType,
375 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 375 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
376 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 376 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
377 // Parameters should only be suggested by LocalComputer 377 // Parameters should only be suggested by LocalComputer
378 if (computer is LocalComputer) { 378 if (computer is LocalComputer) {
379 CompletionSuggestion cs = 379 CompletionSuggestion cs =
380 assertSuggest(name, csKind: kind, relevance: relevance); 380 assertSuggest(name, csKind: kind, relevance: relevance);
381 expect(cs.returnType, equals(returnType)); 381 expect(cs.returnType, equals(returnType));
382 protocol.Element element = cs.element; 382 protocol.Element element = cs.element;
383 expect(element, isNotNull); 383 expect(element, isNotNull);
384 expect(element.kind, equals(protocol.ElementKind.PARAMETER)); 384 expect(element.kind, equals(protocol.ElementKind.PARAMETER));
385 expect(element.name, equals(name)); 385 expect(element.name, equals(name));
386 expect(element.parameters, isNull); 386 expect(element.parameters, isNull);
387 expect( 387 expect(
388 element.returnType, 388 element.returnType,
389 equals(returnType != null ? returnType : 'dynamic')); 389 equals(returnType != null ? returnType : 'dynamic'));
390 return cs; 390 return cs;
391 } else { 391 } else {
392 return assertNotSuggested(name); 392 return assertNotSuggested(name);
393 } 393 }
394 } 394 }
395 395
396 CompletionSuggestion assertSuggestSetter(String name, 396 CompletionSuggestion assertSuggestSetter(String name,
397 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 397 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
398 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 398 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
399 CompletionSuggestion cs = assertSuggest( 399 CompletionSuggestion cs = assertSuggest(
400 name, 400 name,
401 csKind: kind, 401 csKind: kind,
402 relevance: relevance, 402 relevance: relevance,
403 elemKind: protocol.ElementKind.SETTER); 403 elemKind: protocol.ElementKind.SETTER);
404 protocol.Element element = cs.element; 404 protocol.Element element = cs.element;
405 expect(element, isNotNull); 405 expect(element, isNotNull);
406 expect(element.kind, equals(protocol.ElementKind.SETTER)); 406 expect(element.kind, equals(protocol.ElementKind.SETTER));
407 expect(element.name, equals(name)); 407 expect(element.name, equals(name));
408 // TODO (danrubel) assert setter param 408 // TODO (danrubel) assert setter param
409 //expect(element.parameters, isNull); 409 //expect(element.parameters, isNull);
410 // TODO (danrubel) it would be better if this was always null 410 // TODO (danrubel) it would be better if this was always null
411 if (element.returnType != null) { 411 if (element.returnType != null) {
412 expect(element.returnType, 'dynamic'); 412 expect(element.returnType, 'dynamic');
413 } 413 }
414 return cs; 414 return cs;
415 } 415 }
416 416
417 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, 417 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType,
418 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 418 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
419 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 419 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
420 CompletionSuggestion cs = 420 CompletionSuggestion cs =
421 assertSuggest(name, csKind: kind, relevance: relevance); 421 assertSuggest(name, csKind: kind, relevance: relevance);
422 expect(cs.returnType, equals(returnType)); 422 expect(cs.returnType, equals(returnType));
423 protocol.Element element = cs.element; 423 protocol.Element element = cs.element;
424 expect(element, isNotNull); 424 expect(element, isNotNull);
425 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); 425 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE));
426 expect(element.name, equals(name)); 426 expect(element.name, equals(name));
427 expect(element.parameters, isNull); 427 expect(element.parameters, isNull);
428 //TODO (danrubel) return type level variable 'type' but not as 'returnType' 428 //TODO (danrubel) return type level variable 'type' but not as 'returnType'
429 // expect( 429 // expect(
430 // element.returnType, 430 // element.returnType,
431 // equals(returnType != null ? returnType : 'dynamic')); 431 // equals(returnType != null ? returnType : 'dynamic'));
432 return cs; 432 return cs;
433 } 433 }
434 434
435 void assertSuggestTopLevelVarGetterSetter(String name, String returnType, 435 void assertSuggestTopLevelVarGetterSetter(String name, String returnType,
436 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 436 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
437 if (computer is ImportedComputer) { 437 if (computer is ImportedComputer) {
438 assertSuggestGetter(name, returnType); 438 assertSuggestGetter(name, returnType);
439 assertSuggestSetter(name); 439 assertSuggestSetter(name);
440 } else { 440 } else {
441 assertNotSuggested(name); 441 assertNotSuggested(name);
442 } 442 }
443 } 443 }
444 444
445 bool computeFast() { 445 bool computeFast() {
446 _computeFastCalled = true; 446 _computeFastCalled = true;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 584
585 /** 585 /**
586 * Assert that the ImportedComputer uses cached results to produce identical 586 * Assert that the ImportedComputer uses cached results to produce identical
587 * suggestions to the original set of suggestions. 587 * suggestions to the original set of suggestions.
588 */ 588 */
589 void assertCachedCompute(_) { 589 void assertCachedCompute(_) {
590 // Subclasses override 590 // Subclasses override
591 } 591 }
592 592
593 CompletionSuggestion assertLocalSuggestMethod(String name, 593 CompletionSuggestion assertLocalSuggestMethod(String name,
594 String declaringType, String returnType, [CompletionRelevance relevance = 594 String declaringType, String returnType, [int relevance =
595 CompletionRelevance.DEFAULT]) { 595 COMPLETION_RELEVANCE_DEFAULT]) {
596 if (computer is LocalComputer) { 596 if (computer is LocalComputer) {
597 return assertSuggestMethod(name, declaringType, returnType, relevance); 597 return assertSuggestMethod(name, declaringType, returnType, relevance);
598 } else { 598 } else {
599 return assertNotSuggested(name); 599 return assertNotSuggested(name);
600 } 600 }
601 } 601 }
602 602
603 CompletionSuggestion assertSuggestImportedClass(String name, 603 CompletionSuggestion assertSuggestImportedClass(String name,
604 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 604 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
605 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 605 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
606 if (computer is ImportedComputer) { 606 if (computer is ImportedComputer) {
607 return assertSuggestClass(name, relevance, kind); 607 return assertSuggestClass(name, relevance, kind);
608 } else { 608 } else {
609 return assertNotSuggested(name); 609 return assertNotSuggested(name);
610 } 610 }
611 } 611 }
612 612
613 CompletionSuggestion assertSuggestImportedField(String name, 613 CompletionSuggestion assertSuggestImportedField(String name,
614 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 614 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
615 if (computer is ImportedComputer) { 615 if (computer is ImportedComputer) {
616 return assertSuggestField(name, relevance: relevance); 616 return assertSuggestField(name, relevance: relevance);
617 } else { 617 } else {
618 return assertNotSuggested(name); 618 return assertNotSuggested(name);
619 } 619 }
620 } 620 }
621 621
622 CompletionSuggestion assertSuggestImportedFunction(String name, 622 CompletionSuggestion assertSuggestImportedFunction(String name,
623 String returnType, [bool isDeprecated = false, CompletionRelevance relevan ce = 623 String returnType, [bool isDeprecated = false, int relevance =
624 CompletionRelevance.DEFAULT, CompletionSuggestionKind kind = 624 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
625 CompletionSuggestionKind.INVOCATION]) { 625 CompletionSuggestionKind.INVOCATION]) {
626 if (computer is ImportedComputer) { 626 if (computer is ImportedComputer) {
627 return assertSuggestFunction( 627 return assertSuggestFunction(
628 name, 628 name,
629 returnType, 629 returnType,
630 isDeprecated, 630 isDeprecated,
631 relevance, 631 relevance,
632 kind); 632 kind);
633 } else { 633 } else {
634 return assertNotSuggested(name); 634 return assertNotSuggested(name);
635 } 635 }
636 } 636 }
637 637
638 CompletionSuggestion assertSuggestImportedFunctionTypeAlias(String name, 638 CompletionSuggestion assertSuggestImportedFunctionTypeAlias(String name,
639 String returnType, [bool isDeprecated = false, CompletionRelevance relevan ce = 639 String returnType, [bool isDeprecated = false, int relevance =
640 CompletionRelevance.DEFAULT, CompletionSuggestionKind kind = 640 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind =
641 CompletionSuggestionKind.INVOCATION]) { 641 CompletionSuggestionKind.INVOCATION]) {
642 if (computer is ImportedComputer) { 642 if (computer is ImportedComputer) {
643 return assertSuggestFunctionTypeAlias( 643 return assertSuggestFunctionTypeAlias(
644 name, 644 name,
645 returnType, 645 returnType,
646 isDeprecated, 646 isDeprecated,
647 relevance, 647 relevance,
648 kind); 648 kind);
649 } else { 649 } else {
650 return assertNotSuggested(name); 650 return assertNotSuggested(name);
651 } 651 }
652 } 652 }
653 653
654 CompletionSuggestion assertSuggestImportedGetter(String name, 654 CompletionSuggestion assertSuggestImportedGetter(String name,
655 String returnType, [CompletionRelevance relevance = 655 String returnType, [int relevance =
656 CompletionRelevance.DEFAULT]) { 656 COMPLETION_RELEVANCE_DEFAULT]) {
657 if (computer is ImportedComputer) { 657 if (computer is ImportedComputer) {
658 return assertSuggestGetter(name, returnType, relevance: relevance); 658 return assertSuggestGetter(name, returnType, relevance: relevance);
659 } else { 659 } else {
660 return assertNotSuggested(name); 660 return assertNotSuggested(name);
661 } 661 }
662 } 662 }
663 663
664 CompletionSuggestion assertSuggestImportedMethod(String name, 664 CompletionSuggestion assertSuggestImportedMethod(String name,
665 String declaringType, String returnType, [CompletionRelevance relevance = 665 String declaringType, String returnType, [int relevance =
666 CompletionRelevance.DEFAULT]) { 666 COMPLETION_RELEVANCE_DEFAULT]) {
667 if (computer is ImportedComputer) { 667 if (computer is ImportedComputer) {
668 return assertSuggestMethod(name, declaringType, returnType, relevance); 668 return assertSuggestMethod(name, declaringType, returnType, relevance);
669 } else { 669 } else {
670 return assertNotSuggested(name); 670 return assertNotSuggested(name);
671 } 671 }
672 } 672 }
673 673
674 CompletionSuggestion assertSuggestImportedSetter(String name, 674 CompletionSuggestion assertSuggestImportedSetter(String name,
675 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 675 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
676 if (computer is ImportedComputer) { 676 if (computer is ImportedComputer) {
677 return assertSuggestSetter(name, relevance); 677 return assertSuggestSetter(name, relevance);
678 } else { 678 } else {
679 return assertNotSuggested(name); 679 return assertNotSuggested(name);
680 } 680 }
681 } 681 }
682 682
683 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, 683 CompletionSuggestion assertSuggestImportedTopLevelVar(String name,
684 String returnType, [CompletionRelevance relevance = CompletionRelevance.DE FAULT, 684 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT,
685 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 685 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
686 if (computer is ImportedComputer) { 686 if (computer is ImportedComputer) {
687 return assertSuggestTopLevelVar(name, returnType, relevance, kind); 687 return assertSuggestTopLevelVar(name, returnType, relevance, kind);
688 } else { 688 } else {
689 return assertNotSuggested(name); 689 return assertNotSuggested(name);
690 } 690 }
691 } 691 }
692 692
693 CompletionSuggestion assertSuggestInvocationClass(String name, 693 CompletionSuggestion assertSuggestInvocationClass(String name,
694 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 694 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
695 if (computer is InvocationComputer) { 695 if (computer is InvocationComputer) {
696 return assertSuggestClass(name, relevance); 696 return assertSuggestClass(name, relevance);
697 } else { 697 } else {
698 return assertNotSuggested(name); 698 return assertNotSuggested(name);
699 } 699 }
700 } 700 }
701 701
702 CompletionSuggestion assertSuggestInvocationGetter(String name, 702 CompletionSuggestion assertSuggestInvocationGetter(String name,
703 String returnType, {CompletionRelevance relevance: CompletionRelevance.DEF AULT, 703 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT,
704 bool isDeprecated: false}) { 704 bool isDeprecated: false}) {
705 if (computer is InvocationComputer) { 705 if (computer is InvocationComputer) {
706 return assertSuggestGetter( 706 return assertSuggestGetter(
707 name, 707 name,
708 returnType, 708 returnType,
709 relevance: relevance, 709 relevance: relevance,
710 isDeprecated: isDeprecated); 710 isDeprecated: isDeprecated);
711 } else { 711 } else {
712 return assertNotSuggested(name); 712 return assertNotSuggested(name);
713 } 713 }
714 } 714 }
715 715
716 CompletionSuggestion assertSuggestInvocationMethod(String name, 716 CompletionSuggestion assertSuggestInvocationMethod(String name,
717 String declaringType, String returnType, [CompletionRelevance relevance = 717 String declaringType, String returnType, [int relevance =
718 CompletionRelevance.DEFAULT]) { 718 COMPLETION_RELEVANCE_DEFAULT]) {
719 if (computer is InvocationComputer) { 719 if (computer is InvocationComputer) {
720 return assertSuggestMethod(name, declaringType, returnType, relevance); 720 return assertSuggestMethod(name, declaringType, returnType, relevance);
721 } else { 721 } else {
722 return assertNotSuggested(name); 722 return assertNotSuggested(name);
723 } 723 }
724 } 724 }
725 725
726 CompletionSuggestion assertSuggestInvocationSetter(String name, 726 CompletionSuggestion assertSuggestInvocationSetter(String name,
727 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 727 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
728 if (computer is InvocationComputer) { 728 if (computer is InvocationComputer) {
729 return assertSuggestSetter(name); 729 return assertSuggestSetter(name);
730 } else { 730 } else {
731 return assertNotSuggested(name); 731 return assertNotSuggested(name);
732 } 732 }
733 } 733 }
734 734
735 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name, 735 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name,
736 String returnType, [CompletionRelevance relevance = 736 String returnType, [int relevance =
737 CompletionRelevance.DEFAULT]) { 737 COMPLETION_RELEVANCE_DEFAULT]) {
738 if (computer is InvocationComputer) { 738 if (computer is InvocationComputer) {
739 return assertSuggestTopLevelVar(name, returnType, relevance); 739 return assertSuggestTopLevelVar(name, returnType, relevance);
740 } else { 740 } else {
741 return assertNotSuggested(name); 741 return assertNotSuggested(name);
742 } 742 }
743 } 743 }
744 744
745 CompletionSuggestion assertSuggestLocalClass(String name, 745 CompletionSuggestion assertSuggestLocalClass(String name,
746 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 746 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
747 if (computer is LocalComputer) { 747 if (computer is LocalComputer) {
748 return assertSuggestClass(name, relevance); 748 return assertSuggestClass(name, relevance);
749 } else { 749 } else {
750 return assertNotSuggested(name); 750 return assertNotSuggested(name);
751 } 751 }
752 } 752 }
753 753
754 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, 754 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name,
755 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 755 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
756 if (computer is LocalComputer) { 756 if (computer is LocalComputer) {
757 return assertSuggestClassTypeAlias(name, relevance); 757 return assertSuggestClassTypeAlias(name, relevance);
758 } else { 758 } else {
759 return assertNotSuggested(name); 759 return assertNotSuggested(name);
760 } 760 }
761 } 761 }
762 762
763 CompletionSuggestion assertSuggestLocalField(String name, 763 CompletionSuggestion assertSuggestLocalField(String name,
764 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 764 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
765 if (computer is LocalComputer) { 765 if (computer is LocalComputer) {
766 return assertSuggestField(name, relevance: relevance); 766 return assertSuggestField(name, relevance: relevance);
767 } else { 767 } else {
768 return assertNotSuggested(name); 768 return assertNotSuggested(name);
769 } 769 }
770 } 770 }
771 771
772 CompletionSuggestion assertSuggestLocalFunction(String name, 772 CompletionSuggestion assertSuggestLocalFunction(String name,
773 String returnType, [bool isDeprecated = false, CompletionRelevance relevan ce = 773 String returnType, [bool isDeprecated = false, int relevance =
774 CompletionRelevance.DEFAULT]) { 774 COMPLETION_RELEVANCE_DEFAULT]) {
775 if (computer is LocalComputer) { 775 if (computer is LocalComputer) {
776 return assertSuggestFunction(name, returnType, isDeprecated, relevance); 776 return assertSuggestFunction(name, returnType, isDeprecated, relevance);
777 } else { 777 } else {
778 return assertNotSuggested(name); 778 return assertNotSuggested(name);
779 } 779 }
780 } 780 }
781 781
782 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name, 782 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name,
783 String returnType, [bool isDeprecated = false, CompletionRelevance relevan ce = 783 String returnType, [bool isDeprecated = false, int relevance =
784 CompletionRelevance.DEFAULT]) { 784 COMPLETION_RELEVANCE_DEFAULT]) {
785 if (computer is LocalComputer) { 785 if (computer is LocalComputer) {
786 return assertSuggestFunctionTypeAlias( 786 return assertSuggestFunctionTypeAlias(
787 name, 787 name,
788 returnType, 788 returnType,
789 isDeprecated, 789 isDeprecated,
790 relevance); 790 relevance);
791 } else { 791 } else {
792 return assertNotSuggested(name); 792 return assertNotSuggested(name);
793 } 793 }
794 } 794 }
795 795
796 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, 796 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType,
797 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 797 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
798 if (computer is LocalComputer) { 798 if (computer is LocalComputer) {
799 return assertSuggestGetter(name, returnType, relevance: relevance); 799 return assertSuggestGetter(name, returnType, relevance: relevance);
800 } else { 800 } else {
801 return assertNotSuggested(name); 801 return assertNotSuggested(name);
802 } 802 }
803 } 803 }
804 804
805 CompletionSuggestion assertSuggestLocalMethod(String name, 805 CompletionSuggestion assertSuggestLocalMethod(String name,
806 String declaringType, String returnType, [CompletionRelevance relevance = 806 String declaringType, String returnType, [int relevance =
807 CompletionRelevance.DEFAULT]) { 807 COMPLETION_RELEVANCE_DEFAULT]) {
808 if (computer is LocalComputer) { 808 if (computer is LocalComputer) {
809 return assertSuggestMethod(name, declaringType, returnType, relevance); 809 return assertSuggestMethod(name, declaringType, returnType, relevance);
810 } else { 810 } else {
811 return assertNotSuggested(name); 811 return assertNotSuggested(name);
812 } 812 }
813 } 813 }
814 814
815 CompletionSuggestion assertSuggestLocalSetter(String name, 815 CompletionSuggestion assertSuggestLocalSetter(String name,
816 [CompletionRelevance relevance = CompletionRelevance.DEFAULT]) { 816 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) {
817 if (computer is LocalComputer) { 817 if (computer is LocalComputer) {
818 return assertSuggestSetter(name, relevance); 818 return assertSuggestSetter(name, relevance);
819 } else { 819 } else {
820 return assertNotSuggested(name); 820 return assertNotSuggested(name);
821 } 821 }
822 } 822 }
823 823
824 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, 824 CompletionSuggestion assertSuggestLocalTopLevelVar(String name,
825 String returnType, [CompletionRelevance relevance = 825 String returnType, [int relevance =
826 CompletionRelevance.DEFAULT]) { 826 COMPLETION_RELEVANCE_DEFAULT]) {
827 if (computer is LocalComputer) { 827 if (computer is LocalComputer) {
828 return assertSuggestTopLevelVar(name, returnType, relevance); 828 return assertSuggestTopLevelVar(name, returnType, relevance);
829 } else { 829 } else {
830 return assertNotSuggested(name); 830 return assertNotSuggested(name);
831 } 831 }
832 } 832 }
833 833
834 CompletionSuggestion assertSuggestNonLocalClass(String name, 834 CompletionSuggestion assertSuggestNonLocalClass(String name,
835 [CompletionRelevance relevance = CompletionRelevance.DEFAULT, 835 [int relevance = COMPLETION_RELEVANCE_DEFAULT,
836 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { 836 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) {
837 return assertSuggestImportedClass(name, relevance, kind); 837 return assertSuggestImportedClass(name, relevance, kind);
838 } 838 }
839 839
840 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) { 840 Future computeFull(assertFunction(bool result), {bool fullAnalysis: true}) {
841 return super.computeFull( 841 return super.computeFull(
842 assertFunction, 842 assertFunction,
843 fullAnalysis: fullAnalysis).then(assertCachedCompute); 843 fullAnalysis: fullAnalysis).then(assertCachedCompute);
844 } 844 }
845 845
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 assertSuggestLocalVariable('f', null); 1178 assertSuggestLocalVariable('f', null);
1179 // Don't suggest locals out of scope 1179 // Don't suggest locals out of scope
1180 assertNotSuggested('r'); 1180 assertNotSuggested('r');
1181 assertNotSuggested('x'); 1181 assertNotSuggested('x');
1182 1182
1183 assertSuggestImportedClass('A'); 1183 assertSuggestImportedClass('A');
1184 assertNotSuggested('_B'); 1184 assertNotSuggested('_B');
1185 assertSuggestImportedClass('C'); 1185 assertSuggestImportedClass('C');
1186 // hidden element suggested as low relevance 1186 // hidden element suggested as low relevance
1187 // but imported results are partially filtered 1187 // but imported results are partially filtered
1188 //assertSuggestImportedClass('D', CompletionRelevance.LOW); 1188 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW);
1189 //assertSuggestImportedFunction( 1189 //assertSuggestImportedFunction(
1190 // 'D1', null, true, CompletionRelevance.LOW); 1190 // 'D1', null, true, COMPLETION_RELEVANCE_LOW);
1191 assertSuggestLocalFunction('D2', 'Z'); 1191 assertSuggestLocalFunction('D2', 'Z');
1192 assertSuggestImportedClass('EE'); 1192 assertSuggestImportedClass('EE');
1193 // hidden element suggested as low relevance 1193 // hidden element suggested as low relevance
1194 //assertSuggestImportedClass('F', CompletionRelevance.LOW); 1194 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW);
1195 assertSuggestLibraryPrefix('g'); 1195 assertSuggestLibraryPrefix('g');
1196 assertNotSuggested('G'); 1196 assertNotSuggested('G');
1197 //assertSuggestImportedClass('H', CompletionRelevance.LOW); 1197 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW);
1198 assertSuggestImportedClass('Object'); 1198 assertSuggestImportedClass('Object');
1199 assertSuggestImportedFunction('min', 'num', false); 1199 assertSuggestImportedFunction('min', 'num', false);
1200 //assertSuggestImportedFunction( 1200 //assertSuggestImportedFunction(
1201 // 'max', 1201 // 'max',
1202 // 'num', 1202 // 'num',
1203 // false, 1203 // false,
1204 // CompletionRelevance.LOW); 1204 // COMPLETION_RELEVANCE_LOW);
1205 assertSuggestTopLevelVarGetterSetter('T1', 'String'); 1205 assertSuggestTopLevelVarGetterSetter('T1', 'String');
1206 assertNotSuggested('_T2'); 1206 assertNotSuggested('_T2');
1207 //assertSuggestImportedTopLevelVar('T3', 'int', CompletionRelevance.LOW); 1207 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW);
1208 assertNotSuggested('_T4'); 1208 assertNotSuggested('_T4');
1209 assertSuggestLocalTopLevelVar('T5', 'int'); 1209 assertSuggestLocalTopLevelVar('T5', 'int');
1210 assertSuggestLocalTopLevelVar('_T6', null); 1210 assertSuggestLocalTopLevelVar('_T6', null);
1211 assertNotSuggested('=='); 1211 assertNotSuggested('==');
1212 assertSuggestLocalGetter('T7', 'String'); 1212 assertSuggestLocalGetter('T7', 'String');
1213 assertSuggestLocalSetter('T8'); 1213 assertSuggestLocalSetter('T8');
1214 assertSuggestLocalGetter('clog', 'int'); 1214 assertSuggestLocalGetter('clog', 'int');
1215 assertSuggestLocalSetter('blog'); 1215 assertSuggestLocalSetter('blog');
1216 // TODO (danrubel) suggest HtmlElement as low relevance 1216 // TODO (danrubel) suggest HtmlElement as low relevance
1217 assertNotSuggested('HtmlElement'); 1217 assertNotSuggested('HtmlElement');
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 assertSuggestLocalVariable('f', null); 1257 assertSuggestLocalVariable('f', null);
1258 // Don't suggest locals out of scope 1258 // Don't suggest locals out of scope
1259 assertNotSuggested('r'); 1259 assertNotSuggested('r');
1260 assertNotSuggested('x'); 1260 assertNotSuggested('x');
1261 1261
1262 // imported elements are portially filtered 1262 // imported elements are portially filtered
1263 //assertSuggestImportedClass('A'); 1263 //assertSuggestImportedClass('A');
1264 assertNotSuggested('_B'); 1264 assertNotSuggested('_B');
1265 //assertSuggestImportedClass('C'); 1265 //assertSuggestImportedClass('C');
1266 // hidden element suggested as low relevance 1266 // hidden element suggested as low relevance
1267 assertSuggestImportedClass('D', CompletionRelevance.LOW); 1267 assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW);
1268 assertSuggestImportedFunction('D1', null, true, CompletionRelevance.LOW); 1268 assertSuggestImportedFunction('D1', null, true, COMPLETION_RELEVANCE_LOW);
1269 assertSuggestLocalFunction('D2', 'Z'); 1269 assertSuggestLocalFunction('D2', 'Z');
1270 //assertSuggestImportedClass('EE'); 1270 //assertSuggestImportedClass('EE');
1271 // hidden element suggested as low relevance 1271 // hidden element suggested as low relevance
1272 //assertSuggestImportedClass('F', CompletionRelevance.LOW); 1272 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW);
1273 //assertSuggestLibraryPrefix('g'); 1273 //assertSuggestLibraryPrefix('g');
1274 assertNotSuggested('G'); 1274 assertNotSuggested('G');
1275 //assertSuggestImportedClass('H', CompletionRelevance.LOW); 1275 //assertSuggestImportedClass('H', COMPLETION_RELEVANCE_LOW);
1276 //assertSuggestImportedClass('Object'); 1276 //assertSuggestImportedClass('Object');
1277 //assertSuggestImportedFunction('min', 'num', false); 1277 //assertSuggestImportedFunction('min', 'num', false);
1278 //assertSuggestImportedFunction( 1278 //assertSuggestImportedFunction(
1279 // 'max', 1279 // 'max',
1280 // 'num', 1280 // 'num',
1281 // false, 1281 // false,
1282 // CompletionRelevance.LOW); 1282 // COMPLETION_RELEVANCE_LOW);
1283 //assertSuggestTopLevelVarGetterSetter('T1', 'String'); 1283 //assertSuggestTopLevelVarGetterSetter('T1', 'String');
1284 assertNotSuggested('_T2'); 1284 assertNotSuggested('_T2');
1285 //assertSuggestImportedTopLevelVar('T3', 'int', CompletionRelevance.LOW); 1285 //assertSuggestImportedTopLevelVar('T3', 'int', COMPLETION_RELEVANCE_LOW);
1286 assertNotSuggested('_T4'); 1286 assertNotSuggested('_T4');
1287 //assertSuggestLocalTopLevelVar('T5', 'int'); 1287 //assertSuggestLocalTopLevelVar('T5', 'int');
1288 //assertSuggestLocalTopLevelVar('_T6', null); 1288 //assertSuggestLocalTopLevelVar('_T6', null);
1289 assertNotSuggested('=='); 1289 assertNotSuggested('==');
1290 // TODO (danrubel) suggest HtmlElement as low relevance 1290 // TODO (danrubel) suggest HtmlElement as low relevance
1291 assertNotSuggested('HtmlElement'); 1291 assertNotSuggested('HtmlElement');
1292 }); 1292 });
1293 } 1293 }
1294 1294
1295 test_Block_inherited_imported() { 1295 test_Block_inherited_imported() {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 addSource('/testB.dart', ''' 1460 addSource('/testB.dart', '''
1461 class B { }'''); 1461 class B { }''');
1462 addTestSource(''' 1462 addTestSource('''
1463 import "testB.dart" as x; 1463 import "testB.dart" as x;
1464 @deprecated class A {^} 1464 @deprecated class A {^}
1465 class _B {} 1465 class _B {}
1466 A T;'''); 1466 A T;''');
1467 computeFast(); 1467 computeFast();
1468 return computeFull((bool result) { 1468 return computeFull((bool result) {
1469 CompletionSuggestion suggestionA = 1469 CompletionSuggestion suggestionA =
1470 assertSuggestLocalClass('A', CompletionRelevance.LOW); 1470 assertSuggestLocalClass('A', COMPLETION_RELEVANCE_LOW);
1471 if (suggestionA != null) { 1471 if (suggestionA != null) {
1472 expect(suggestionA.element.isDeprecated, isTrue); 1472 expect(suggestionA.element.isDeprecated, isTrue);
1473 expect(suggestionA.element.isPrivate, isFalse); 1473 expect(suggestionA.element.isPrivate, isFalse);
1474 } 1474 }
1475 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); 1475 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B');
1476 if (suggestionB != null) { 1476 if (suggestionB != null) {
1477 expect(suggestionB.element.isDeprecated, isFalse); 1477 expect(suggestionB.element.isDeprecated, isFalse);
1478 expect(suggestionB.element.isPrivate, isTrue); 1478 expect(suggestionB.element.isPrivate, isTrue);
1479 } 1479 }
1480 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); 1480 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object');
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2017 // Block BlockFunctionBody MethodDeclaration 2017 // Block BlockFunctionBody MethodDeclaration
2018 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); 2018 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}');
2019 computeFast(); 2019 computeFast();
2020 return computeFull((bool result) { 2020 return computeFull((bool result) {
2021 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); 2021 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z');
2022 if (methodA != null) { 2022 if (methodA != null) {
2023 expect(methodA.element.isDeprecated, isFalse); 2023 expect(methodA.element.isDeprecated, isFalse);
2024 expect(methodA.element.isPrivate, isFalse); 2024 expect(methodA.element.isPrivate, isFalse);
2025 } 2025 }
2026 CompletionSuggestion getterF = 2026 CompletionSuggestion getterF =
2027 assertSuggestLocalGetter('f', 'X', CompletionRelevance.LOW); 2027 assertSuggestLocalGetter('f', 'X', COMPLETION_RELEVANCE_LOW);
2028 if (getterF != null) { 2028 if (getterF != null) {
2029 expect(getterF.element.isDeprecated, isTrue); 2029 expect(getterF.element.isDeprecated, isTrue);
2030 expect(getterF.element.isPrivate, isFalse); 2030 expect(getterF.element.isPrivate, isFalse);
2031 } 2031 }
2032 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); 2032 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null);
2033 if (getterG != null) { 2033 if (getterG != null) {
2034 expect(getterG.element.isDeprecated, isFalse); 2034 expect(getterG.element.isDeprecated, isFalse);
2035 expect(getterG.element.isPrivate, isTrue); 2035 expect(getterG.element.isPrivate, isTrue);
2036 } 2036 }
2037 }); 2037 });
2038 } 2038 }
2039 2039
2040 test_MethodDeclaration_members() { 2040 test_MethodDeclaration_members() {
2041 // Block BlockFunctionBody MethodDeclaration 2041 // Block BlockFunctionBody MethodDeclaration
2042 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); 2042 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}');
2043 computeFast(); 2043 computeFast();
2044 return computeFull((bool result) { 2044 return computeFull((bool result) {
2045 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); 2045 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z');
2046 if (methodA != null) { 2046 if (methodA != null) {
2047 expect(methodA.element.isDeprecated, isFalse); 2047 expect(methodA.element.isDeprecated, isFalse);
2048 expect(methodA.element.isPrivate, isTrue); 2048 expect(methodA.element.isPrivate, isTrue);
2049 } 2049 }
2050 CompletionSuggestion getterF = 2050 CompletionSuggestion getterF =
2051 assertSuggestLocalField('f', CompletionRelevance.LOW); 2051 assertSuggestLocalField('f', COMPLETION_RELEVANCE_LOW);
2052 if (getterF != null) { 2052 if (getterF != null) {
2053 expect(getterF.element.isDeprecated, isTrue); 2053 expect(getterF.element.isDeprecated, isTrue);
2054 expect(getterF.element.isPrivate, isFalse); 2054 expect(getterF.element.isPrivate, isFalse);
2055 expect(getterF.element.parameters, isNull); 2055 expect(getterF.element.parameters, isNull);
2056 } 2056 }
2057 CompletionSuggestion getterG = assertSuggestLocalField('_g'); 2057 CompletionSuggestion getterG = assertSuggestLocalField('_g');
2058 if (getterG != null) { 2058 if (getterG != null) {
2059 expect(getterG.element.isDeprecated, isFalse); 2059 expect(getterG.element.isDeprecated, isFalse);
2060 expect(getterG.element.isPrivate, isTrue); 2060 expect(getterG.element.isPrivate, isTrue);
2061 expect(getterF.element.parameters, isNull); 2061 expect(getterF.element.parameters, isNull);
2062 } 2062 }
2063 assertSuggestImportedClass('bool'); 2063 assertSuggestImportedClass('bool');
2064 }); 2064 });
2065 } 2065 }
2066 2066
2067 test_MethodDeclaration_parameters_named() { 2067 test_MethodDeclaration_parameters_named() {
2068 // Block BlockFunctionBody MethodDeclaration 2068 // Block BlockFunctionBody MethodDeclaration
2069 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); 2069 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}');
2070 computeFast(); 2070 computeFast();
2071 return computeFull((bool result) { 2071 return computeFull((bool result) {
2072 CompletionSuggestion methodA = 2072 CompletionSuggestion methodA =
2073 assertSuggestLocalMethod('a', 'A', 'Z', CompletionRelevance.LOW); 2073 assertSuggestLocalMethod('a', 'A', 'Z', COMPLETION_RELEVANCE_LOW);
2074 if (methodA != null) { 2074 if (methodA != null) {
2075 expect(methodA.element.isDeprecated, isTrue); 2075 expect(methodA.element.isDeprecated, isTrue);
2076 expect(methodA.element.isPrivate, isFalse); 2076 expect(methodA.element.isPrivate, isFalse);
2077 } 2077 }
2078 assertSuggestParameter('x', 'X'); 2078 assertSuggestParameter('x', 'X');
2079 assertSuggestParameter('y', null); 2079 assertSuggestParameter('y', null);
2080 assertSuggestParameter('b', null); 2080 assertSuggestParameter('b', null);
2081 assertSuggestImportedClass('int'); 2081 assertSuggestImportedClass('int');
2082 assertNotSuggested('_'); 2082 assertNotSuggested('_');
2083 }); 2083 });
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2571 assertNotSuggested('bar2'); 2571 assertNotSuggested('bar2');
2572 assertNotSuggested('_B'); 2572 assertNotSuggested('_B');
2573 assertSuggestLocalClass('Y'); 2573 assertSuggestLocalClass('Y');
2574 assertSuggestLocalClass('C'); 2574 assertSuggestLocalClass('C');
2575 assertSuggestLocalVariable('f', null); 2575 assertSuggestLocalVariable('f', null);
2576 assertNotSuggested('x'); 2576 assertNotSuggested('x');
2577 assertNotSuggested('e'); 2577 assertNotSuggested('e');
2578 }); 2578 });
2579 } 2579 }
2580 } 2580 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698