| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.services.completion.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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 new CompletionPerformance()); | 71 new CompletionPerformance()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void assertHasNoParameterInfo(CompletionSuggestion suggestion) { | 74 void assertHasNoParameterInfo(CompletionSuggestion suggestion) { |
| 75 expect(suggestion.parameterNames, isNull); | 75 expect(suggestion.parameterNames, isNull); |
| 76 expect(suggestion.parameterTypes, isNull); | 76 expect(suggestion.parameterTypes, isNull); |
| 77 expect(suggestion.requiredParameterCount, isNull); | 77 expect(suggestion.requiredParameterCount, isNull); |
| 78 expect(suggestion.hasNamedParameters, isNull); | 78 expect(suggestion.hasNamedParameters, isNull); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void assertHasParameterInfo(CompletionSuggestion suggestion) { |
| 82 expect(suggestion.parameterNames, isNotNull); |
| 83 expect(suggestion.parameterTypes, isNotNull); |
| 84 expect(suggestion.parameterNames.length, suggestion.parameterTypes.length); |
| 85 expect( |
| 86 suggestion.requiredParameterCount, |
| 87 lessThanOrEqualTo(suggestion.parameterNames.length)); |
| 88 expect(suggestion.hasNamedParameters, isNotNull); |
| 89 } |
| 90 |
| 81 void assertNoSuggestions({CompletionSuggestionKind kind: null}) { | 91 void assertNoSuggestions({CompletionSuggestionKind kind: null}) { |
| 82 if (kind == null) { | 92 if (kind == null) { |
| 83 if (request.suggestions.length > 0) { | 93 if (request.suggestions.length > 0) { |
| 84 failedCompletion('Expected no suggestions', request.suggestions); | 94 failedCompletion('Expected no suggestions', request.suggestions); |
| 85 } | 95 } |
| 86 return; | 96 return; |
| 87 } | 97 } |
| 88 CompletionSuggestion suggestion = request.suggestions.firstWhere( | 98 CompletionSuggestion suggestion = request.suggestions.firstWhere( |
| 89 (CompletionSuggestion cs) => cs.kind == kind, | 99 (CompletionSuggestion cs) => cs.kind == kind, |
| 90 orElse: () => null); | 100 orElse: () => null); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 173 } |
| 164 StringBuffer msg = new StringBuffer(); | 174 StringBuffer msg = new StringBuffer(); |
| 165 msg.writeln('Argument list not the same'); | 175 msg.writeln('Argument list not the same'); |
| 166 msg.writeln(' Expected names: $expectedNames'); | 176 msg.writeln(' Expected names: $expectedNames'); |
| 167 msg.writeln(' found: $actualNames'); | 177 msg.writeln(' found: $actualNames'); |
| 168 msg.writeln(' Expected types: $expectedTypes'); | 178 msg.writeln(' Expected types: $expectedTypes'); |
| 169 msg.writeln(' found: $actualTypes'); | 179 msg.writeln(' found: $actualTypes'); |
| 170 fail(msg.toString()); | 180 fail(msg.toString()); |
| 171 } | 181 } |
| 172 | 182 |
| 173 CompletionSuggestion assertSuggestClass(String name, [int relevance = | 183 CompletionSuggestion assertSuggestClass(String name, {int relevance: |
| 174 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 184 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind: |
| 175 CompletionSuggestionKind.INVOCATION]) { | 185 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { |
| 176 CompletionSuggestion cs = | 186 CompletionSuggestion cs = assertSuggest( |
| 177 assertSuggest(name, csKind: kind, relevance: relevance); | 187 name, |
| 188 csKind: kind, |
| 189 relevance: relevance, |
| 190 isDeprecated: isDeprecated); |
| 178 protocol.Element element = cs.element; | 191 protocol.Element element = cs.element; |
| 179 expect(element, isNotNull); | 192 expect(element, isNotNull); |
| 180 expect(element.kind, equals(protocol.ElementKind.CLASS)); | 193 expect(element.kind, equals(protocol.ElementKind.CLASS)); |
| 181 expect(element.name, equals(name)); | 194 expect(element.name, equals(name)); |
| 182 expect(element.parameters, isNull); | 195 expect(element.parameters, isNull); |
| 183 expect(element.returnType, isNull); | 196 expect(element.returnType, isNull); |
| 197 assertHasNoParameterInfo(cs); |
| 184 return cs; | 198 return cs; |
| 185 } | 199 } |
| 186 | 200 |
| 187 CompletionSuggestion assertSuggestClassTypeAlias(String name, [int relevance = | 201 CompletionSuggestion assertSuggestClassTypeAlias(String name, [int relevance = |
| 188 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 202 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 189 CompletionSuggestionKind.INVOCATION]) { | 203 CompletionSuggestionKind.INVOCATION]) { |
| 190 CompletionSuggestion cs = | 204 CompletionSuggestion cs = |
| 191 assertSuggest(name, csKind: kind, relevance: relevance); | 205 assertSuggest(name, csKind: kind, relevance: relevance); |
| 192 protocol.Element element = cs.element; | 206 protocol.Element element = cs.element; |
| 193 expect(element, isNotNull); | 207 expect(element, isNotNull); |
| 194 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); | 208 expect(element.kind, equals(protocol.ElementKind.CLASS_TYPE_ALIAS)); |
| 195 expect(element.name, equals(name)); | 209 expect(element.name, equals(name)); |
| 196 expect(element.parameters, isNull); | 210 expect(element.parameters, isNull); |
| 197 expect(element.returnType, isNull); | 211 expect(element.returnType, isNull); |
| 212 assertHasNoParameterInfo(cs); |
| 198 return cs; | 213 return cs; |
| 199 } | 214 } |
| 200 | 215 |
| 201 CompletionSuggestion assertSuggestField(String name, String type, | 216 CompletionSuggestion assertSuggestField(String name, String type, |
| 202 {int relevance: COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kin
d: | 217 {int relevance: COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kin
d: |
| 203 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { | 218 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { |
| 204 CompletionSuggestion cs = assertSuggest( | 219 CompletionSuggestion cs = assertSuggest( |
| 205 name, | 220 name, |
| 206 csKind: kind, | 221 csKind: kind, |
| 207 relevance: relevance, | 222 relevance: relevance, |
| 208 elemKind: protocol.ElementKind.FIELD, | 223 elemKind: protocol.ElementKind.FIELD, |
| 209 isDeprecated: isDeprecated); | 224 isDeprecated: isDeprecated); |
| 210 // The returnType represents the type of a field | 225 // The returnType represents the type of a field |
| 211 expect(cs.returnType, type != null ? type : 'dynamic'); | 226 expect(cs.returnType, type != null ? type : 'dynamic'); |
| 212 protocol.Element element = cs.element; | 227 protocol.Element element = cs.element; |
| 213 expect(element, isNotNull); | 228 expect(element, isNotNull); |
| 214 expect(element.kind, equals(protocol.ElementKind.FIELD)); | 229 expect(element.kind, equals(protocol.ElementKind.FIELD)); |
| 215 expect(element.name, equals(name)); | 230 expect(element.name, equals(name)); |
| 216 expect(element.parameters, isNull); | 231 expect(element.parameters, isNull); |
| 217 // The returnType represents the type of a field | 232 // The returnType represents the type of a field |
| 218 expect(element.returnType, type != null ? type : 'dynamic'); | 233 expect(element.returnType, type != null ? type : 'dynamic'); |
| 234 assertHasNoParameterInfo(cs); |
| 219 return cs; | 235 return cs; |
| 220 } | 236 } |
| 221 | 237 |
| 222 CompletionSuggestion assertSuggestFunction(String name, String returnType, | 238 CompletionSuggestion assertSuggestFunction(String name, String returnType, |
| 223 [bool isDeprecated = false, int relevance = COMPLETION_RELEVANCE_DEFAULT, | 239 [bool isDeprecated = false, int relevance = COMPLETION_RELEVANCE_DEFAULT, |
| 224 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 240 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| 225 CompletionSuggestion cs = assertSuggest( | 241 CompletionSuggestion cs = assertSuggest( |
| 226 name, | 242 name, |
| 227 csKind: kind, | 243 csKind: kind, |
| 228 relevance: relevance, | 244 relevance: relevance, |
| 229 isDeprecated: isDeprecated); | 245 isDeprecated: isDeprecated); |
| 230 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 246 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 231 protocol.Element element = cs.element; | 247 protocol.Element element = cs.element; |
| 232 expect(element, isNotNull); | 248 expect(element, isNotNull); |
| 233 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); | 249 expect(element.kind, equals(protocol.ElementKind.FUNCTION)); |
| 234 expect(element.name, equals(name)); | 250 expect(element.name, equals(name)); |
| 235 expect(element.isDeprecated, equals(isDeprecated)); | 251 expect(element.isDeprecated, equals(isDeprecated)); |
| 236 String param = element.parameters; | 252 String param = element.parameters; |
| 237 expect(param, isNotNull); | 253 expect(param, isNotNull); |
| 238 expect(param[0], equals('(')); | 254 expect(param[0], equals('(')); |
| 239 expect(param[param.length - 1], equals(')')); | 255 expect(param[param.length - 1], equals(')')); |
| 240 expect( | 256 expect( |
| 241 element.returnType, | 257 element.returnType, |
| 242 equals(returnType != null ? returnType : 'dynamic')); | 258 equals(returnType != null ? returnType : 'dynamic')); |
| 259 assertHasParameterInfo(cs); |
| 243 return cs; | 260 return cs; |
| 244 } | 261 } |
| 245 | 262 |
| 246 CompletionSuggestion assertSuggestFunctionTypeAlias(String name, | 263 CompletionSuggestion assertSuggestFunctionTypeAlias(String name, |
| 247 String returnType, bool isDeprecated, [int relevance = | 264 String returnType, bool isDeprecated, [int relevance = |
| 248 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 265 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 249 CompletionSuggestionKind.INVOCATION]) { | 266 CompletionSuggestionKind.INVOCATION]) { |
| 250 CompletionSuggestion cs = assertSuggest( | 267 CompletionSuggestion cs = assertSuggest( |
| 251 name, | 268 name, |
| 252 csKind: kind, | 269 csKind: kind, |
| 253 relevance: relevance, | 270 relevance: relevance, |
| 254 isDeprecated: isDeprecated); | 271 isDeprecated: isDeprecated); |
| 255 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 272 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 256 protocol.Element element = cs.element; | 273 protocol.Element element = cs.element; |
| 257 expect(element, isNotNull); | 274 expect(element, isNotNull); |
| 258 expect(element.kind, equals(protocol.ElementKind.FUNCTION_TYPE_ALIAS)); | 275 expect(element.kind, equals(protocol.ElementKind.FUNCTION_TYPE_ALIAS)); |
| 259 expect(element.name, equals(name)); | 276 expect(element.name, equals(name)); |
| 260 expect(element.isDeprecated, equals(isDeprecated)); | 277 expect(element.isDeprecated, equals(isDeprecated)); |
| 261 // TODO (danrubel) Determine why params are null | 278 // TODO (danrubel) Determine why params are null |
| 262 // String param = element.parameters; | 279 // String param = element.parameters; |
| 263 // expect(param, isNotNull); | 280 // expect(param, isNotNull); |
| 264 // expect(param[0], equals('(')); | 281 // expect(param[0], equals('(')); |
| 265 // expect(param[param.length - 1], equals(')')); | 282 // expect(param[param.length - 1], equals(')')); |
| 266 // TODO (danrubel) Determine why return type is null | 283 expect( |
| 267 // expect( | 284 element.returnType, |
| 268 // element.returnType, | 285 equals(returnType != null ? returnType : 'dynamic')); |
| 269 // equals(returnType != null ? returnType : 'dynamic')); | 286 // TODO (danrubel) Determine why param info is missing |
| 287 // assertHasParameterInfo(cs); |
| 270 return cs; | 288 return cs; |
| 271 } | 289 } |
| 272 | 290 |
| 273 CompletionSuggestion assertSuggestGetter(String name, String returnType, | 291 CompletionSuggestion assertSuggestGetter(String name, String returnType, |
| 274 {int relevance: COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kin
d: | 292 {int relevance: COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kin
d: |
| 275 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { | 293 CompletionSuggestionKind.INVOCATION, bool isDeprecated: false}) { |
| 276 CompletionSuggestion cs = assertSuggest( | 294 CompletionSuggestion cs = assertSuggest( |
| 277 name, | 295 name, |
| 278 csKind: kind, | 296 csKind: kind, |
| 279 relevance: relevance, | 297 relevance: relevance, |
| 280 elemKind: protocol.ElementKind.GETTER, | 298 elemKind: protocol.ElementKind.GETTER, |
| 281 isDeprecated: isDeprecated); | 299 isDeprecated: isDeprecated); |
| 282 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 300 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 283 protocol.Element element = cs.element; | 301 protocol.Element element = cs.element; |
| 284 expect(element, isNotNull); | 302 expect(element, isNotNull); |
| 285 expect(element.kind, equals(protocol.ElementKind.GETTER)); | 303 expect(element.kind, equals(protocol.ElementKind.GETTER)); |
| 286 expect(element.name, equals(name)); | 304 expect(element.name, equals(name)); |
| 287 //TODO (danrubel) getter should have parameters | 305 expect(element.parameters, isNull); |
| 288 // but not used in code completion | |
| 289 //expect(element.parameters, '()'); | |
| 290 expect( | 306 expect( |
| 291 element.returnType, | 307 element.returnType, |
| 292 equals(returnType != null ? returnType : 'dynamic')); | 308 equals(returnType != null ? returnType : 'dynamic')); |
| 309 assertHasNoParameterInfo(cs); |
| 293 return cs; | 310 return cs; |
| 294 } | 311 } |
| 295 | 312 |
| 296 CompletionSuggestion assertSuggestLabel(String name, [int relevance = | 313 CompletionSuggestion assertSuggestLabel(String name, [int relevance = |
| 297 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 314 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 298 CompletionSuggestionKind.IDENTIFIER]) { | 315 CompletionSuggestionKind.IDENTIFIER]) { |
| 299 CompletionSuggestion cs = | 316 CompletionSuggestion cs = |
| 300 assertSuggest(name, csKind: kind, relevance: relevance); | 317 assertSuggest(name, csKind: kind, relevance: relevance); |
| 301 expect(cs.returnType, isNull); | 318 expect(cs.returnType, isNull); |
| 302 protocol.Element element = cs.element; | 319 protocol.Element element = cs.element; |
| 303 expect(element, isNotNull); | 320 expect(element, isNotNull); |
| 304 expect(element.flags, 0); | 321 expect(element.flags, 0); |
| 305 expect(element.kind, equals(protocol.ElementKind.LABEL)); | 322 expect(element.kind, equals(protocol.ElementKind.LABEL)); |
| 306 expect(element.name, equals(name)); | 323 expect(element.name, equals(name)); |
| 307 expect(element.parameters, isNull); | 324 expect(element.parameters, isNull); |
| 308 expect(element.returnType, isNull); | 325 expect(element.returnType, isNull); |
| 326 assertHasNoParameterInfo(cs); |
| 309 return cs; | 327 return cs; |
| 310 } | 328 } |
| 311 | 329 |
| 312 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, [int relevance | 330 CompletionSuggestion assertSuggestLibraryPrefix(String prefix, [int relevance |
| 313 = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 331 = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 314 CompletionSuggestionKind.INVOCATION]) { | 332 CompletionSuggestionKind.INVOCATION]) { |
| 315 // Library prefix should only be suggested by ImportedComputer | 333 // Library prefix should only be suggested by ImportedComputer |
| 316 if (computer is ImportedComputer) { | 334 if (computer is ImportedComputer) { |
| 317 CompletionSuggestion cs = | 335 CompletionSuggestion cs = |
| 318 assertSuggest(prefix, csKind: kind, relevance: relevance); | 336 assertSuggest(prefix, csKind: kind, relevance: relevance); |
| 319 protocol.Element element = cs.element; | 337 protocol.Element element = cs.element; |
| 320 expect(element, isNotNull); | 338 expect(element, isNotNull); |
| 321 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); | 339 expect(element.kind, equals(protocol.ElementKind.LIBRARY)); |
| 322 expect(element.parameters, isNull); | 340 expect(element.parameters, isNull); |
| 323 expect(element.returnType, isNull); | 341 expect(element.returnType, isNull); |
| 342 assertHasNoParameterInfo(cs); |
| 324 return cs; | 343 return cs; |
| 325 } else { | 344 } else { |
| 326 return assertNotSuggested(prefix); | 345 return assertNotSuggested(prefix); |
| 327 } | 346 } |
| 328 } | 347 } |
| 329 | 348 |
| 330 CompletionSuggestion assertSuggestLocalVariable(String name, | 349 CompletionSuggestion assertSuggestLocalVariable(String name, |
| 331 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 350 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, |
| 332 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 351 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| 333 // Local variables should only be suggested by LocalComputer | 352 // Local variables should only be suggested by LocalComputer |
| 334 if (computer is LocalComputer) { | 353 if (computer is LocalComputer) { |
| 335 CompletionSuggestion cs = | 354 CompletionSuggestion cs = |
| 336 assertSuggest(name, csKind: kind, relevance: relevance); | 355 assertSuggest(name, csKind: kind, relevance: relevance); |
| 337 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 356 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 338 protocol.Element element = cs.element; | 357 protocol.Element element = cs.element; |
| 339 expect(element, isNotNull); | 358 expect(element, isNotNull); |
| 340 expect(element.kind, equals(protocol.ElementKind.LOCAL_VARIABLE)); | 359 expect(element.kind, equals(protocol.ElementKind.LOCAL_VARIABLE)); |
| 341 expect(element.name, equals(name)); | 360 expect(element.name, equals(name)); |
| 342 expect(element.parameters, isNull); | 361 expect(element.parameters, isNull); |
| 343 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | 362 expect(element.returnType, returnType != null ? returnType : 'dynamic'); |
| 363 assertHasNoParameterInfo(cs); |
| 344 return cs; | 364 return cs; |
| 345 } else { | 365 } else { |
| 346 return assertNotSuggested(name); | 366 return assertNotSuggested(name); |
| 347 } | 367 } |
| 348 } | 368 } |
| 349 | 369 |
| 350 CompletionSuggestion assertSuggestMethod(String name, String declaringType, | 370 CompletionSuggestion assertSuggestMethod(String name, String declaringType, |
| 351 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 371 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, |
| 352 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 372 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 353 CompletionSuggestion cs = | 373 bool isDeprecated: false}) { |
| 354 assertSuggest(name, csKind: kind, relevance: relevance); | 374 CompletionSuggestion cs = assertSuggest( |
| 375 name, |
| 376 csKind: kind, |
| 377 relevance: relevance, |
| 378 isDeprecated: isDeprecated); |
| 355 expect(cs.declaringType, equals(declaringType)); | 379 expect(cs.declaringType, equals(declaringType)); |
| 356 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 380 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 357 protocol.Element element = cs.element; | 381 protocol.Element element = cs.element; |
| 358 expect(element, isNotNull); | 382 expect(element, isNotNull); |
| 359 expect(element.kind, equals(protocol.ElementKind.METHOD)); | 383 expect(element.kind, equals(protocol.ElementKind.METHOD)); |
| 360 expect(element.name, equals(name)); | 384 expect(element.name, equals(name)); |
| 361 String param = element.parameters; | 385 String param = element.parameters; |
| 362 expect(param, isNotNull); | 386 expect(param, isNotNull); |
| 363 expect(param[0], equals('(')); | 387 expect(param[0], equals('(')); |
| 364 expect(param[param.length - 1], equals(')')); | 388 expect(param[param.length - 1], equals(')')); |
| 365 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | 389 expect(element.returnType, returnType != null ? returnType : 'dynamic'); |
| 390 assertHasParameterInfo(cs); |
| 366 return cs; | 391 return cs; |
| 367 } | 392 } |
| 368 | 393 |
| 369 CompletionSuggestion assertSuggestNamedConstructor(String name, | 394 CompletionSuggestion assertSuggestNamedConstructor(String name, |
| 370 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 395 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, |
| 371 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 396 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| 372 if (computer is InvocationComputer) { | 397 if (computer is InvocationComputer) { |
| 373 CompletionSuggestion cs = | 398 CompletionSuggestion cs = |
| 374 assertSuggest(name, csKind: kind, relevance: relevance); | 399 assertSuggest(name, csKind: kind, relevance: relevance); |
| 375 protocol.Element element = cs.element; | 400 protocol.Element element = cs.element; |
| 376 expect(element, isNotNull); | 401 expect(element, isNotNull); |
| 377 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR)); | 402 expect(element.kind, equals(protocol.ElementKind.CONSTRUCTOR)); |
| 378 expect(element.name, equals(name)); | 403 expect(element.name, equals(name)); |
| 379 String param = element.parameters; | 404 String param = element.parameters; |
| 380 expect(param, isNotNull); | 405 expect(param, isNotNull); |
| 381 expect(param[0], equals('(')); | 406 expect(param[0], equals('(')); |
| 382 expect(param[param.length - 1], equals(')')); | 407 expect(param[param.length - 1], equals(')')); |
| 383 expect(element.returnType, equals(returnType)); | 408 expect(element.returnType, equals(returnType)); |
| 409 assertHasParameterInfo(cs); |
| 384 return cs; | 410 return cs; |
| 385 } else { | 411 } else { |
| 386 return assertNotSuggested(name); | 412 return assertNotSuggested(name); |
| 387 } | 413 } |
| 388 } | 414 } |
| 389 | 415 |
| 390 CompletionSuggestion assertSuggestParameter(String name, String returnType, | 416 CompletionSuggestion assertSuggestParameter(String name, String returnType, |
| 391 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki
nd = | 417 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki
nd = |
| 392 CompletionSuggestionKind.INVOCATION]) { | 418 CompletionSuggestionKind.INVOCATION]) { |
| 393 // Parameters should only be suggested by LocalComputer | 419 // Parameters should only be suggested by LocalComputer |
| (...skipping 26 matching lines...) Expand all Loading... |
| 420 protocol.Element element = cs.element; | 446 protocol.Element element = cs.element; |
| 421 expect(element, isNotNull); | 447 expect(element, isNotNull); |
| 422 expect(element.kind, equals(protocol.ElementKind.SETTER)); | 448 expect(element.kind, equals(protocol.ElementKind.SETTER)); |
| 423 expect(element.name, equals(name)); | 449 expect(element.name, equals(name)); |
| 424 // TODO (danrubel) assert setter param | 450 // TODO (danrubel) assert setter param |
| 425 //expect(element.parameters, isNull); | 451 //expect(element.parameters, isNull); |
| 426 // TODO (danrubel) it would be better if this was always null | 452 // TODO (danrubel) it would be better if this was always null |
| 427 if (element.returnType != null) { | 453 if (element.returnType != null) { |
| 428 expect(element.returnType, 'dynamic'); | 454 expect(element.returnType, 'dynamic'); |
| 429 } | 455 } |
| 456 assertHasNoParameterInfo(cs); |
| 430 return cs; | 457 return cs; |
| 431 } | 458 } |
| 432 | 459 |
| 433 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, | 460 CompletionSuggestion assertSuggestTopLevelVar(String name, String returnType, |
| 434 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki
nd = | 461 [int relevance = COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind ki
nd = |
| 435 CompletionSuggestionKind.INVOCATION]) { | 462 CompletionSuggestionKind.INVOCATION]) { |
| 436 CompletionSuggestion cs = | 463 CompletionSuggestion cs = |
| 437 assertSuggest(name, csKind: kind, relevance: relevance); | 464 assertSuggest(name, csKind: kind, relevance: relevance); |
| 438 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); | 465 expect(cs.returnType, returnType != null ? returnType : 'dynamic'); |
| 439 protocol.Element element = cs.element; | 466 protocol.Element element = cs.element; |
| 440 expect(element, isNotNull); | 467 expect(element, isNotNull); |
| 441 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); | 468 expect(element.kind, equals(protocol.ElementKind.TOP_LEVEL_VARIABLE)); |
| 442 expect(element.name, equals(name)); | 469 expect(element.name, equals(name)); |
| 443 expect(element.parameters, isNull); | 470 expect(element.parameters, isNull); |
| 444 expect(element.returnType, returnType != null ? returnType : 'dynamic'); | 471 expect(element.returnType, returnType != null ? returnType : 'dynamic'); |
| 472 assertHasNoParameterInfo(cs); |
| 445 return cs; | 473 return cs; |
| 446 } | 474 } |
| 447 | 475 |
| 448 void assertSuggestTopLevelVarGetterSetter(String name, String returnType, | 476 void assertSuggestTopLevelVarGetterSetter(String name, String returnType, |
| 449 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 477 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 450 if (computer is ImportedComputer) { | 478 if (computer is ImportedComputer) { |
| 451 assertSuggestGetter(name, returnType); | 479 assertSuggestGetter(name, returnType); |
| 452 assertSuggestSetter(name); | 480 assertSuggestSetter(name); |
| 453 } else { | 481 } else { |
| 454 assertNotSuggested(name); | 482 assertNotSuggested(name); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 * suggestions to the original set of suggestions. | 628 * suggestions to the original set of suggestions. |
| 601 */ | 629 */ |
| 602 void assertCachedCompute(_) { | 630 void assertCachedCompute(_) { |
| 603 // Subclasses override | 631 // Subclasses override |
| 604 } | 632 } |
| 605 | 633 |
| 606 CompletionSuggestion assertLocalSuggestMethod(String name, | 634 CompletionSuggestion assertLocalSuggestMethod(String name, |
| 607 String declaringType, String returnType, [int relevance = | 635 String declaringType, String returnType, [int relevance = |
| 608 COMPLETION_RELEVANCE_DEFAULT]) { | 636 COMPLETION_RELEVANCE_DEFAULT]) { |
| 609 if (computer is LocalComputer) { | 637 if (computer is LocalComputer) { |
| 610 return assertSuggestMethod(name, declaringType, returnType, relevance); | 638 return assertSuggestMethod( |
| 639 name, |
| 640 declaringType, |
| 641 returnType, |
| 642 relevance: relevance); |
| 611 } else { | 643 } else { |
| 612 return assertNotSuggested(name); | 644 return assertNotSuggested(name); |
| 613 } | 645 } |
| 614 } | 646 } |
| 615 | 647 |
| 616 CompletionSuggestion assertSuggestImportedClass(String name, [int relevance = | 648 CompletionSuggestion assertSuggestImportedClass(String name, [int relevance = |
| 617 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = | 649 COMPLETION_RELEVANCE_DEFAULT, CompletionSuggestionKind kind = |
| 618 CompletionSuggestionKind.INVOCATION]) { | 650 CompletionSuggestionKind.INVOCATION]) { |
| 619 if (computer is ImportedComputer) { | 651 if (computer is ImportedComputer) { |
| 620 return assertSuggestClass(name, relevance, kind); | 652 return assertSuggestClass(name, relevance: relevance, kind: kind); |
| 621 } else { | 653 } else { |
| 622 return assertNotSuggested(name); | 654 return assertNotSuggested(name); |
| 623 } | 655 } |
| 624 } | 656 } |
| 625 | 657 |
| 626 CompletionSuggestion assertSuggestImportedField(String name, String type, | 658 CompletionSuggestion assertSuggestImportedField(String name, String type, |
| 627 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 659 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 628 return assertNotSuggested(name); | 660 return assertNotSuggested(name); |
| 629 } | 661 } |
| 630 | 662 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 return assertSuggestGetter(name, returnType, relevance: relevance); | 698 return assertSuggestGetter(name, returnType, relevance: relevance); |
| 667 } else { | 699 } else { |
| 668 return assertNotSuggested(name); | 700 return assertNotSuggested(name); |
| 669 } | 701 } |
| 670 } | 702 } |
| 671 | 703 |
| 672 CompletionSuggestion assertSuggestImportedMethod(String name, | 704 CompletionSuggestion assertSuggestImportedMethod(String name, |
| 673 String declaringType, String returnType, [int relevance = | 705 String declaringType, String returnType, [int relevance = |
| 674 COMPLETION_RELEVANCE_DEFAULT]) { | 706 COMPLETION_RELEVANCE_DEFAULT]) { |
| 675 if (computer is ImportedComputer) { | 707 if (computer is ImportedComputer) { |
| 676 return assertSuggestMethod(name, declaringType, returnType, relevance); | 708 return assertSuggestMethod( |
| 709 name, |
| 710 declaringType, |
| 711 returnType, |
| 712 relevance: relevance); |
| 677 } else { | 713 } else { |
| 678 return assertNotSuggested(name); | 714 return assertNotSuggested(name); |
| 679 } | 715 } |
| 680 } | 716 } |
| 681 | 717 |
| 682 CompletionSuggestion assertSuggestImportedSetter(String name, [int relevance = | 718 CompletionSuggestion assertSuggestImportedSetter(String name, [int relevance = |
| 683 COMPLETION_RELEVANCE_DEFAULT]) { | 719 COMPLETION_RELEVANCE_DEFAULT]) { |
| 684 if (computer is ImportedComputer) { | 720 if (computer is ImportedComputer) { |
| 685 return assertSuggestSetter(name, relevance); | 721 return assertSuggestSetter(name, relevance); |
| 686 } else { | 722 } else { |
| 687 return assertNotSuggested(name); | 723 return assertNotSuggested(name); |
| 688 } | 724 } |
| 689 } | 725 } |
| 690 | 726 |
| 691 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, | 727 CompletionSuggestion assertSuggestImportedTopLevelVar(String name, |
| 692 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, | 728 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT, |
| 693 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { | 729 CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION]) { |
| 694 if (computer is ImportedComputer) { | 730 if (computer is ImportedComputer) { |
| 695 return assertSuggestTopLevelVar(name, returnType, relevance, kind); | 731 return assertSuggestTopLevelVar(name, returnType, relevance, kind); |
| 696 } else { | 732 } else { |
| 697 return assertNotSuggested(name); | 733 return assertNotSuggested(name); |
| 698 } | 734 } |
| 699 } | 735 } |
| 700 | 736 |
| 701 CompletionSuggestion assertSuggestInvocationClass(String name, [int relevance | 737 CompletionSuggestion assertSuggestInvocationClass(String name, [int relevance |
| 702 = COMPLETION_RELEVANCE_DEFAULT]) { | 738 = COMPLETION_RELEVANCE_DEFAULT]) { |
| 703 if (computer is InvocationComputer) { | 739 if (computer is InvocationComputer) { |
| 704 return assertSuggestClass(name, relevance); | 740 return assertSuggestClass(name, relevance: relevance); |
| 705 } else { | 741 } else { |
| 706 return assertNotSuggested(name); | 742 return assertNotSuggested(name); |
| 707 } | 743 } |
| 708 } | 744 } |
| 709 | 745 |
| 710 CompletionSuggestion assertSuggestInvocationField(String name, String type, | 746 CompletionSuggestion assertSuggestInvocationField(String name, String type, |
| 711 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { | 747 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
| 712 return assertNotSuggested(name); | 748 return assertNotSuggested(name); |
| 713 } | 749 } |
| 714 | 750 |
| 715 CompletionSuggestion assertSuggestInvocationGetter(String name, | 751 CompletionSuggestion assertSuggestInvocationGetter(String name, |
| 716 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, | 752 String returnType, {int relevance: COMPLETION_RELEVANCE_DEFAULT, |
| 717 bool isDeprecated: false}) { | 753 bool isDeprecated: false}) { |
| 718 if (computer is InvocationComputer) { | 754 if (computer is InvocationComputer) { |
| 719 return assertSuggestGetter( | 755 return assertSuggestGetter( |
| 720 name, | 756 name, |
| 721 returnType, | 757 returnType, |
| 722 relevance: relevance, | 758 relevance: relevance, |
| 723 isDeprecated: isDeprecated); | 759 isDeprecated: isDeprecated); |
| 724 } else { | 760 } else { |
| 725 return assertNotSuggested(name); | 761 return assertNotSuggested(name); |
| 726 } | 762 } |
| 727 } | 763 } |
| 728 | 764 |
| 729 CompletionSuggestion assertSuggestInvocationMethod(String name, | 765 CompletionSuggestion assertSuggestInvocationMethod(String name, |
| 730 String declaringType, String returnType, [int relevance = | 766 String declaringType, String returnType, [int relevance = |
| 731 COMPLETION_RELEVANCE_DEFAULT]) { | 767 COMPLETION_RELEVANCE_DEFAULT]) { |
| 732 if (computer is InvocationComputer) { | 768 if (computer is InvocationComputer) { |
| 733 return assertSuggestMethod(name, declaringType, returnType, relevance); | 769 return assertSuggestMethod( |
| 770 name, |
| 771 declaringType, |
| 772 returnType, |
| 773 relevance: relevance); |
| 734 } else { | 774 } else { |
| 735 return assertNotSuggested(name); | 775 return assertNotSuggested(name); |
| 736 } | 776 } |
| 737 } | 777 } |
| 738 | 778 |
| 739 CompletionSuggestion assertSuggestInvocationSetter(String name, [int relevance | 779 CompletionSuggestion assertSuggestInvocationSetter(String name, [int relevance |
| 740 = COMPLETION_RELEVANCE_DEFAULT]) { | 780 = COMPLETION_RELEVANCE_DEFAULT]) { |
| 741 if (computer is InvocationComputer) { | 781 if (computer is InvocationComputer) { |
| 742 return assertSuggestSetter(name); | 782 return assertSuggestSetter(name); |
| 743 } else { | 783 } else { |
| 744 return assertNotSuggested(name); | 784 return assertNotSuggested(name); |
| 745 } | 785 } |
| 746 } | 786 } |
| 747 | 787 |
| 748 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name, | 788 CompletionSuggestion assertSuggestInvocationTopLevelVar(String name, |
| 749 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 789 String returnType, [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 750 if (computer is InvocationComputer) { | 790 if (computer is InvocationComputer) { |
| 751 return assertSuggestTopLevelVar(name, returnType, relevance); | 791 return assertSuggestTopLevelVar(name, returnType, relevance); |
| 752 } else { | 792 } else { |
| 753 return assertNotSuggested(name); | 793 return assertNotSuggested(name); |
| 754 } | 794 } |
| 755 } | 795 } |
| 756 | 796 |
| 757 CompletionSuggestion assertSuggestLocalClass(String name, [int relevance = | 797 CompletionSuggestion assertSuggestLocalClass(String name, {int relevance: |
| 758 COMPLETION_RELEVANCE_DEFAULT]) { | 798 COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
| 759 if (computer is LocalComputer) { | 799 return assertNotSuggested(name); |
| 760 return assertSuggestClass(name, relevance); | |
| 761 } else { | |
| 762 return assertNotSuggested(name); | |
| 763 } | |
| 764 } | 800 } |
| 765 | 801 |
| 766 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, | 802 CompletionSuggestion assertSuggestLocalClassTypeAlias(String name, |
| 767 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 803 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { |
| 768 if (computer is LocalComputer) { | 804 if (computer is LocalComputer) { |
| 769 return assertSuggestClassTypeAlias(name, relevance); | 805 return assertSuggestClassTypeAlias(name, relevance); |
| 770 } else { | 806 } else { |
| 771 return assertNotSuggested(name); | 807 return assertNotSuggested(name); |
| 772 } | 808 } |
| 773 } | 809 } |
| 774 | 810 |
| 775 CompletionSuggestion assertSuggestLocalField(String name, String type, | 811 CompletionSuggestion assertSuggestLocalField(String name, String type, |
| 776 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 812 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
| 777 return assertNotSuggested(name); | 813 return assertNotSuggested(name); |
| 778 } | 814 } |
| 779 | 815 |
| 780 CompletionSuggestion assertSuggestLocalFunction(String name, | 816 CompletionSuggestion assertSuggestLocalFunction(String name, |
| 781 String returnType, [bool isDeprecated = false, int relevance = | 817 String returnType, [bool isDeprecated = false, int relevance = |
| 782 COMPLETION_RELEVANCE_DEFAULT]) { | 818 COMPLETION_RELEVANCE_DEFAULT]) { |
| 783 if (computer is LocalComputer) { | 819 if (computer is LocalComputer) { |
| 784 return assertSuggestFunction(name, returnType, isDeprecated, relevance); | 820 return assertSuggestFunction(name, returnType, isDeprecated, relevance); |
| 785 } else { | 821 } else { |
| 786 return assertNotSuggested(name); | 822 return assertNotSuggested(name); |
| 787 } | 823 } |
| 788 } | 824 } |
| 789 | 825 |
| 790 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name, | 826 CompletionSuggestion assertSuggestLocalFunctionTypeAlias(String name, |
| 791 String returnType, [bool isDeprecated = false, int relevance = | 827 String returnType, [bool isDeprecated = false, int relevance = |
| 792 COMPLETION_RELEVANCE_DEFAULT]) { | 828 COMPLETION_RELEVANCE_DEFAULT]) { |
| 793 if (computer is LocalComputer) { | 829 if (computer is LocalComputer) { |
| 794 return assertSuggestFunctionTypeAlias( | 830 return assertSuggestFunctionTypeAlias( |
| 795 name, | 831 name, |
| 796 returnType, | 832 returnType, |
| 797 isDeprecated, | 833 isDeprecated, |
| 798 relevance); | 834 relevance); |
| 799 } else { | 835 } else { |
| 800 return assertNotSuggested(name); | 836 return assertNotSuggested(name); |
| 801 } | 837 } |
| 802 } | 838 } |
| 803 | 839 |
| 804 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, | 840 CompletionSuggestion assertSuggestLocalGetter(String name, String returnType, |
| 805 [int relevance = COMPLETION_RELEVANCE_DEFAULT]) { | 841 {int relevance: COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
| 806 if (computer is LocalComputer) { | 842 return assertNotSuggested(name); |
| 807 return assertSuggestGetter(name, returnType, relevance: relevance); | |
| 808 } else { | |
| 809 return assertNotSuggested(name); | |
| 810 } | |
| 811 } | 843 } |
| 812 | 844 |
| 813 CompletionSuggestion assertSuggestLocalMethod(String name, | 845 CompletionSuggestion assertSuggestLocalMethod(String name, |
| 814 String declaringType, String returnType, [int relevance = | 846 String declaringType, String returnType, {int relevance: |
| 815 COMPLETION_RELEVANCE_DEFAULT]) { | 847 COMPLETION_RELEVANCE_DEFAULT, bool isDeprecated: false}) { |
| 816 if (computer is LocalComputer) { | 848 return assertNotSuggested(name); |
| 817 return assertSuggestMethod(name, declaringType, returnType, relevance); | |
| 818 } else { | |
| 819 return assertNotSuggested(name); | |
| 820 } | |
| 821 } | 849 } |
| 822 | 850 |
| 823 CompletionSuggestion assertSuggestLocalSetter(String name, [int relevance = | 851 CompletionSuggestion assertSuggestLocalSetter(String name, [int relevance = |
| 824 COMPLETION_RELEVANCE_DEFAULT]) { | 852 COMPLETION_RELEVANCE_DEFAULT]) { |
| 825 if (computer is LocalComputer) { | 853 if (computer is LocalComputer) { |
| 826 return assertSuggestSetter(name, relevance); | 854 return assertSuggestSetter(name, relevance); |
| 827 } else { | 855 } else { |
| 828 return assertNotSuggested(name); | 856 return assertNotSuggested(name); |
| 829 } | 857 } |
| 830 } | 858 } |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 // ClassDeclaration CompilationUnit | 1496 // ClassDeclaration CompilationUnit |
| 1469 addSource('/testB.dart', ''' | 1497 addSource('/testB.dart', ''' |
| 1470 class B { }'''); | 1498 class B { }'''); |
| 1471 addTestSource(''' | 1499 addTestSource(''' |
| 1472 import "testB.dart" as x; | 1500 import "testB.dart" as x; |
| 1473 @deprecated class A {^} | 1501 @deprecated class A {^} |
| 1474 class _B {} | 1502 class _B {} |
| 1475 A T;'''); | 1503 A T;'''); |
| 1476 computeFast(); | 1504 computeFast(); |
| 1477 return computeFull((bool result) { | 1505 return computeFull((bool result) { |
| 1478 CompletionSuggestion suggestionA = | 1506 CompletionSuggestion suggestionA = assertSuggestLocalClass( |
| 1479 assertSuggestLocalClass('A', COMPLETION_RELEVANCE_LOW); | 1507 'A', |
| 1508 relevance: COMPLETION_RELEVANCE_LOW, |
| 1509 isDeprecated: true); |
| 1480 if (suggestionA != null) { | 1510 if (suggestionA != null) { |
| 1481 expect(suggestionA.element.isDeprecated, isTrue); | 1511 expect(suggestionA.element.isDeprecated, isTrue); |
| 1482 expect(suggestionA.element.isPrivate, isFalse); | 1512 expect(suggestionA.element.isPrivate, isFalse); |
| 1483 } | 1513 } |
| 1484 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); | 1514 CompletionSuggestion suggestionB = assertSuggestLocalClass('_B'); |
| 1485 if (suggestionB != null) { | 1515 if (suggestionB != null) { |
| 1486 expect(suggestionB.element.isDeprecated, isFalse); | 1516 expect(suggestionB.element.isDeprecated, isFalse); |
| 1487 expect(suggestionB.element.isPrivate, isTrue); | 1517 expect(suggestionB.element.isPrivate, isTrue); |
| 1488 } | 1518 } |
| 1489 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); | 1519 CompletionSuggestion suggestionO = assertSuggestImportedClass('Object'); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 test_MethodDeclaration_body_getters() { | 2055 test_MethodDeclaration_body_getters() { |
| 2026 // Block BlockFunctionBody MethodDeclaration | 2056 // Block BlockFunctionBody MethodDeclaration |
| 2027 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); | 2057 addTestSource('class A {@deprecated X get f => 0; Z a() {^} get _g => 1;}'); |
| 2028 computeFast(); | 2058 computeFast(); |
| 2029 return computeFull((bool result) { | 2059 return computeFull((bool result) { |
| 2030 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); | 2060 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); |
| 2031 if (methodA != null) { | 2061 if (methodA != null) { |
| 2032 expect(methodA.element.isDeprecated, isFalse); | 2062 expect(methodA.element.isDeprecated, isFalse); |
| 2033 expect(methodA.element.isPrivate, isFalse); | 2063 expect(methodA.element.isPrivate, isFalse); |
| 2034 } | 2064 } |
| 2035 CompletionSuggestion getterF = | 2065 CompletionSuggestion getterF = assertSuggestLocalGetter( |
| 2036 assertSuggestLocalGetter('f', 'X', COMPLETION_RELEVANCE_LOW); | 2066 'f', |
| 2067 'X', |
| 2068 relevance: COMPLETION_RELEVANCE_LOW, |
| 2069 isDeprecated: true); |
| 2037 if (getterF != null) { | 2070 if (getterF != null) { |
| 2038 expect(getterF.element.isDeprecated, isTrue); | 2071 expect(getterF.element.isDeprecated, isTrue); |
| 2039 expect(getterF.element.isPrivate, isFalse); | 2072 expect(getterF.element.isPrivate, isFalse); |
| 2040 } | 2073 } |
| 2041 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); | 2074 CompletionSuggestion getterG = assertSuggestLocalGetter('_g', null); |
| 2042 if (getterG != null) { | 2075 if (getterG != null) { |
| 2043 expect(getterG.element.isDeprecated, isFalse); | 2076 expect(getterG.element.isDeprecated, isFalse); |
| 2044 expect(getterG.element.isPrivate, isTrue); | 2077 expect(getterG.element.isPrivate, isTrue); |
| 2045 } | 2078 } |
| 2046 }); | 2079 }); |
| 2047 } | 2080 } |
| 2048 | 2081 |
| 2049 test_MethodDeclaration_members() { | 2082 test_MethodDeclaration_members() { |
| 2050 // Block BlockFunctionBody MethodDeclaration | 2083 // Block BlockFunctionBody MethodDeclaration |
| 2051 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); | 2084 addTestSource('class A {@deprecated X f; Z _a() {^} var _g;}'); |
| 2052 computeFast(); | 2085 computeFast(); |
| 2053 return computeFull((bool result) { | 2086 return computeFull((bool result) { |
| 2054 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); | 2087 CompletionSuggestion methodA = assertSuggestLocalMethod('_a', 'A', 'Z'); |
| 2055 if (methodA != null) { | 2088 if (methodA != null) { |
| 2056 expect(methodA.element.isDeprecated, isFalse); | 2089 expect(methodA.element.isDeprecated, isFalse); |
| 2057 expect(methodA.element.isPrivate, isTrue); | 2090 expect(methodA.element.isPrivate, isTrue); |
| 2058 } | 2091 } |
| 2059 CompletionSuggestion getterF = | 2092 CompletionSuggestion getterF = assertSuggestLocalField( |
| 2060 assertSuggestLocalField('f', 'X', COMPLETION_RELEVANCE_LOW); | 2093 'f', |
| 2094 'X', |
| 2095 relevance: COMPLETION_RELEVANCE_LOW, |
| 2096 isDeprecated: true); |
| 2061 if (getterF != null) { | 2097 if (getterF != null) { |
| 2062 expect(getterF.element.isDeprecated, isTrue); | 2098 expect(getterF.element.isDeprecated, isTrue); |
| 2063 expect(getterF.element.isPrivate, isFalse); | 2099 expect(getterF.element.isPrivate, isFalse); |
| 2064 expect(getterF.element.parameters, isNull); | 2100 expect(getterF.element.parameters, isNull); |
| 2065 } | 2101 } |
| 2066 CompletionSuggestion getterG = assertSuggestLocalField('_g', null); | 2102 CompletionSuggestion getterG = assertSuggestLocalField('_g', null); |
| 2067 if (getterG != null) { | 2103 if (getterG != null) { |
| 2068 expect(getterG.element.isDeprecated, isFalse); | 2104 expect(getterG.element.isDeprecated, isFalse); |
| 2069 expect(getterG.element.isPrivate, isTrue); | 2105 expect(getterG.element.isPrivate, isTrue); |
| 2070 expect(getterF.element.parameters, isNull); | 2106 expect(getterF.element.parameters, isNull); |
| 2071 } | 2107 } |
| 2072 assertSuggestImportedClass('bool'); | 2108 assertSuggestImportedClass('bool'); |
| 2073 }); | 2109 }); |
| 2074 } | 2110 } |
| 2075 | 2111 |
| 2076 test_MethodDeclaration_parameters_named() { | 2112 test_MethodDeclaration_parameters_named() { |
| 2077 // Block BlockFunctionBody MethodDeclaration | 2113 // Block BlockFunctionBody MethodDeclaration |
| 2078 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); | 2114 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}'); |
| 2079 computeFast(); | 2115 computeFast(); |
| 2080 return computeFull((bool result) { | 2116 return computeFull((bool result) { |
| 2081 CompletionSuggestion methodA = | 2117 CompletionSuggestion methodA = assertSuggestLocalMethod( |
| 2082 assertSuggestLocalMethod('a', 'A', 'Z', COMPLETION_RELEVANCE_LOW); | 2118 'a', |
| 2119 'A', |
| 2120 'Z', |
| 2121 relevance: COMPLETION_RELEVANCE_LOW, |
| 2122 isDeprecated: true); |
| 2083 if (methodA != null) { | 2123 if (methodA != null) { |
| 2084 expect(methodA.element.isDeprecated, isTrue); | 2124 expect(methodA.element.isDeprecated, isTrue); |
| 2085 expect(methodA.element.isPrivate, isFalse); | 2125 expect(methodA.element.isPrivate, isFalse); |
| 2086 } | 2126 } |
| 2087 assertSuggestParameter('x', 'X'); | 2127 assertSuggestParameter('x', 'X'); |
| 2088 assertSuggestParameter('y', null); | 2128 assertSuggestParameter('y', null); |
| 2089 assertSuggestParameter('b', null); | 2129 assertSuggestParameter('b', null); |
| 2090 assertSuggestImportedClass('int'); | 2130 assertSuggestImportedClass('int'); |
| 2091 assertNotSuggested('_'); | 2131 assertNotSuggested('_'); |
| 2092 }); | 2132 }); |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2580 assertNotSuggested('bar2'); | 2620 assertNotSuggested('bar2'); |
| 2581 assertNotSuggested('_B'); | 2621 assertNotSuggested('_B'); |
| 2582 assertSuggestLocalClass('Y'); | 2622 assertSuggestLocalClass('Y'); |
| 2583 assertSuggestLocalClass('C'); | 2623 assertSuggestLocalClass('C'); |
| 2584 assertSuggestLocalVariable('f', null); | 2624 assertSuggestLocalVariable('f', null); |
| 2585 assertNotSuggested('x'); | 2625 assertNotSuggested('x'); |
| 2586 assertNotSuggested('e'); | 2626 assertNotSuggested('e'); |
| 2587 }); | 2627 }); |
| 2588 } | 2628 } |
| 2589 } | 2629 } |
| OLD | NEW |