| 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 engine.testing.element_factory; | 5 library engine.testing.element_factory; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/constant.dart'; | 10 import 'package:analyzer/src/generated/constant.dart'; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 functionName, null, normalParameters, optionalParameters); | 339 functionName, null, normalParameters, optionalParameters); |
| 340 | 340 |
| 341 static FunctionElementImpl functionElement7( | 341 static FunctionElementImpl functionElement7( |
| 342 String functionName, | 342 String functionName, |
| 343 List<ClassElement> normalParameters, | 343 List<ClassElement> normalParameters, |
| 344 List<String> names, | 344 List<String> names, |
| 345 List<ClassElement> namedParameters) => | 345 List<ClassElement> namedParameters) => |
| 346 functionElement4( | 346 functionElement4( |
| 347 functionName, null, normalParameters, names, namedParameters); | 347 functionName, null, normalParameters, names, namedParameters); |
| 348 | 348 |
| 349 static FunctionElementImpl functionElement8( |
| 350 List<DartType> parameters, DartType returnType, |
| 351 {List<DartType> optional, Map<String, DartType> named}) { |
| 352 List<ParameterElement> parameterElements = new List<ParameterElement>(); |
| 353 for (int i = 0; i < parameters.length; i++) { |
| 354 ParameterElementImpl parameterElement = |
| 355 new ParameterElementImpl("a$i", i); |
| 356 parameterElement.type = parameters[i]; |
| 357 parameterElement.parameterKind = ParameterKind.REQUIRED; |
| 358 parameterElements.add(parameterElement); |
| 359 } |
| 360 if (optional != null) { |
| 361 int j = parameters.length; |
| 362 for (int i = 0; i < optional.length; i++) { |
| 363 ParameterElementImpl parameterElement = |
| 364 new ParameterElementImpl("o$i", j); |
| 365 parameterElement.type = optional[i]; |
| 366 parameterElement.parameterKind = ParameterKind.POSITIONAL; |
| 367 parameterElements.add(parameterElement); |
| 368 j++; |
| 369 } |
| 370 } else if (named != null) { |
| 371 int j = parameters.length; |
| 372 for (String s in named.keys) { |
| 373 ParameterElementImpl parameterElement = new ParameterElementImpl(s, j); |
| 374 parameterElement.type = named[s]; |
| 375 parameterElement.parameterKind = ParameterKind.NAMED; |
| 376 parameterElements.add(parameterElement); |
| 377 } |
| 378 } |
| 379 |
| 380 return functionElementWithParameters("f", returnType, parameterElements); |
| 381 } |
| 382 |
| 349 static FunctionElementImpl functionElementWithParameters(String functionName, | 383 static FunctionElementImpl functionElementWithParameters(String functionName, |
| 350 DartType returnType, List<ParameterElement> parameters) { | 384 DartType returnType, List<ParameterElement> parameters) { |
| 351 FunctionElementImpl functionElement = | 385 FunctionElementImpl functionElement = |
| 352 new FunctionElementImpl(functionName, 0); | 386 new FunctionElementImpl(functionName, 0); |
| 353 functionElement.returnType = | 387 functionElement.returnType = |
| 354 returnType == null ? VoidTypeImpl.instance : returnType; | 388 returnType == null ? VoidTypeImpl.instance : returnType; |
| 355 functionElement.parameters = parameters; | 389 functionElement.parameters = parameters; |
| 356 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); | 390 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); |
| 357 functionElement.type = functionType; | 391 functionElement.type = functionType; |
| 358 return functionElement; | 392 return functionElement; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 } | 604 } |
| 571 return variable; | 605 return variable; |
| 572 } | 606 } |
| 573 | 607 |
| 574 static TypeParameterElementImpl typeParameterElement(String name) { | 608 static TypeParameterElementImpl typeParameterElement(String name) { |
| 575 TypeParameterElementImpl element = new TypeParameterElementImpl(name, 0); | 609 TypeParameterElementImpl element = new TypeParameterElementImpl(name, 0); |
| 576 element.type = new TypeParameterTypeImpl(element); | 610 element.type = new TypeParameterTypeImpl(element); |
| 577 return element; | 611 return element; |
| 578 } | 612 } |
| 579 } | 613 } |
| OLD | NEW |