Index: packages/analyzer/lib/src/generated/element.dart |
diff --git a/analyzer/lib/src/generated/element.dart b/packages/analyzer/lib/src/generated/element.dart |
similarity index 96% |
rename from analyzer/lib/src/generated/element.dart |
rename to packages/analyzer/lib/src/generated/element.dart |
index 395dc279bd27b3188309a951b9357939029f5705..9e7aeb4825871cb6b0c974897742ebf56df78838 100644 |
--- a/analyzer/lib/src/generated/element.dart |
+++ b/packages/analyzer/lib/src/generated/element.dart |
@@ -2,12 +2,10 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-// This code was auto-generated, is not intended to be edited, and is subject to |
-// significant change. Please see the README file for more information. |
- |
library engine.element; |
import 'dart:collection'; |
+import 'dart:math' show min; |
import 'package:analyzer/src/generated/utilities_general.dart'; |
import 'package:analyzer/src/task/dart.dart'; |
@@ -85,7 +83,8 @@ class BottomTypeImpl extends TypeImpl { |
@override |
bool isMoreSpecificThan(DartType type, |
- [bool withDynamic = false, Set<Element> visitedElements]) => true; |
+ [bool withDynamic = false, Set<Element> visitedElements]) => |
+ true; |
@override |
bool isSubtypeOf(DartType type) => true; |
@@ -98,8 +97,9 @@ class BottomTypeImpl extends TypeImpl { |
@override |
BottomTypeImpl substitute2( |
- List<DartType> argumentTypes, List<DartType> parameterTypes, |
- [List<FunctionTypeAliasElement> prune]) => this; |
+ List<DartType> argumentTypes, List<DartType> parameterTypes, |
+ [List<FunctionTypeAliasElement> prune]) => |
+ this; |
} |
/** |
@@ -554,6 +554,12 @@ class ClassElementImpl extends ElementImpl implements ClassElement { |
SourceRange withClauseRange; |
/** |
+ * A flag indicating whether the types associated with the instance members of |
+ * this class have been inferred. |
+ */ |
+ bool hasBeenInferred = false; |
+ |
+ /** |
* Initialize a newly created class element to have the given [name] at the |
* given [offset] in the file that contains the declaration of this element. |
*/ |
@@ -1154,8 +1160,8 @@ class ClassElementImpl extends ElementImpl implements ClassElement { |
if (definingClass is! ClassElementImpl) { |
return null; |
} |
- getter = (definingClass as ClassElementImpl)._internalLookUpGetter( |
- getterName, library, false); |
+ getter = (definingClass as ClassElementImpl) |
+ ._internalLookUpGetter(getterName, library, false); |
} |
return getter; |
} |
@@ -1183,8 +1189,8 @@ class ClassElementImpl extends ElementImpl implements ClassElement { |
if (definingClass is! ClassElementImpl) { |
return null; |
} |
- setter = (definingClass as ClassElementImpl)._internalLookUpSetter( |
- setterName, library, false); |
+ setter = (definingClass as ClassElementImpl) |
+ ._internalLookUpSetter(setterName, library, false); |
} |
return setter; |
} |
@@ -2457,6 +2463,12 @@ abstract class Element implements AnalysisTarget { |
String get displayName; |
/** |
+ * Return the source range of the documentation comment for this element, |
+ * or `null` if this element does not or cannot have a documentation. |
+ */ |
+ SourceRange get docRange; |
+ |
+ /** |
* Return the element that either physically or logically encloses this |
* element. This will be `null` if this element is a library because libraries |
* are the top-level elements in the model. |
@@ -2531,6 +2543,12 @@ abstract class Element implements AnalysisTarget { |
String get name; |
/** |
+ * Return the length of the name of this element in the file that contains the |
+ * declaration of this element, or `0` if this element does not have a name. |
+ */ |
+ int get nameLength; |
+ |
+ /** |
* Return the offset of the name of this element in the file that contains the |
* declaration of this element, or `-1` if this element is synthetic, does not |
* have a name, or otherwise does not have an offset. |
@@ -2538,6 +2556,8 @@ abstract class Element implements AnalysisTarget { |
int get nameOffset; |
/** |
+ * **DEPRECATED** Use `computeNode()` instead. |
+ * |
* Return the resolved [AstNode] node that declares this element, or `null` if |
* this element is synthetic or isn't contained in a compilation unit, such as |
* a [LibraryElement]. |
@@ -2815,6 +2835,17 @@ abstract class ElementImpl implements Element { |
ElementLocation _cachedLocation; |
/** |
+ * The offset to the beginning of the documentation comment, |
+ * or `null` if this element does not have a documentation comment. |
+ */ |
+ int _docRangeOffset; |
+ |
+ /** |
+ * The length of the documentation comment range for this element. |
+ */ |
+ int _docRangeLength; |
+ |
+ /** |
* Initialize a newly created element to have the given [name] at the given |
* [_nameOffset]. |
*/ |
@@ -2840,6 +2871,14 @@ abstract class ElementImpl implements Element { |
String get displayName => _name; |
@override |
+ SourceRange get docRange { |
+ if (_docRangeOffset != null && _docRangeLength != null) { |
+ return new SourceRange(_docRangeOffset, _docRangeLength); |
+ } |
+ return null; |
+ } |
+ |
+ @override |
Element get enclosingElement => _enclosingElement; |
/** |
@@ -2929,10 +2968,10 @@ abstract class ElementImpl implements Element { |
_cachedHashCode = null; |
} |
- /** |
- * The offset of the name of this element in the file that contains the |
- * declaration of this element. |
- */ |
+ @override |
+ int get nameLength => displayName != null ? displayName.length : 0; |
+ |
+ @override |
int get nameOffset => _nameOffset; |
/** |
@@ -3089,6 +3128,14 @@ abstract class ElementImpl implements Element { |
} |
/** |
+ * Set the documentation comment source range for this element. |
+ */ |
+ void setDocRange(int offset, int length) { |
+ _docRangeOffset = offset; |
+ _docRangeLength = length; |
+ } |
+ |
+ /** |
* Set whether the given [modifier] is associated with this element to |
* correspond to the given [value]. |
*/ |
@@ -3522,6 +3569,14 @@ abstract class ExecutableElement implements Element { |
List<FunctionElement> get functions; |
/** |
+ * Return `true` if this executable element did not have an explicit return |
+ * type specified for it in the original source. Note that if there was no |
+ * explicit return type, and if the element model is fully populated, then |
+ * the [returnType] will not be `null`. |
+ */ |
+ bool get hasImplicitReturnType; |
+ |
+ /** |
* Return `true` if this executable element is abstract. Executable elements |
* are abstract if they are not external and have no body. |
*/ |
@@ -3585,7 +3640,9 @@ abstract class ExecutableElement implements Element { |
List<ParameterElement> get parameters; |
/** |
- * Return the return type defined by this executable element. |
+ * Return the return type defined by this executable element. If the element |
+ * model is fully populated, then the [returnType] will not be `null`, even |
+ * if no return type was explicitly specified. |
*/ |
DartType get returnType; |
@@ -3698,6 +3755,16 @@ abstract class ExecutableElementImpl extends ElementImpl |
} |
@override |
+ bool get hasImplicitReturnType => hasModifier(Modifier.IMPLICIT_TYPE); |
+ |
+ /** |
+ * Set whether this executable element has an implicit return type. |
+ */ |
+ void set hasImplicitReturnType(bool hasImplicitReturnType) { |
+ setModifier(Modifier.IMPLICIT_TYPE, hasImplicitReturnType); |
+ } |
+ |
+ @override |
bool get isAbstract => hasModifier(Modifier.ABSTRACT); |
@override |
@@ -3884,6 +3951,9 @@ abstract class ExecutableMember extends Member implements ExecutableElement { |
} |
@override |
+ bool get hasImplicitReturnType => baseElement.hasImplicitReturnType; |
+ |
+ @override |
bool get isAbstract => baseElement.isAbstract; |
@override |
@@ -4087,7 +4157,8 @@ abstract class FieldElement |
* A concrete implementation of a [FieldElement]. |
*/ |
class FieldElementImpl extends PropertyInducingElementImpl |
- with PotentiallyConstVariableElement implements FieldElement { |
+ with PotentiallyConstVariableElement |
+ implements FieldElement { |
/** |
* An empty list of field elements. |
*/ |
@@ -4113,9 +4184,6 @@ class FieldElementImpl extends PropertyInducingElementImpl |
enclosingElement != null ? enclosingElement.isEnum : false; |
@override |
- bool get isStatic => hasModifier(Modifier.STATIC); |
- |
- @override |
ElementKind get kind => ElementKind.FIELD; |
/** |
@@ -4230,9 +4298,6 @@ class FieldMember extends VariableMember implements FieldElement { |
bool get isEnumConstant => baseElement.isEnumConstant; |
@override |
- bool get isStatic => baseElement.isStatic; |
- |
- @override |
DartType get propagatedType => substituteFor(baseElement.propagatedType); |
@override |
@@ -4961,8 +5026,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
DartType type = parameter.type; |
if (typeArguments.length != 0 && |
typeArguments.length == typeParameters.length) { |
- type = (type as TypeImpl).substitute2( |
- typeArguments, typeParameters, newPrune); |
+ type = (type as TypeImpl) |
+ .substitute2(typeArguments, typeParameters, newPrune); |
} else { |
type = (type as TypeImpl).pruned(newPrune); |
} |
@@ -5007,8 +5072,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
DartType type = parameter.type; |
if (typeArguments.length != 0 && |
typeArguments.length == typeParameters.length) { |
- type = (type as TypeImpl).substitute2( |
- typeArguments, typeParameters, newPrune); |
+ type = (type as TypeImpl) |
+ .substitute2(typeArguments, typeParameters, newPrune); |
} else { |
type = (type as TypeImpl).pruned(newPrune); |
} |
@@ -5032,8 +5097,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
DartType type = parameter.type; |
if (typeArguments.length != 0 && |
typeArguments.length == typeParameters.length) { |
- type = (type as TypeImpl).substitute2( |
- typeArguments, typeParameters, newPrune); |
+ type = (type as TypeImpl) |
+ .substitute2(typeArguments, typeParameters, newPrune); |
} else { |
type = (type as TypeImpl).pruned(newPrune); |
} |
@@ -5215,8 +5280,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
return false; |
} else if (t.normalParameterTypes.length > 0) { |
for (int i = 0; i < tTypes.length; i++) { |
- if (!(tTypes[i] as TypeImpl).isMoreSpecificThan( |
- sTypes[i], withDynamic)) { |
+ if (!(tTypes[i] as TypeImpl) |
+ .isMoreSpecificThan(sTypes[i], withDynamic)) { |
return false; |
} |
} |
@@ -5236,8 +5301,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
if (typeT == null) { |
return false; |
} |
- if (!(typeT as TypeImpl).isMoreSpecificThan( |
- namedTypesS[keyS], withDynamic)) { |
+ if (!(typeT as TypeImpl) |
+ .isMoreSpecificThan(namedTypesS[keyS], withDynamic)) { |
return false; |
} |
} |
@@ -5257,8 +5322,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
if (tOpTypes.length == 0 && sOpTypes.length == 0) { |
// No positional arguments, don't copy contents to new array |
for (int i = 0; i < sTypes.length; i++) { |
- if (!(tTypes[i] as TypeImpl).isMoreSpecificThan( |
- sTypes[i], withDynamic)) { |
+ if (!(tTypes[i] as TypeImpl) |
+ .isMoreSpecificThan(sTypes[i], withDynamic)) { |
return false; |
} |
} |
@@ -5280,8 +5345,8 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType { |
sAllTypes[i] = sOpTypes[j]; |
} |
for (int i = 0; i < sAllTypes.length; i++) { |
- if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan( |
- sAllTypes[i], withDynamic)) { |
+ if (!(tAllTypes[i] as TypeImpl) |
+ .isMoreSpecificThan(sAllTypes[i], withDynamic)) { |
return false; |
} |
} |
@@ -6633,8 +6698,8 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
return false; |
} |
for (int i = 0; i < tArguments.length; i++) { |
- if (!(tArguments[i] as TypeImpl).isMoreSpecificThan( |
- sArguments[i], withDynamic)) { |
+ if (!(tArguments[i] as TypeImpl) |
+ .isMoreSpecificThan(sArguments[i], withDynamic)) { |
return false; |
} |
} |
@@ -6664,14 +6729,14 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
return true; |
} |
for (InterfaceType interfaceType in interfaces) { |
- if ((interfaceType as InterfaceTypeImpl).isMoreSpecificThan( |
- type, withDynamic, visitedElements)) { |
+ if ((interfaceType as InterfaceTypeImpl) |
+ .isMoreSpecificThan(type, withDynamic, visitedElements)) { |
return true; |
} |
} |
for (InterfaceType mixinType in mixins) { |
- if ((mixinType as InterfaceTypeImpl).isMoreSpecificThan( |
- type, withDynamic, visitedElements)) { |
+ if ((mixinType as InterfaceTypeImpl) |
+ .isMoreSpecificThan(type, withDynamic, visitedElements)) { |
return true; |
} |
} |
@@ -7276,6 +7341,15 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
List<ExportElement> _exports = ExportElement.EMPTY_LIST; |
/** |
+ * A list containing the strongly connected component in the import/export |
+ * graph in which the current library resides. Computed on demand, null |
+ * if not present. If _libraryCycle is set, then the _libraryCycle field |
+ * for all libraries reachable from this library in the import/export graph |
+ * is also set. |
+ */ |
+ List<LibraryElement> _libraryCycle = null; |
+ |
+ /** |
* A list containing all of the compilation units that are included in this |
* library using a `part` directive. |
*/ |
@@ -7287,6 +7361,9 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
*/ |
FunctionElement _loadLibraryFunction; |
+ @override |
+ final int nameLength; |
+ |
/** |
* The export [Namespace] of this library, `null` if it has not been |
* computed yet. |
@@ -7305,7 +7382,7 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
* Initialize a newly created library element in the given [context] to have |
* the given [name] and [offset]. |
*/ |
- LibraryElementImpl(this.context, String name, int offset) |
+ LibraryElementImpl(this.context, String name, int offset, this.nameLength) |
: super(name, offset); |
/** |
@@ -7313,7 +7390,8 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
* the given [name]. |
*/ |
LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |
- : super.forNode(name); |
+ : super.forNode(name), |
+ nameLength = name != null ? name.length : 0; |
@override |
CompilationUnitElement get definingCompilationUnit => |
@@ -7459,6 +7537,69 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
@override |
LibraryElement get library => this; |
+ List<LibraryElement> get libraryCycle { |
+ if (_libraryCycle != null) { |
+ return _libraryCycle; |
+ } |
+ |
+ // Global counter for this run of the algorithm |
+ int counter = 0; |
+ // The discovery times of each library |
+ Map<LibraryElementImpl, int> indices = {}; |
+ // The set of scc candidates |
+ Set<LibraryElementImpl> active = new Set(); |
+ // The stack of discovered elements |
+ List<LibraryElementImpl> stack = []; |
+ // For a given library that has not yet been processed by this run of the |
+ // algorithm, compute the strongly connected components. |
+ int scc(LibraryElementImpl library) { |
+ int index = counter++; |
+ int root = index; |
+ indices[library] = index; |
+ active.add(library); |
+ stack.add(library); |
+ void recurse(LibraryElementImpl child) { |
+ if (!indices.containsKey(child)) { |
+ // We haven't visited this child yet, so recurse on the child, |
+ // returning the lowest numbered node reachable from the child. If |
+ // the child can reach a root which is lower numbered than anything |
+ // we've reached so far, update the root. |
+ root = min(root, scc(child)); |
+ } else if (active.contains(child)) { |
+ // The child has been visited, but has not yet been placed into a |
+ // component. If the child is higher than anything we've seen so far |
+ // update the root appropriately. |
+ root = min(root, indices[child]); |
+ } |
+ } |
+ // Recurse on all of the children in the import/export graph, filtering |
+ // out those for which library cycles have already been computed. |
+ library.exportedLibraries |
+ .where((l) => l._libraryCycle == null) |
+ .forEach(recurse); |
+ library.importedLibraries |
+ .where((l) => l._libraryCycle == null) |
+ .forEach(recurse); |
+ |
+ if (root == index) { |
+ // This is the root of a strongly connected component. |
+ // Pop the elements, and share the component across all |
+ // of the elements. |
+ List<LibraryElement> component = <LibraryElement>[]; |
+ LibraryElementImpl cur = null; |
+ do { |
+ cur = stack.removeLast(); |
+ active.remove(cur); |
+ component.add(cur); |
+ cur._libraryCycle = component; |
+ } while (cur != library); |
+ } |
+ return root; |
+ } |
+ scc(library); |
+ return _libraryCycle; |
+ } |
+ |
@override |
FunctionElement get loadLibraryFunction { |
if (_loadLibraryFunction == null) { |
@@ -7645,8 +7786,8 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
for (ImportElement importElement in _imports) { |
LibraryElement importedLibrary = importElement.importedLibrary; |
if (importedLibrary != null) { |
- (importedLibrary as LibraryElementImpl)._addVisibleLibraries( |
- visibleLibraries, true); |
+ (importedLibrary as LibraryElementImpl) |
+ ._addVisibleLibraries(visibleLibraries, true); |
} |
} |
// add exported libraries |
@@ -7654,8 +7795,8 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement { |
for (ExportElement exportElement in _exports) { |
LibraryElement exportedLibrary = exportElement.exportedLibrary; |
if (exportedLibrary != null) { |
- (exportedLibrary as LibraryElementImpl)._addVisibleLibraries( |
- visibleLibraries, true); |
+ (exportedLibrary as LibraryElementImpl) |
+ ._addVisibleLibraries(visibleLibraries, true); |
} |
} |
} |
@@ -7749,7 +7890,8 @@ abstract class LocalVariableElement implements LocalElement, VariableElement { |
* A concrete implementation of a [LocalVariableElement]. |
*/ |
class LocalVariableElementImpl extends VariableElementImpl |
- with PotentiallyConstVariableElement implements LocalVariableElement { |
+ with PotentiallyConstVariableElement |
+ implements LocalVariableElement { |
/** |
* An empty list of field elements. |
*/ |
@@ -7881,6 +8023,9 @@ abstract class Member implements Element { |
@override |
String get displayName => _baseElement.displayName; |
+ @override |
+ SourceRange get docRange => _baseElement.docRange; |
+ |
int get id => _baseElement.id; |
@override |
@@ -7914,6 +8059,9 @@ abstract class Member implements Element { |
String get name => _baseElement.name; |
@override |
+ int get nameLength => _baseElement.nameLength; |
+ |
+ @override |
int get nameOffset => _baseElement.nameOffset; |
@deprecated |
@@ -8251,45 +8399,52 @@ class Modifier extends Enum<Modifier> { |
static const Modifier HAS_EXT_URI = const Modifier('HAS_EXT_URI', 10); |
/** |
+ * Indicates that the associated element did not have an explicit type |
+ * associated with it. If the element is an [ExecutableElement], then the |
+ * type being referred to is the return type. |
+ */ |
+ static const Modifier IMPLICIT_TYPE = const Modifier('IMPLICIT_TYPE', 11); |
+ |
+ /** |
* Indicates that a class can validly be used as a mixin. |
*/ |
- static const Modifier MIXIN = const Modifier('MIXIN', 11); |
+ static const Modifier MIXIN = const Modifier('MIXIN', 12); |
/** |
* Indicates that a class is a mixin application. |
*/ |
static const Modifier MIXIN_APPLICATION = |
- const Modifier('MIXIN_APPLICATION', 12); |
+ const Modifier('MIXIN_APPLICATION', 13); |
/** |
* Indicates that the value of a parameter or local variable might be mutated |
* within the context. |
*/ |
static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = |
- const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 13); |
+ const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 14); |
/** |
* Indicates that the value of a parameter or local variable might be mutated |
* within the scope. |
*/ |
static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = |
- const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 14); |
+ const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 15); |
/** |
* Indicates that a class contains an explicit reference to 'super'. |
*/ |
static const Modifier REFERENCES_SUPER = |
- const Modifier('REFERENCES_SUPER', 15); |
+ const Modifier('REFERENCES_SUPER', 16); |
/** |
* Indicates that the pseudo-modifier 'set' was applied to the element. |
*/ |
- static const Modifier SETTER = const Modifier('SETTER', 16); |
+ static const Modifier SETTER = const Modifier('SETTER', 17); |
/** |
* Indicates that the modifier 'static' was applied to the element. |
*/ |
- static const Modifier STATIC = const Modifier('STATIC', 17); |
+ static const Modifier STATIC = const Modifier('STATIC', 18); |
/** |
* Indicates that the element does not appear in the source code but was |
@@ -8297,7 +8452,7 @@ class Modifier extends Enum<Modifier> { |
* constructors, an implicit zero-argument constructor will be created and it |
* will be marked as being synthetic. |
*/ |
- static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 18); |
+ static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 19); |
static const List<Modifier> values = const [ |
ABSTRACT, |
@@ -8311,6 +8466,7 @@ class Modifier extends Enum<Modifier> { |
GENERATOR, |
GETTER, |
HAS_EXT_URI, |
+ IMPLICIT_TYPE, |
MIXIN, |
MIXIN_APPLICATION, |
POTENTIALLY_MUTATED_IN_CONTEXT, |
@@ -8380,6 +8536,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement { |
String get displayName => _name; |
@override |
+ SourceRange get docRange => null; |
+ |
+ @override |
Element get enclosingElement => null; |
@override |
@@ -8419,6 +8578,9 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement { |
String get name => _name; |
@override |
+ int get nameLength => displayName != null ? displayName.length : 0; |
+ |
+ @override |
int get nameOffset => -1; |
@deprecated |
@@ -8651,6 +8813,12 @@ abstract class ParameterElement |
*/ |
List<TypeParameterElement> get typeParameters; |
+ /** |
+ * Append the type, name and possibly the default value of this parameter to |
+ * the given [buffer]. |
+ */ |
+ void appendToWithoutDelimiters(StringBuffer buffer); |
+ |
@override |
FormalParameter computeNode(); |
} |
@@ -8659,7 +8827,8 @@ abstract class ParameterElement |
* A concrete implementation of a [ParameterElement]. |
*/ |
class ParameterElementImpl extends VariableElementImpl |
- with PotentiallyConstVariableElement implements ParameterElement { |
+ with ParameterElementMixin, PotentiallyConstVariableElement |
+ implements ParameterElement { |
/** |
* An empty list of parameter elements. |
*/ |
@@ -8794,24 +8963,6 @@ class ParameterElementImpl extends VariableElementImpl |
buffer.write(right); |
} |
- /** |
- * Append the type and name of this parameter to the given [buffer]. |
- */ |
- void appendToWithoutDelimiters(StringBuffer buffer) { |
- buffer.write(type); |
- buffer.write(" "); |
- buffer.write(displayName); |
- if (_defaultValueCode != null) { |
- if (parameterKind == ParameterKind.NAMED) { |
- buffer.write(": "); |
- } |
- if (parameterKind == ParameterKind.POSITIONAL) { |
- buffer.write(" = "); |
- } |
- buffer.write(_defaultValueCode); |
- } |
- } |
- |
@override |
FormalParameter computeNode() => |
getNodeMatching((node) => node is FormalParameter); |
@@ -8857,6 +9008,28 @@ class ParameterElementImpl extends VariableElementImpl |
} |
/** |
+ * A mixin that provides a common implementation for methods defined in |
+ * [ParameterElement]. |
+ */ |
+abstract class ParameterElementMixin implements ParameterElement { |
+ @override |
+ void appendToWithoutDelimiters(StringBuffer buffer) { |
+ buffer.write(type); |
+ buffer.write(" "); |
+ buffer.write(displayName); |
+ if (defaultValueCode != null) { |
+ if (parameterKind == ParameterKind.NAMED) { |
+ buffer.write(": "); |
+ } |
+ if (parameterKind == ParameterKind.POSITIONAL) { |
+ buffer.write(" = "); |
+ } |
+ buffer.write(defaultValueCode); |
+ } |
+ } |
+} |
+ |
+/** |
* A type with type parameters, such as a class or function type alias. |
*/ |
abstract class ParameterizedType implements DartType { |
@@ -8880,7 +9053,9 @@ abstract class ParameterizedType implements DartType { |
* A parameter element defined in a parameterized type where the values of the |
* type parameters are known. |
*/ |
-class ParameterMember extends VariableMember implements ParameterElement { |
+class ParameterMember extends VariableMember |
+ with ParameterElementMixin |
+ implements ParameterElement { |
/** |
* Initialize a newly created element to represent a constructor, based on the |
* [baseElement], defined by the [definingType]. |
@@ -9479,13 +9654,6 @@ abstract class PropertyInducingElement implements VariableElement { |
PropertyAccessorElement get getter; |
/** |
- * Return `true` if this element is a static element. A static element is an |
- * element that is not associated with a particular instance, but rather with |
- * an entire library or class. |
- */ |
- bool get isStatic; |
- |
- /** |
* Return the propagated type of this variable, or `null` if type propagation |
* has not been performed, for example because the variable is not final. |
*/ |
@@ -9848,7 +10016,8 @@ abstract class TopLevelVariableElement implements PropertyInducingElement { |
* A concrete implementation of a [TopLevelVariableElement]. |
*/ |
class TopLevelVariableElementImpl extends PropertyInducingElementImpl |
- with PotentiallyConstVariableElement implements TopLevelVariableElement { |
+ with PotentiallyConstVariableElement |
+ implements TopLevelVariableElement { |
/** |
* An empty list of top-level variable elements. |
*/ |
@@ -10091,8 +10260,8 @@ abstract class TypeImpl implements DartType { |
} |
List<DartType> newTypes = new List<DartType>(length); |
for (int i = 0; i < length; i++) { |
- newTypes[i] = (types[i] as TypeImpl).substitute2( |
- argumentTypes, parameterTypes, prune); |
+ newTypes[i] = (types[i] as TypeImpl) |
+ .substitute2(argumentTypes, parameterTypes, prune); |
} |
return newTypes; |
} |
@@ -10101,7 +10270,7 @@ abstract class TypeImpl implements DartType { |
/** |
* A type parameter. |
*/ |
-abstract class TypeParameterElement implements Element { |
+abstract class TypeParameterElement implements TypeDefiningElement { |
/** |
* An empty list of type parameter elements. |
*/ |
@@ -10441,6 +10610,12 @@ abstract class VariableElement implements Element, ConstantEvaluationTarget { |
static const List<VariableElement> EMPTY_LIST = const <VariableElement>[]; |
/** |
+ * Return `true` if this variable element did not have an explicit type |
+ * specified for it. |
+ */ |
+ bool get hasImplicitType; |
+ |
+ /** |
* Return a synthetic function representing this variable's initializer, or |
* `null` if this variable does not have an initializer. The function will |
* have no parameters. The return type of the function will be the |
@@ -10477,6 +10652,19 @@ abstract class VariableElement implements Element, ConstantEvaluationTarget { |
bool get isPotentiallyMutatedInScope; |
/** |
+ * Return `true` if this element is a static variable, as per section 8 of the |
+ * Dart Language Specification: |
+ * |
+ * > A static variable is a variable that is not associated with a particular |
+ * > instance, but rather with an entire library or class. Static variables |
+ * > include library variables and class variables. Class variables are |
+ * > variables whose declaration is immediately nested inside a class |
+ * > declaration and includes the modifier static. A library variable is |
+ * > implicitly static. |
+ */ |
+ bool get isStatic; |
+ |
+ /** |
* Return the declared type of this variable, or `null` if the variable did |
* not have a declared type (such as if it was declared using the keyword |
* 'var'). |
@@ -10549,6 +10737,16 @@ abstract class VariableElementImpl extends ElementImpl |
} |
@override |
+ bool get hasImplicitType => hasModifier(Modifier.IMPLICIT_TYPE); |
+ |
+ /** |
+ * Set whether this variable element has an implicit type. |
+ */ |
+ void set hasImplicitType(bool hasImplicitType) { |
+ setModifier(Modifier.IMPLICIT_TYPE, hasImplicitType); |
+ } |
+ |
+ @override |
FunctionElement get initializer => _initializer; |
/** |
@@ -10575,6 +10773,9 @@ abstract class VariableElementImpl extends ElementImpl |
bool get isPotentiallyMutatedInScope => false; |
@override |
+ bool get isStatic => hasModifier(Modifier.STATIC); |
+ |
+ @override |
void appendTo(StringBuffer buffer) { |
buffer.write(type); |
buffer.write(" "); |
@@ -10604,6 +10805,9 @@ abstract class VariableMember extends Member implements VariableElement { |
VariableElement get baseElement => super.baseElement as VariableElement; |
@override |
+ bool get hasImplicitType => baseElement.hasImplicitType; |
+ |
+ @override |
FunctionElement get initializer { |
// |
// Elements within this element should have type parameters substituted, |
@@ -10628,6 +10832,9 @@ abstract class VariableMember extends Member implements VariableElement { |
baseElement.isPotentiallyMutatedInScope; |
@override |
+ bool get isStatic => baseElement.isStatic; |
+ |
+ @override |
DartType get type => substituteFor(baseElement.type); |
@override |
@@ -10695,8 +10902,9 @@ class VoidTypeImpl extends TypeImpl implements VoidType { |
@override |
VoidTypeImpl substitute2( |
- List<DartType> argumentTypes, List<DartType> parameterTypes, |
- [List<FunctionTypeAliasElement> prune]) => this; |
+ List<DartType> argumentTypes, List<DartType> parameterTypes, |
+ [List<FunctionTypeAliasElement> prune]) => |
+ this; |
} |
/** |