| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return unit; | 58 return unit; |
| 59 } | 59 } |
| 60 | 60 |
| 61 static ConstructorElementImpl constructorElement(ClassElement definingClass, S
tring name, bool isConst, List<DartType> argumentTypes) { | 61 static ConstructorElementImpl constructorElement(ClassElement definingClass, S
tring name, bool isConst, List<DartType> argumentTypes) { |
| 62 DartType type = definingClass.type; | 62 DartType type = definingClass.type; |
| 63 ConstructorElementImpl constructor = name == null ? new ConstructorElementIm
pl("", -1) : new ConstructorElementImpl(name, 0); | 63 ConstructorElementImpl constructor = name == null ? new ConstructorElementIm
pl("", -1) : new ConstructorElementImpl(name, 0); |
| 64 constructor.const2 = isConst; | 64 constructor.const2 = isConst; |
| 65 int count = argumentTypes.length; | 65 int count = argumentTypes.length; |
| 66 List<ParameterElement> parameters = new List<ParameterElement>(count); | 66 List<ParameterElement> parameters = new List<ParameterElement>(count); |
| 67 for (int i = 0; i < count; i++) { | 67 for (int i = 0; i < count; i++) { |
| 68 ParameterElementImpl parameter = new ParameterElementImpl("a${i}", i); | 68 ParameterElementImpl parameter = new ParameterElementImpl("a$i", i); |
| 69 parameter.type = argumentTypes[i]; | 69 parameter.type = argumentTypes[i]; |
| 70 parameter.parameterKind = ParameterKind.REQUIRED; | 70 parameter.parameterKind = ParameterKind.REQUIRED; |
| 71 parameters[i] = parameter; | 71 parameters[i] = parameter; |
| 72 } | 72 } |
| 73 constructor.parameters = parameters; | 73 constructor.parameters = parameters; |
| 74 constructor.returnType = type; | 74 constructor.returnType = type; |
| 75 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); | 75 FunctionTypeImpl constructorType = new FunctionTypeImpl.con1(constructor); |
| 76 constructor.type = constructorType; | 76 constructor.type = constructorType; |
| 77 return constructor; | 77 return constructor; |
| 78 } | 78 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 getter.variable = field; | 152 getter.variable = field; |
| 153 getter.returnType = type; | 153 getter.returnType = type; |
| 154 field.getter = getter; | 154 field.getter = getter; |
| 155 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); | 155 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); |
| 156 getter.type = getterType; | 156 getter.type = getterType; |
| 157 if (!isConst && !isFinal) { | 157 if (!isConst && !isFinal) { |
| 158 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.forVa
riable(field); | 158 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.forVa
riable(field); |
| 159 setter.setter = true; | 159 setter.setter = true; |
| 160 setter.synthetic = true; | 160 setter.synthetic = true; |
| 161 setter.variable = field; | 161 setter.variable = field; |
| 162 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ
e)]; | 162 setter.parameters = <ParameterElement> [requiredParameter2("_$name", type)
]; |
| 163 setter.returnType = VoidTypeImpl.instance; | 163 setter.returnType = VoidTypeImpl.instance; |
| 164 setter.type = new FunctionTypeImpl.con1(setter); | 164 setter.type = new FunctionTypeImpl.con1(setter); |
| 165 field.setter = setter; | 165 field.setter = setter; |
| 166 } | 166 } |
| 167 return field; | 167 return field; |
| 168 } | 168 } |
| 169 | 169 |
| 170 static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) =
> new FieldFormalParameterElementImpl(name); | 170 static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) =
> new FieldFormalParameterElementImpl(name); |
| 171 | 171 |
| 172 static FunctionElementImpl functionElement(String functionName) => functionEle
ment4(functionName, null, null, null, null); | 172 static FunctionElementImpl functionElement(String functionName) => functionEle
ment4(functionName, null, null, null, null); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 183 functionElement.returnType = VoidTypeImpl.instance; | 183 functionElement.returnType = VoidTypeImpl.instance; |
| 184 } else { | 184 } else { |
| 185 functionElement.returnType = returnElement.type; | 185 functionElement.returnType = returnElement.type; |
| 186 } | 186 } |
| 187 // parameters | 187 // parameters |
| 188 int normalCount = normalParameters == null ? 0 : normalParameters.length; | 188 int normalCount = normalParameters == null ? 0 : normalParameters.length; |
| 189 int optionalCount = optionalParameters == null ? 0 : optionalParameters.leng
th; | 189 int optionalCount = optionalParameters == null ? 0 : optionalParameters.leng
th; |
| 190 int totalCount = normalCount + optionalCount; | 190 int totalCount = normalCount + optionalCount; |
| 191 List<ParameterElement> parameters = new List<ParameterElement>(totalCount); | 191 List<ParameterElement> parameters = new List<ParameterElement>(totalCount); |
| 192 for (int i = 0; i < totalCount; i++) { | 192 for (int i = 0; i < totalCount; i++) { |
| 193 ParameterElementImpl parameter = new ParameterElementImpl("a${i}", i); | 193 ParameterElementImpl parameter = new ParameterElementImpl("a$i", i); |
| 194 if (i < normalCount) { | 194 if (i < normalCount) { |
| 195 parameter.type = normalParameters[i].type; | 195 parameter.type = normalParameters[i].type; |
| 196 parameter.parameterKind = ParameterKind.REQUIRED; | 196 parameter.parameterKind = ParameterKind.REQUIRED; |
| 197 } else { | 197 } else { |
| 198 parameter.type = optionalParameters[i - normalCount].type; | 198 parameter.type = optionalParameters[i - normalCount].type; |
| 199 parameter.parameterKind = ParameterKind.POSITIONAL; | 199 parameter.parameterKind = ParameterKind.POSITIONAL; |
| 200 } | 200 } |
| 201 parameters[i] = parameter; | 201 parameters[i] = parameter; |
| 202 } | 202 } |
| 203 functionElement.parameters = parameters; | 203 functionElement.parameters = parameters; |
| 204 // done | 204 // done |
| 205 return functionElement; | 205 return functionElement; |
| 206 } | 206 } |
| 207 | 207 |
| 208 static FunctionElementImpl functionElement4(String functionName, ClassElement
returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla
ssElement> namedParameters) { | 208 static FunctionElementImpl functionElement4(String functionName, ClassElement
returnElement, List<ClassElement> normalParameters, List<String> names, List<Cla
ssElement> namedParameters) { |
| 209 FunctionElementImpl functionElement = new FunctionElementImpl(functionName,
0); | 209 FunctionElementImpl functionElement = new FunctionElementImpl(functionName,
0); |
| 210 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); | 210 FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
| 211 functionElement.type = functionType; | 211 functionElement.type = functionType; |
| 212 // parameters | 212 // parameters |
| 213 int normalCount = normalParameters == null ? 0 : normalParameters.length; | 213 int normalCount = normalParameters == null ? 0 : normalParameters.length; |
| 214 int nameCount = names == null ? 0 : names.length; | 214 int nameCount = names == null ? 0 : names.length; |
| 215 int typeCount = namedParameters == null ? 0 : namedParameters.length; | 215 int typeCount = namedParameters == null ? 0 : namedParameters.length; |
| 216 if (names != null && nameCount != typeCount) { | 216 if (names != null && nameCount != typeCount) { |
| 217 throw new IllegalStateException("The passed String[] and ClassElement[] ar
rays had different lengths."); | 217 throw new IllegalStateException("The passed String[] and ClassElement[] ar
rays had different lengths."); |
| 218 } | 218 } |
| 219 int totalCount = normalCount + nameCount; | 219 int totalCount = normalCount + nameCount; |
| 220 List<ParameterElement> parameters = new List<ParameterElement>(totalCount); | 220 List<ParameterElement> parameters = new List<ParameterElement>(totalCount); |
| 221 for (int i = 0; i < totalCount; i++) { | 221 for (int i = 0; i < totalCount; i++) { |
| 222 if (i < normalCount) { | 222 if (i < normalCount) { |
| 223 ParameterElementImpl parameter = new ParameterElementImpl("a${i}", i); | 223 ParameterElementImpl parameter = new ParameterElementImpl("a$i", i); |
| 224 parameter.type = normalParameters[i].type; | 224 parameter.type = normalParameters[i].type; |
| 225 parameter.parameterKind = ParameterKind.REQUIRED; | 225 parameter.parameterKind = ParameterKind.REQUIRED; |
| 226 parameters[i] = parameter; | 226 parameters[i] = parameter; |
| 227 } else { | 227 } else { |
| 228 ParameterElementImpl parameter = new ParameterElementImpl(names[i - norm
alCount], i); | 228 ParameterElementImpl parameter = new ParameterElementImpl(names[i - norm
alCount], i); |
| 229 parameter.type = namedParameters[i - normalCount].type; | 229 parameter.type = namedParameters[i - normalCount].type; |
| 230 parameter.parameterKind = ParameterKind.NAMED; | 230 parameter.parameterKind = ParameterKind.NAMED; |
| 231 parameters[i] = parameter; | 231 parameters[i] = parameter; |
| 232 } | 232 } |
| 233 } | 233 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 | 289 |
| 290 static ImportElementImpl importFor(LibraryElement importedLibrary, PrefixEleme
nt prefix, List<NamespaceCombinator> combinators) { | 290 static ImportElementImpl importFor(LibraryElement importedLibrary, PrefixEleme
nt prefix, List<NamespaceCombinator> combinators) { |
| 291 ImportElementImpl spec = new ImportElementImpl(0); | 291 ImportElementImpl spec = new ImportElementImpl(0); |
| 292 spec.importedLibrary = importedLibrary; | 292 spec.importedLibrary = importedLibrary; |
| 293 spec.prefix = prefix; | 293 spec.prefix = prefix; |
| 294 spec.combinators = combinators; | 294 spec.combinators = combinators; |
| 295 return spec; | 295 return spec; |
| 296 } | 296 } |
| 297 | 297 |
| 298 static LibraryElementImpl library(AnalysisContext context, String libraryName)
{ | 298 static LibraryElementImpl library(AnalysisContext context, String libraryName)
{ |
| 299 String fileName = "/${libraryName}.dart"; | 299 String fileName = "/$libraryName.dart"; |
| 300 CompilationUnitElementImpl unit = compilationUnit(fileName); | 300 CompilationUnitElementImpl unit = compilationUnit(fileName); |
| 301 LibraryElementImpl library = new LibraryElementImpl(context, libraryName, 0)
; | 301 LibraryElementImpl library = new LibraryElementImpl(context, libraryName, 0)
; |
| 302 library.definingCompilationUnit = unit; | 302 library.definingCompilationUnit = unit; |
| 303 return library; | 303 return library; |
| 304 } | 304 } |
| 305 | 305 |
| 306 static LocalVariableElementImpl localVariableElement(Identifier name) => new L
ocalVariableElementImpl.forNode(name); | 306 static LocalVariableElementImpl localVariableElement(Identifier name) => new L
ocalVariableElementImpl.forNode(name); |
| 307 | 307 |
| 308 static LocalVariableElementImpl localVariableElement2(String name) => new Loca
lVariableElementImpl(name, 0); | 308 static LocalVariableElementImpl localVariableElement2(String name) => new Loca
lVariableElementImpl(name, 0); |
| 309 | 309 |
| 310 static MethodElementImpl methodElement(String methodName, DartType returnType,
List<DartType> argumentTypes) { | 310 static MethodElementImpl methodElement(String methodName, DartType returnType,
List<DartType> argumentTypes) { |
| 311 MethodElementImpl method = new MethodElementImpl(methodName, 0); | 311 MethodElementImpl method = new MethodElementImpl(methodName, 0); |
| 312 int count = argumentTypes.length; | 312 int count = argumentTypes.length; |
| 313 List<ParameterElement> parameters = new List<ParameterElement>(count); | 313 List<ParameterElement> parameters = new List<ParameterElement>(count); |
| 314 for (int i = 0; i < count; i++) { | 314 for (int i = 0; i < count; i++) { |
| 315 ParameterElementImpl parameter = new ParameterElementImpl("a${i}", i); | 315 ParameterElementImpl parameter = new ParameterElementImpl("a$i", i); |
| 316 parameter.type = argumentTypes[i]; | 316 parameter.type = argumentTypes[i]; |
| 317 parameter.parameterKind = ParameterKind.REQUIRED; | 317 parameter.parameterKind = ParameterKind.REQUIRED; |
| 318 parameters[i] = parameter; | 318 parameters[i] = parameter; |
| 319 } | 319 } |
| 320 method.parameters = parameters; | 320 method.parameters = parameters; |
| 321 method.returnType = returnType; | 321 method.returnType = returnType; |
| 322 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method); | 322 FunctionTypeImpl methodType = new FunctionTypeImpl.con1(method); |
| 323 method.type = methodType; | 323 method.type = methodType; |
| 324 return method; | 324 return method; |
| 325 } | 325 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 getter.returnType = type; | 415 getter.returnType = type; |
| 416 variable.getter = getter; | 416 variable.getter = getter; |
| 417 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); | 417 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); |
| 418 getter.type = getterType; | 418 getter.type = getterType; |
| 419 if (!isFinal) { | 419 if (!isFinal) { |
| 420 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.forVa
riable(variable); | 420 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.forVa
riable(variable); |
| 421 setter.setter = true; | 421 setter.setter = true; |
| 422 setter.static = true; | 422 setter.static = true; |
| 423 setter.synthetic = true; | 423 setter.synthetic = true; |
| 424 setter.variable = variable; | 424 setter.variable = variable; |
| 425 setter.parameters = <ParameterElement> [requiredParameter2("_${name}", typ
e)]; | 425 setter.parameters = <ParameterElement> [requiredParameter2("_$name", type)
]; |
| 426 setter.returnType = VoidTypeImpl.instance; | 426 setter.returnType = VoidTypeImpl.instance; |
| 427 setter.type = new FunctionTypeImpl.con1(setter); | 427 setter.type = new FunctionTypeImpl.con1(setter); |
| 428 variable.setter = setter; | 428 variable.setter = setter; |
| 429 } | 429 } |
| 430 return variable; | 430 return variable; |
| 431 } | 431 } |
| 432 } | 432 } |
| OLD | NEW |