Index: pkg/analyzer/lib/src/generated/testing/element_factory.dart |
diff --git a/pkg/analyzer/lib/src/generated/testing/element_factory.dart b/pkg/analyzer/lib/src/generated/testing/element_factory.dart |
index a7a52e2be248d874aeecb1c386a66deab7d75b21..c19828416b4533f5dad3d02b4f91794ef68955a0 100644 |
--- a/pkg/analyzer/lib/src/generated/testing/element_factory.dart |
+++ b/pkg/analyzer/lib/src/generated/testing/element_factory.dart |
@@ -8,14 +8,15 @@ |
library engine.testing.element_factory; |
import 'dart:collection'; |
-import 'package:analyzer/src/generated/java_core.dart'; |
-import 'package:analyzer/src/generated/utilities_dart.dart'; |
+ |
import 'package:analyzer/src/generated/ast.dart'; |
import 'package:analyzer/src/generated/constant.dart'; |
-import 'package:analyzer/src/generated/source.dart'; |
import 'package:analyzer/src/generated/element.dart'; |
import 'package:analyzer/src/generated/engine.dart'; |
+import 'package:analyzer/src/generated/java_core.dart'; |
import 'package:analyzer/src/generated/resolver.dart'; |
+import 'package:analyzer/src/generated/source.dart'; |
+import 'package:analyzer/src/generated/utilities_dart.dart'; |
/** |
* The class `ElementFactory` defines utility methods used to create elements for testing |
@@ -28,7 +29,17 @@ class ElementFactory { |
*/ |
static ClassElementImpl _objectElement; |
- static ClassElementImpl classElement(String typeName, InterfaceType superclassType, [List<String> parameterNames]) { |
+ static ClassElementImpl get object { |
+ if (_objectElement == null) { |
+ _objectElement = classElement("Object", null); |
+ } |
+ return _objectElement; |
+ } |
+ |
+ static InterfaceType get objectType => object.type; |
+ |
+ static ClassElementImpl classElement(String typeName, |
+ InterfaceType superclassType, [List<String> parameterNames]) { |
ClassElementImpl element = new ClassElementImpl(typeName, 0); |
element.supertype = superclassType; |
InterfaceTypeImpl type = new InterfaceTypeImpl.con1(element); |
@@ -36,13 +47,13 @@ class ElementFactory { |
if (parameterNames != null) { |
int count = parameterNames.length; |
if (count > 0) { |
- List<TypeParameterElementImpl> typeParameters |
- = new List<TypeParameterElementImpl>(count); |
- List<TypeParameterTypeImpl> typeParameterTypes |
- = new List<TypeParameterTypeImpl>(count); |
+ List<TypeParameterElementImpl> typeParameters = |
+ new List<TypeParameterElementImpl>(count); |
+ List<TypeParameterTypeImpl> typeParameterTypes = |
+ new List<TypeParameterTypeImpl>(count); |
for (int i = 0; i < count; i++) { |
- TypeParameterElementImpl typeParameter |
- = new TypeParameterElementImpl(parameterNames[i], 0); |
+ TypeParameterElementImpl typeParameter = |
+ new TypeParameterElementImpl(parameterNames[i], 0); |
typeParameters[i] = typeParameter; |
typeParameterTypes[i] = new TypeParameterTypeImpl(typeParameter); |
typeParameter.type = typeParameterTypes[i]; |
@@ -54,8 +65,9 @@ class ElementFactory { |
return element; |
} |
- static ClassElementImpl classElement2(String typeName, [List<String> parameterNames]) |
- => classElement(typeName, objectType, parameterNames); |
+ static ClassElementImpl classElement2(String typeName, |
+ [List<String> parameterNames]) => |
+ classElement(typeName, objectType, parameterNames); |
static CompilationUnitElementImpl compilationUnit(String fileName) { |
Source source = new NonExistingSource(fileName, UriKind.FILE_URI); |
@@ -64,9 +76,12 @@ class ElementFactory { |
return unit; |
} |
- static ConstructorElementImpl constructorElement(ClassElement definingClass, String name, bool isConst, [List<DartType> argumentTypes]) { |
+ static ConstructorElementImpl constructorElement(ClassElement definingClass, |
+ String name, bool isConst, [List<DartType> argumentTypes]) { |
DartType type = definingClass.type; |
- ConstructorElementImpl constructor = name == null ? new ConstructorElementImpl("", -1) : new ConstructorElementImpl(name, 0); |
+ ConstructorElementImpl constructor = name == null ? |
+ new ConstructorElementImpl("", -1) : |
+ new ConstructorElementImpl(name, 0); |
constructor.const2 = isConst; |
if (argumentTypes != null) { |
int count = argumentTypes.length; |
@@ -87,10 +102,12 @@ class ElementFactory { |
return constructor; |
} |
- static ConstructorElementImpl constructorElement2(ClassElement definingClass, String name, [List<DartType> argumentTypes]) |
- => constructorElement(definingClass, name, false, argumentTypes); |
+ static ConstructorElementImpl constructorElement2(ClassElement definingClass, |
+ String name, [List<DartType> argumentTypes]) => |
+ constructorElement(definingClass, name, false, argumentTypes); |
- static ClassElementImpl enumElement(TypeProvider typeProvider, String enumName, [List<String> constantNames]) { |
+ static ClassElementImpl enumElement(TypeProvider typeProvider, |
+ String enumName, [List<String> constantNames]) { |
// |
// Build the enum. |
// |
@@ -117,7 +134,7 @@ class ElementFactory { |
FieldElementImpl valuesField = new FieldElementImpl("values", -1); |
valuesField.static = true; |
valuesField.const3 = true; |
- valuesField.type = typeProvider.listType.substitute4(<DartType> [enumType]); |
+ valuesField.type = typeProvider.listType.substitute4(<DartType>[enumType]); |
fields.add(valuesField); |
// |
// Build the enum constants. |
@@ -126,14 +143,18 @@ class ElementFactory { |
int constantCount = constantNames.length; |
for (int i = 0; i < constantCount; i++) { |
String constantName = constantNames[i]; |
- FieldElementImpl constantElement = new ConstFieldElementImpl.con2(constantName, -1); |
+ FieldElementImpl constantElement = |
+ new ConstFieldElementImpl.con2(constantName, -1); |
constantElement.static = true; |
constantElement.const3 = true; |
constantElement.type = enumType; |
- HashMap<String, DartObjectImpl> fieldMap = new HashMap<String, DartObjectImpl>(); |
+ HashMap<String, DartObjectImpl> fieldMap = |
+ new HashMap<String, DartObjectImpl>(); |
fieldMap[indexFieldName] = new DartObjectImpl(intType, new IntState(i)); |
- fieldMap[nameFieldName] = new DartObjectImpl(stringType, new StringState(constantName)); |
- DartObjectImpl value = new DartObjectImpl(enumType, new GenericState(fieldMap)); |
+ fieldMap[nameFieldName] = |
+ new DartObjectImpl(stringType, new StringState(constantName)); |
+ DartObjectImpl value = |
+ new DartObjectImpl(enumType, new GenericState(fieldMap)); |
constantElement.evaluationResult = new EvaluationResultImpl.con1(value); |
fields.add(constantElement); |
} |
@@ -142,24 +163,28 @@ class ElementFactory { |
// Finish building the enum. |
// |
enumElement.fields = fields; |
- // Client code isn't allowed to invoke the constructor, so we do not model it. |
+ |
+ // Client code isn't allowed to invoke the constructor, so we do not model it. |
return enumElement; |
} |
- static ExportElementImpl exportFor(LibraryElement exportedLibrary, [List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY]) { |
+ static ExportElementImpl exportFor(LibraryElement exportedLibrary, |
+ [List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY]) { |
ExportElementImpl spec = new ExportElementImpl(); |
spec.exportedLibrary = exportedLibrary; |
spec.combinators = combinators; |
return spec; |
} |
- static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, bool isConst, DartType type) { |
+ static FieldElementImpl fieldElement(String name, bool isStatic, bool isFinal, |
+ bool isConst, DartType type) { |
FieldElementImpl field = new FieldElementImpl(name, 0); |
field.const3 = isConst; |
field.final2 = isFinal; |
field.static = isStatic; |
field.type = type; |
- PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.forVariable(field); |
+ PropertyAccessorElementImpl getter = |
+ new PropertyAccessorElementImpl.forVariable(field); |
getter.getter = true; |
getter.synthetic = true; |
getter.variable = field; |
@@ -168,11 +193,13 @@ class ElementFactory { |
FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); |
getter.type = getterType; |
if (!isConst && !isFinal) { |
- PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.forVariable(field); |
+ PropertyAccessorElementImpl setter = |
+ new PropertyAccessorElementImpl.forVariable(field); |
setter.setter = true; |
setter.synthetic = true; |
setter.variable = field; |
- setter.parameters = <ParameterElement> [requiredParameter2("_$name", type)]; |
+ setter.parameters = |
+ <ParameterElement>[requiredParameter2("_$name", type)]; |
setter.returnType = VoidTypeImpl.instance; |
setter.type = new FunctionTypeImpl.con1(setter); |
field.setter = setter; |
@@ -180,15 +207,23 @@ class ElementFactory { |
return field; |
} |
- static FieldFormalParameterElementImpl fieldFormalParameter(Identifier name) => new FieldFormalParameterElementImpl(name); |
+ static FieldFormalParameterElementImpl |
+ fieldFormalParameter(Identifier name) => |
+ new FieldFormalParameterElementImpl(name); |
- static FunctionElementImpl functionElement(String functionName) => functionElement4(functionName, null, null, null, null); |
+ static FunctionElementImpl functionElement(String functionName) => |
+ functionElement4(functionName, null, null, null, null); |
- static FunctionElementImpl functionElement2(String functionName, ClassElement returnElement) => functionElement3(functionName, returnElement, null, null); |
+ static FunctionElementImpl functionElement2(String functionName, |
+ ClassElement returnElement) => |
+ functionElement3(functionName, returnElement, null, null); |
- static FunctionElementImpl functionElement3(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<ClassElement> optionalParameters) { |
+ static FunctionElementImpl functionElement3(String functionName, |
+ ClassElement returnElement, List<ClassElement> normalParameters, |
+ List<ClassElement> optionalParameters) { |
// We don't create parameter elements because we don't have parameter names |
- FunctionElementImpl functionElement = new FunctionElementImpl(functionName, 0); |
+ FunctionElementImpl functionElement = |
+ new FunctionElementImpl(functionName, 0); |
FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
functionElement.type = functionType; |
// return type |
@@ -199,7 +234,8 @@ class ElementFactory { |
} |
// parameters |
int normalCount = normalParameters == null ? 0 : normalParameters.length; |
- int optionalCount = optionalParameters == null ? 0 : optionalParameters.length; |
+ int optionalCount = |
+ optionalParameters == null ? 0 : optionalParameters.length; |
int totalCount = normalCount + optionalCount; |
List<ParameterElement> parameters = new List<ParameterElement>(totalCount); |
for (int i = 0; i < totalCount; i++) { |
@@ -218,8 +254,11 @@ class ElementFactory { |
return functionElement; |
} |
- static FunctionElementImpl functionElement4(String functionName, ClassElement returnElement, List<ClassElement> normalParameters, List<String> names, List<ClassElement> namedParameters) { |
- FunctionElementImpl functionElement = new FunctionElementImpl(functionName, 0); |
+ static FunctionElementImpl functionElement4(String functionName, |
+ ClassElement returnElement, List<ClassElement> normalParameters, |
+ List<String> names, List<ClassElement> namedParameters) { |
+ FunctionElementImpl functionElement = |
+ new FunctionElementImpl(functionName, 0); |
FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
functionElement.type = functionType; |
// parameters |
@@ -227,7 +266,8 @@ class ElementFactory { |
int nameCount = names == null ? 0 : names.length; |
int typeCount = namedParameters == null ? 0 : namedParameters.length; |
if (names != null && nameCount != typeCount) { |
- throw new IllegalStateException("The passed String[] and ClassElement[] arrays had different lengths."); |
+ throw new IllegalStateException( |
+ "The passed String[] and ClassElement[] arrays had different lengths."); |
} |
int totalCount = normalCount + nameCount; |
List<ParameterElement> parameters = new List<ParameterElement>(totalCount); |
@@ -238,7 +278,8 @@ class ElementFactory { |
parameter.parameterKind = ParameterKind.REQUIRED; |
parameters[i] = parameter; |
} else { |
- ParameterElementImpl parameter = new ParameterElementImpl(names[i - normalCount], i); |
+ ParameterElementImpl parameter = |
+ new ParameterElementImpl(names[i - normalCount], i); |
parameter.type = namedParameters[i - normalCount].type; |
parameter.parameterKind = ParameterKind.NAMED; |
parameters[i] = parameter; |
@@ -254,36 +295,39 @@ class ElementFactory { |
return functionElement; |
} |
- static FunctionElementImpl functionElement5(String functionName, List<ClassElement> normalParameters) => functionElement3(functionName, null, normalParameters, null); |
- |
- static FunctionElementImpl functionElement6(String functionName, List<ClassElement> normalParameters, List<ClassElement> optionalParameters) => functionElement3(functionName, null, normalParameters, optionalParameters); |
- |
- static FunctionElementImpl functionElement7(String functionName, List<ClassElement> normalParameters, List<String> names, List<ClassElement> namedParameters) => functionElement4(functionName, null, normalParameters, names, namedParameters); |
- |
- static FunctionElementImpl functionElementWithParameters(String functionName, DartType returnType, List<ParameterElement> parameters) { |
- FunctionElementImpl functionElement = new FunctionElementImpl(functionName, 0); |
- functionElement.returnType = returnType == null ? VoidTypeImpl.instance : returnType; |
+ static FunctionElementImpl functionElement5(String functionName, |
+ List<ClassElement> normalParameters) => |
+ functionElement3(functionName, null, normalParameters, null); |
+ |
+ static FunctionElementImpl functionElement6(String functionName, |
+ List<ClassElement> normalParameters, List<ClassElement> optionalParameters) => |
+ functionElement3(functionName, null, normalParameters, optionalParameters); |
+ |
+ static FunctionElementImpl functionElement7(String functionName, |
+ List<ClassElement> normalParameters, List<String> names, |
+ List<ClassElement> namedParameters) => |
+ functionElement4(functionName, null, normalParameters, names, namedParameters); |
+ |
+ static FunctionElementImpl functionElementWithParameters(String functionName, |
+ DartType returnType, List<ParameterElement> parameters) { |
+ FunctionElementImpl functionElement = |
+ new FunctionElementImpl(functionName, 0); |
+ functionElement.returnType = |
+ returnType == null ? VoidTypeImpl.instance : returnType; |
functionElement.parameters = parameters; |
FunctionTypeImpl functionType = new FunctionTypeImpl.con1(functionElement); |
functionElement.type = functionType; |
return functionElement; |
} |
- static ClassElementImpl get object { |
- if (_objectElement == null) { |
- _objectElement = classElement("Object", null); |
- } |
- return _objectElement; |
- } |
- |
- static InterfaceType get objectType => object.type; |
- |
- static PropertyAccessorElementImpl getterElement(String name, bool isStatic, DartType type) { |
+ static PropertyAccessorElementImpl getterElement(String name, bool isStatic, |
+ DartType type) { |
FieldElementImpl field = new FieldElementImpl(name, -1); |
field.static = isStatic; |
field.synthetic = true; |
field.type = type; |
- PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.forVariable(field); |
+ PropertyAccessorElementImpl getter = |
+ new PropertyAccessorElementImpl.forVariable(field); |
getter.getter = true; |
getter.variable = field; |
getter.returnType = type; |
@@ -300,7 +344,9 @@ class ElementFactory { |
return unit; |
} |
- static ImportElementImpl importFor(LibraryElement importedLibrary, PrefixElement prefix, [List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY]) { |
+ static ImportElementImpl importFor(LibraryElement importedLibrary, |
+ PrefixElement prefix, [List<NamespaceCombinator> combinators = |
+ NamespaceCombinator.EMPTY_ARRAY]) { |
ImportElementImpl spec = new ImportElementImpl(0); |
spec.importedLibrary = importedLibrary; |
spec.prefix = prefix; |
@@ -308,19 +354,24 @@ class ElementFactory { |
return spec; |
} |
- static LibraryElementImpl library(AnalysisContext context, String libraryName) { |
+ static LibraryElementImpl library(AnalysisContext context, |
+ String libraryName) { |
String fileName = "/$libraryName.dart"; |
CompilationUnitElementImpl unit = compilationUnit(fileName); |
- LibraryElementImpl library = new LibraryElementImpl(context, libraryName, 0); |
+ LibraryElementImpl library = |
+ new LibraryElementImpl(context, libraryName, 0); |
library.definingCompilationUnit = unit; |
return library; |
} |
- static LocalVariableElementImpl localVariableElement(Identifier name) => new LocalVariableElementImpl.forNode(name); |
+ static LocalVariableElementImpl localVariableElement(Identifier name) => |
+ new LocalVariableElementImpl.forNode(name); |
- static LocalVariableElementImpl localVariableElement2(String name) => new LocalVariableElementImpl(name, 0); |
+ static LocalVariableElementImpl localVariableElement2(String name) => |
+ new LocalVariableElementImpl(name, 0); |
- static MethodElementImpl methodElement(String methodName, DartType returnType, [List<DartType> argumentTypes]) { |
+ static MethodElementImpl methodElement(String methodName, DartType returnType, |
+ [List<DartType> argumentTypes]) { |
MethodElementImpl method = new MethodElementImpl(methodName, 0); |
if (argumentTypes == null) { |
method.parameters = ParameterElementImpl.EMPTY_ARRAY; |
@@ -341,7 +392,9 @@ class ElementFactory { |
return method; |
} |
- static MethodElementImpl methodElementWithParameters(String methodName, List<DartType> typeArguments, DartType returnType, List<ParameterElement> parameters) { |
+ static MethodElementImpl methodElementWithParameters(String methodName, |
+ List<DartType> typeArguments, DartType returnType, |
+ List<ParameterElement> parameters) { |
MethodElementImpl method = new MethodElementImpl(methodName, 0); |
method.parameters = parameters; |
method.returnType = returnType; |
@@ -377,7 +430,8 @@ class ElementFactory { |
return parameter; |
} |
- static PrefixElementImpl prefix(String name) => new PrefixElementImpl(name, 0); |
+ static PrefixElementImpl prefix(String name) => |
+ new PrefixElementImpl(name, 0); |
static ParameterElementImpl requiredParameter(String name) { |
ParameterElementImpl parameter = new ParameterElementImpl(name, 0); |
@@ -392,12 +446,14 @@ class ElementFactory { |
return parameter; |
} |
- static PropertyAccessorElementImpl setterElement(String name, bool isStatic, DartType type) { |
+ static PropertyAccessorElementImpl setterElement(String name, bool isStatic, |
+ DartType type) { |
FieldElementImpl field = new FieldElementImpl(name, -1); |
field.static = isStatic; |
field.synthetic = true; |
field.type = type; |
- PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.forVariable(field); |
+ PropertyAccessorElementImpl getter = |
+ new PropertyAccessorElementImpl.forVariable(field); |
getter.getter = true; |
getter.variable = field; |
getter.returnType = type; |
@@ -405,27 +461,33 @@ class ElementFactory { |
FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); |
getter.type = getterType; |
ParameterElementImpl parameter = requiredParameter2("a", type); |
- PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.forVariable(field); |
+ PropertyAccessorElementImpl setter = |
+ new PropertyAccessorElementImpl.forVariable(field); |
setter.setter = true; |
setter.synthetic = true; |
setter.variable = field; |
- setter.parameters = <ParameterElement> [parameter]; |
+ setter.parameters = <ParameterElement>[parameter]; |
setter.returnType = VoidTypeImpl.instance; |
setter.type = new FunctionTypeImpl.con1(setter); |
field.setter = setter; |
return setter; |
} |
- static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => new TopLevelVariableElementImpl.forNode(name); |
+ static TopLevelVariableElementImpl topLevelVariableElement(Identifier name) => |
+ new TopLevelVariableElementImpl.forNode(name); |
- static TopLevelVariableElementImpl topLevelVariableElement2(String name) => topLevelVariableElement3(name, false, false, null); |
+ static TopLevelVariableElementImpl topLevelVariableElement2(String name) => |
+ topLevelVariableElement3(name, false, false, null); |
- static TopLevelVariableElementImpl topLevelVariableElement3(String name, bool isConst, bool isFinal, DartType type) { |
- TopLevelVariableElementImpl variable = new TopLevelVariableElementImpl(name, -1); |
+ static TopLevelVariableElementImpl topLevelVariableElement3(String name, |
+ bool isConst, bool isFinal, DartType type) { |
+ TopLevelVariableElementImpl variable = |
+ new TopLevelVariableElementImpl(name, -1); |
variable.const3 = isConst; |
variable.final2 = isFinal; |
variable.synthetic = true; |
- PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.forVariable(variable); |
+ PropertyAccessorElementImpl getter = |
+ new PropertyAccessorElementImpl.forVariable(variable); |
getter.getter = true; |
getter.synthetic = true; |
getter.variable = variable; |
@@ -434,16 +496,18 @@ class ElementFactory { |
FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter); |
getter.type = getterType; |
if (!isFinal) { |
- PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.forVariable(variable); |
+ PropertyAccessorElementImpl setter = |
+ new PropertyAccessorElementImpl.forVariable(variable); |
setter.setter = true; |
setter.static = true; |
setter.synthetic = true; |
setter.variable = variable; |
- setter.parameters = <ParameterElement> [requiredParameter2("_$name", type)]; |
+ setter.parameters = |
+ <ParameterElement>[requiredParameter2("_$name", type)]; |
setter.returnType = VoidTypeImpl.instance; |
setter.type = new FunctionTypeImpl.con1(setter); |
variable.setter = setter; |
} |
return variable; |
} |
-} |
+} |