| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.testing.element_factory; | 8 library engine.testing.element_factory; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 190 } |
| 191 // | 191 // |
| 192 // Finish building the enum. | 192 // Finish building the enum. |
| 193 // | 193 // |
| 194 enumElement.fields = fields; | 194 enumElement.fields = fields; |
| 195 // Client code isn't allowed to invoke the constructor, so we do not model i
t. | 195 // Client code isn't allowed to invoke the constructor, so we do not model i
t. |
| 196 return enumElement; | 196 return enumElement; |
| 197 } | 197 } |
| 198 | 198 |
| 199 static ExportElementImpl exportFor(LibraryElement exportedLibrary, | 199 static ExportElementImpl exportFor(LibraryElement exportedLibrary, |
| 200 [List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_LIST])
{ | 200 [List<NamespaceCombinator> combinators = |
| 201 NamespaceCombinator.EMPTY_LIST]) { |
| 201 ExportElementImpl spec = new ExportElementImpl(-1); | 202 ExportElementImpl spec = new ExportElementImpl(-1); |
| 202 spec.exportedLibrary = exportedLibrary; | 203 spec.exportedLibrary = exportedLibrary; |
| 203 spec.combinators = combinators; | 204 spec.combinators = combinators; |
| 204 return spec; | 205 return spec; |
| 205 } | 206 } |
| 206 | 207 |
| 207 static FieldElementImpl fieldElement( | 208 static FieldElementImpl fieldElement( |
| 208 String name, bool isStatic, bool isFinal, bool isConst, DartType type) { | 209 String name, bool isStatic, bool isFinal, bool isConst, DartType type) { |
| 209 FieldElementImpl field = new FieldElementImpl(name, 0); | 210 FieldElementImpl field = new FieldElementImpl(name, 0); |
| 210 field.const3 = isConst; | 211 field.const3 = isConst; |
| 211 field.final2 = isFinal; | 212 field.final2 = isFinal; |
| 212 field.static = isStatic; | 213 field.static = isStatic; |
| 213 field.type = type; | 214 field.type = type; |
| 214 PropertyAccessorElementImpl getter = | 215 PropertyAccessorElementImpl getter = |
| 215 new PropertyAccessorElementImpl.forVariable(field); | 216 new PropertyAccessorElementImpl.forVariable(field); |
| 216 getter.getter = true; | 217 getter.getter = true; |
| 217 getter.synthetic = true; | 218 getter.synthetic = true; |
| 218 getter.variable = field; | 219 getter.variable = field; |
| 219 getter.returnType = type; | 220 getter.returnType = type; |
| 220 field.getter = getter; | 221 field.getter = getter; |
| 221 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); | 222 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); |
| 222 getter.type = getterType; | 223 getter.type = getterType; |
| 223 if (!isConst && !isFinal) { | 224 if (!isConst && !isFinal) { |
| 224 PropertyAccessorElementImpl setter = | 225 PropertyAccessorElementImpl setter = |
| 225 new PropertyAccessorElementImpl.forVariable(field); | 226 new PropertyAccessorElementImpl.forVariable(field); |
| 226 setter.setter = true; | 227 setter.setter = true; |
| 227 setter.synthetic = true; | 228 setter.synthetic = true; |
| 228 setter.variable = field; | 229 setter.variable = field; |
| 229 setter.parameters = | 230 setter.parameters = <ParameterElement>[ |
| 230 <ParameterElement>[requiredParameter2("_$name", type)]; | 231 requiredParameter2("_$name", type) |
| 232 ]; |
| 231 setter.returnType = VoidTypeImpl.instance; | 233 setter.returnType = VoidTypeImpl.instance; |
| 232 setter.type = new FunctionTypeImpl(setter); | 234 setter.type = new FunctionTypeImpl(setter); |
| 233 field.setter = setter; | 235 field.setter = setter; |
| 234 } | 236 } |
| 235 return field; | 237 return field; |
| 236 } | 238 } |
| 237 | 239 |
| 238 static FieldFormalParameterElementImpl fieldFormalParameter( | 240 static FieldFormalParameterElementImpl fieldFormalParameter( |
| 239 Identifier name) => new FieldFormalParameterElementImpl(name); | 241 Identifier name) => |
| 242 new FieldFormalParameterElementImpl(name); |
| 240 | 243 |
| 241 static FunctionElementImpl functionElement(String functionName) => | 244 static FunctionElementImpl functionElement(String functionName) => |
| 242 functionElement4(functionName, null, null, null, null); | 245 functionElement4(functionName, null, null, null, null); |
| 243 | 246 |
| 244 static FunctionElementImpl functionElement2( | 247 static FunctionElementImpl functionElement2( |
| 245 String functionName, ClassElement returnElement) => | 248 String functionName, ClassElement returnElement) => |
| 246 functionElement3(functionName, returnElement, null, null); | 249 functionElement3(functionName, returnElement, null, null); |
| 247 | 250 |
| 248 static FunctionElementImpl functionElement3(String functionName, | 251 static FunctionElementImpl functionElement3( |
| 249 ClassElement returnElement, List<ClassElement> normalParameters, | 252 String functionName, |
| 250 List<ClassElement> optionalParameters) { | 253 ClassElement returnElement, |
| 254 List<TypeDefiningElement> normalParameters, |
| 255 List<TypeDefiningElement> optionalParameters) { |
| 251 // We don't create parameter elements because we don't have parameter names | 256 // We don't create parameter elements because we don't have parameter names |
| 252 FunctionElementImpl functionElement = | 257 FunctionElementImpl functionElement = |
| 253 new FunctionElementImpl(functionName, 0); | 258 new FunctionElementImpl(functionName, 0); |
| 254 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); | 259 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); |
| 255 functionElement.type = functionType; | 260 functionElement.type = functionType; |
| 256 // return type | 261 // return type |
| 257 if (returnElement == null) { | 262 if (returnElement == null) { |
| 258 functionElement.returnType = VoidTypeImpl.instance; | 263 functionElement.returnType = VoidTypeImpl.instance; |
| 259 } else { | 264 } else { |
| 260 functionElement.returnType = returnElement.type; | 265 functionElement.returnType = returnElement.type; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 274 parameter.type = optionalParameters[i - normalCount].type; | 279 parameter.type = optionalParameters[i - normalCount].type; |
| 275 parameter.parameterKind = ParameterKind.POSITIONAL; | 280 parameter.parameterKind = ParameterKind.POSITIONAL; |
| 276 } | 281 } |
| 277 parameters[i] = parameter; | 282 parameters[i] = parameter; |
| 278 } | 283 } |
| 279 functionElement.parameters = parameters; | 284 functionElement.parameters = parameters; |
| 280 // done | 285 // done |
| 281 return functionElement; | 286 return functionElement; |
| 282 } | 287 } |
| 283 | 288 |
| 284 static FunctionElementImpl functionElement4(String functionName, | 289 static FunctionElementImpl functionElement4( |
| 285 ClassElement returnElement, List<ClassElement> normalParameters, | 290 String functionName, |
| 286 List<String> names, List<ClassElement> namedParameters) { | 291 ClassElement returnElement, |
| 292 List<ClassElement> normalParameters, |
| 293 List<String> names, |
| 294 List<ClassElement> namedParameters) { |
| 287 FunctionElementImpl functionElement = | 295 FunctionElementImpl functionElement = |
| 288 new FunctionElementImpl(functionName, 0); | 296 new FunctionElementImpl(functionName, 0); |
| 289 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); | 297 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); |
| 290 functionElement.type = functionType; | 298 functionElement.type = functionType; |
| 291 // parameters | 299 // parameters |
| 292 int normalCount = normalParameters == null ? 0 : normalParameters.length; | 300 int normalCount = normalParameters == null ? 0 : normalParameters.length; |
| 293 int nameCount = names == null ? 0 : names.length; | 301 int nameCount = names == null ? 0 : names.length; |
| 294 int typeCount = namedParameters == null ? 0 : namedParameters.length; | 302 int typeCount = namedParameters == null ? 0 : namedParameters.length; |
| 295 if (names != null && nameCount != typeCount) { | 303 if (names != null && nameCount != typeCount) { |
| 296 throw new IllegalStateException( | 304 throw new IllegalStateException( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 319 } else { | 327 } else { |
| 320 functionElement.returnType = returnElement.type; | 328 functionElement.returnType = returnElement.type; |
| 321 } | 329 } |
| 322 return functionElement; | 330 return functionElement; |
| 323 } | 331 } |
| 324 | 332 |
| 325 static FunctionElementImpl functionElement5( | 333 static FunctionElementImpl functionElement5( |
| 326 String functionName, List<ClassElement> normalParameters) => | 334 String functionName, List<ClassElement> normalParameters) => |
| 327 functionElement3(functionName, null, normalParameters, null); | 335 functionElement3(functionName, null, normalParameters, null); |
| 328 | 336 |
| 329 static FunctionElementImpl functionElement6(String functionName, | 337 static FunctionElementImpl functionElement6( |
| 330 List<ClassElement> normalParameters, | 338 String functionName, |
| 331 List<ClassElement> optionalParameters) => functionElement3( | 339 List<ClassElement> normalParameters, |
| 340 List<ClassElement> optionalParameters) => |
| 341 functionElement3( |
| 332 functionName, null, normalParameters, optionalParameters); | 342 functionName, null, normalParameters, optionalParameters); |
| 333 | 343 |
| 334 static FunctionElementImpl functionElement7(String functionName, | 344 static FunctionElementImpl functionElement7( |
| 335 List<ClassElement> normalParameters, List<String> names, | 345 String functionName, |
| 336 List<ClassElement> namedParameters) => functionElement4( | 346 List<ClassElement> normalParameters, |
| 347 List<String> names, |
| 348 List<ClassElement> namedParameters) => |
| 349 functionElement4( |
| 337 functionName, null, normalParameters, names, namedParameters); | 350 functionName, null, normalParameters, names, namedParameters); |
| 338 | 351 |
| 339 static FunctionElementImpl functionElementWithParameters(String functionName, | 352 static FunctionElementImpl functionElementWithParameters(String functionName, |
| 340 DartType returnType, List<ParameterElement> parameters) { | 353 DartType returnType, List<ParameterElement> parameters) { |
| 341 FunctionElementImpl functionElement = | 354 FunctionElementImpl functionElement = |
| 342 new FunctionElementImpl(functionName, 0); | 355 new FunctionElementImpl(functionName, 0); |
| 343 functionElement.returnType = | 356 functionElement.returnType = |
| 344 returnType == null ? VoidTypeImpl.instance : returnType; | 357 returnType == null ? VoidTypeImpl.instance : returnType; |
| 345 functionElement.parameters = parameters; | 358 functionElement.parameters = parameters; |
| 346 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); | 359 FunctionTypeImpl functionType = new FunctionTypeImpl(functionElement); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 377 static HtmlElementImpl htmlUnit(AnalysisContext context, String fileName) { | 390 static HtmlElementImpl htmlUnit(AnalysisContext context, String fileName) { |
| 378 Source source = | 391 Source source = |
| 379 new NonExistingSource(fileName, toUri(fileName), UriKind.FILE_URI); | 392 new NonExistingSource(fileName, toUri(fileName), UriKind.FILE_URI); |
| 380 HtmlElementImpl unit = new HtmlElementImpl(context, fileName); | 393 HtmlElementImpl unit = new HtmlElementImpl(context, fileName); |
| 381 unit.source = source; | 394 unit.source = source; |
| 382 return unit; | 395 return unit; |
| 383 } | 396 } |
| 384 | 397 |
| 385 static ImportElementImpl importFor( | 398 static ImportElementImpl importFor( |
| 386 LibraryElement importedLibrary, PrefixElement prefix, | 399 LibraryElement importedLibrary, PrefixElement prefix, |
| 387 [List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_LIST])
{ | 400 [List<NamespaceCombinator> combinators = |
| 401 NamespaceCombinator.EMPTY_LIST]) { |
| 388 ImportElementImpl spec = new ImportElementImpl(0); | 402 ImportElementImpl spec = new ImportElementImpl(0); |
| 389 spec.importedLibrary = importedLibrary; | 403 spec.importedLibrary = importedLibrary; |
| 390 spec.prefix = prefix; | 404 spec.prefix = prefix; |
| 391 spec.combinators = combinators; | 405 spec.combinators = combinators; |
| 392 return spec; | 406 return spec; |
| 393 } | 407 } |
| 394 | 408 |
| 395 static LibraryElementImpl library( | 409 static LibraryElementImpl library( |
| 396 AnalysisContext context, String libraryName) { | 410 AnalysisContext context, String libraryName) { |
| 397 String fileName = "/$libraryName.dart"; | 411 String fileName = "/$libraryName.dart"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 423 parameters[i] = parameter; | 437 parameters[i] = parameter; |
| 424 } | 438 } |
| 425 method.parameters = parameters; | 439 method.parameters = parameters; |
| 426 } | 440 } |
| 427 method.returnType = returnType; | 441 method.returnType = returnType; |
| 428 FunctionTypeImpl methodType = new FunctionTypeImpl(method); | 442 FunctionTypeImpl methodType = new FunctionTypeImpl(method); |
| 429 method.type = methodType; | 443 method.type = methodType; |
| 430 return method; | 444 return method; |
| 431 } | 445 } |
| 432 | 446 |
| 433 static MethodElementImpl methodElementWithParameters(String methodName, | 447 static MethodElementImpl methodElementWithParameters( |
| 434 List<DartType> typeArguments, DartType returnType, | 448 String methodName, |
| 449 List<DartType> typeArguments, |
| 450 DartType returnType, |
| 435 List<ParameterElement> parameters) { | 451 List<ParameterElement> parameters) { |
| 436 MethodElementImpl method = new MethodElementImpl(methodName, 0); | 452 MethodElementImpl method = new MethodElementImpl(methodName, 0); |
| 437 method.parameters = parameters; | 453 method.parameters = parameters; |
| 438 method.returnType = returnType; | 454 method.returnType = returnType; |
| 439 FunctionTypeImpl methodType = new FunctionTypeImpl(method); | 455 FunctionTypeImpl methodType = new FunctionTypeImpl(method); |
| 440 methodType.typeArguments = typeArguments; | 456 methodType.typeArguments = typeArguments; |
| 441 method.type = methodType; | 457 method.type = methodType; |
| 442 return method; | 458 return method; |
| 443 } | 459 } |
| 444 | 460 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 variable.getter = getter; | 557 variable.getter = getter; |
| 542 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); | 558 FunctionTypeImpl getterType = new FunctionTypeImpl(getter); |
| 543 getter.type = getterType; | 559 getter.type = getterType; |
| 544 if (!isConst && !isFinal) { | 560 if (!isConst && !isFinal) { |
| 545 PropertyAccessorElementImpl setter = | 561 PropertyAccessorElementImpl setter = |
| 546 new PropertyAccessorElementImpl.forVariable(variable); | 562 new PropertyAccessorElementImpl.forVariable(variable); |
| 547 setter.setter = true; | 563 setter.setter = true; |
| 548 setter.static = true; | 564 setter.static = true; |
| 549 setter.synthetic = true; | 565 setter.synthetic = true; |
| 550 setter.variable = variable; | 566 setter.variable = variable; |
| 551 setter.parameters = | 567 setter.parameters = <ParameterElement>[ |
| 552 <ParameterElement>[requiredParameter2("_$name", type)]; | 568 requiredParameter2("_$name", type) |
| 569 ]; |
| 553 setter.returnType = VoidTypeImpl.instance; | 570 setter.returnType = VoidTypeImpl.instance; |
| 554 setter.type = new FunctionTypeImpl(setter); | 571 setter.type = new FunctionTypeImpl(setter); |
| 555 variable.setter = setter; | 572 variable.setter = setter; |
| 556 } | 573 } |
| 557 return variable; | 574 return variable; |
| 558 } | 575 } |
| 559 | 576 |
| 560 static TypeParameterElementImpl typeParameterElement(String name) { | 577 static TypeParameterElementImpl typeParameterElement(String name) { |
| 561 TypeParameterElementImpl element = new TypeParameterElementImpl(name, 0); | 578 TypeParameterElementImpl element = new TypeParameterElementImpl(name, 0); |
| 562 element.type = new TypeParameterTypeImpl(element); | 579 element.type = new TypeParameterTypeImpl(element); |
| 563 return element; | 580 return element; |
| 564 } | 581 } |
| 565 } | 582 } |
| OLD | NEW |