| Index: pkg/analyzer/lib/src/generated/error_verifier.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| index 9bc9e3759618232ffc7b9e875a7b329eb8e72eef..74c14ae16f7d162f929310024d6dda3b146d98a0 100644
|
| --- a/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
|
| @@ -1124,10 +1124,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR], and
|
| * [CompileTimeErrorCode.FINAL_INITIALIZED_MULTIPLE_TIMES].
|
| */
|
| - bool _checkForAllFinalInitializedErrorCodes(ConstructorDeclaration node) {
|
| - if (node.factoryKeyword != null ||
|
| - node.redirectedConstructor != null ||
|
| - node.externalKeyword != null) {
|
| + bool _checkForAllFinalInitializedErrorCodes(
|
| + ConstructorDeclaration constructor) {
|
| + if (constructor.factoryKeyword != null ||
|
| + constructor.redirectedConstructor != null ||
|
| + constructor.externalKeyword != null) {
|
| return false;
|
| }
|
| // Ignore if native class.
|
| @@ -1138,7 +1139,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| HashMap<FieldElement, INIT_STATE> fieldElementsMap =
|
| new HashMap<FieldElement, INIT_STATE>.from(_initialFieldElementsMap);
|
| // Visit all of the field formal parameters
|
| - NodeList<FormalParameter> formalParameters = node.parameters.parameters;
|
| + NodeList<FormalParameter> formalParameters =
|
| + constructor.parameters.parameters;
|
| for (FormalParameter formalParameter in formalParameters) {
|
| FormalParameter parameter = formalParameter;
|
| if (parameter is DefaultFormalParameter) {
|
| @@ -1168,7 +1170,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| }
|
| // Visit all of the initializers
|
| - NodeList<ConstructorInitializer> initializers = node.initializers;
|
| + NodeList<ConstructorInitializer> initializers = constructor.initializers;
|
| for (ConstructorInitializer constructorInitializer in initializers) {
|
| if (constructorInitializer is RedirectingConstructorInvocation) {
|
| return false;
|
| @@ -1219,8 +1221,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (state == INIT_STATE.NOT_INIT) {
|
| if (fieldElement.isConst) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_NOT_INITIALIZED, node.returnType,
|
| - [fieldElement.name]);
|
| + CompileTimeErrorCode.CONST_NOT_INITIALIZED,
|
| + constructor.returnType, [fieldElement.name]);
|
| foundError = true;
|
| }
|
| }
|
| @@ -1231,18 +1233,18 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (notInitFinalFields.length == 1) {
|
| analysisError = _errorReporter.newErrorWithProperties(
|
| StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_1,
|
| - node.returnType, [notInitFinalFields[0].name]);
|
| + constructor.returnType, [notInitFinalFields[0].name]);
|
| } else if (notInitFinalFields.length == 2) {
|
| analysisError = _errorReporter.newErrorWithProperties(
|
| StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_2,
|
| - node.returnType, [
|
| + constructor.returnType, [
|
| notInitFinalFields[0].name,
|
| notInitFinalFields[1].name
|
| ]);
|
| } else {
|
| analysisError = _errorReporter.newErrorWithProperties(
|
| StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS,
|
| - node.returnType, [
|
| + constructor.returnType, [
|
| notInitFinalFields[0].name,
|
| notInitFinalFields[1].name,
|
| notInitFinalFields.length - 2
|
| @@ -1559,16 +1561,17 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Check the given [field] declaration against override-error codes.
|
| + * Check the given field [declaration] against override-error codes.
|
| *
|
| * See [_checkForAllInvalidOverrideErrorCodes].
|
| */
|
| - bool _checkForAllInvalidOverrideErrorCodesForField(FieldDeclaration node) {
|
| - if (_enclosingClass == null || node.isStatic) {
|
| + bool _checkForAllInvalidOverrideErrorCodesForField(
|
| + FieldDeclaration declaration) {
|
| + if (_enclosingClass == null || declaration.isStatic) {
|
| return false;
|
| }
|
| bool hasProblems = false;
|
| - VariableDeclarationList fields = node.fields;
|
| + VariableDeclarationList fields = declaration.fields;
|
| for (VariableDeclaration field in fields.variables) {
|
| FieldElement element = field.element as FieldElement;
|
| if (element == null) {
|
| @@ -1598,21 +1601,22 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [_checkForAllInvalidOverrideErrorCodes].
|
| */
|
| - bool _checkForAllInvalidOverrideErrorCodesForMethod(MethodDeclaration node) {
|
| + bool _checkForAllInvalidOverrideErrorCodesForMethod(
|
| + MethodDeclaration method) {
|
| if (_enclosingClass == null ||
|
| - node.isStatic ||
|
| - node.body is NativeFunctionBody) {
|
| + method.isStatic ||
|
| + method.body is NativeFunctionBody) {
|
| return false;
|
| }
|
| - ExecutableElement executableElement = node.element;
|
| + ExecutableElement executableElement = method.element;
|
| if (executableElement == null) {
|
| return false;
|
| }
|
| - SimpleIdentifier methodName = node.name;
|
| + SimpleIdentifier methodName = method.name;
|
| if (methodName.isSynthetic) {
|
| return false;
|
| }
|
| - FormalParameterList formalParameterList = node.parameters;
|
| + FormalParameterList formalParameterList = method.parameters;
|
| NodeList<FormalParameter> parameterList =
|
| formalParameterList != null ? formalParameterList.parameters : null;
|
| List<AstNode> parameters =
|
| @@ -1668,11 +1672,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [StaticWarningCode.REDIRECT_TO_INVALID_FUNCTION_TYPE], and
|
| * [StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR].
|
| */
|
| - bool _checkForAllRedirectConstructorErrorCodes(ConstructorDeclaration node) {
|
| + bool _checkForAllRedirectConstructorErrorCodes(
|
| + ConstructorDeclaration declaration) {
|
| //
|
| // Prepare redirected constructor node
|
| //
|
| - ConstructorName redirectedConstructor = node.redirectedConstructor;
|
| + ConstructorName redirectedConstructor = declaration.redirectedConstructor;
|
| if (redirectedConstructor == null) {
|
| return false;
|
| }
|
| @@ -1697,7 +1702,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (redirectedConstructor.name != null) {
|
| constructorStrName += ".${redirectedConstructor.name.name}";
|
| }
|
| - ErrorCode errorCode = (node.constKeyword != null
|
| + ErrorCode errorCode = (declaration.constKeyword != null
|
| ? CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR
|
| : StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR);
|
| _errorReporter.reportErrorForNode(errorCode, redirectedConstructor, [
|
| @@ -1713,7 +1718,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| //
|
| // Report specific problem when return type is incompatible
|
| //
|
| - FunctionType constructorType = node.element.type;
|
| + FunctionType constructorType = declaration.element.type;
|
| DartType constructorReturnType = constructorType.returnType;
|
| if (!redirectedReturnType.isAssignableTo(constructorReturnType)) {
|
| _errorReporter.reportErrorForNode(
|
| @@ -1748,13 +1753,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [StaticWarningCode.RETURN_WITHOUT_VALUE], and
|
| * [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE].
|
| */
|
| - bool _checkForAllReturnStatementErrorCodes(ReturnStatement node) {
|
| + bool _checkForAllReturnStatementErrorCodes(ReturnStatement statement) {
|
| FunctionType functionType =
|
| _enclosingFunction == null ? null : _enclosingFunction.type;
|
| DartType expectedReturnType = functionType == null
|
| ? DynamicTypeImpl.instance
|
| : functionType.returnType;
|
| - Expression returnExpression = node.expression;
|
| + Expression returnExpression = statement.expression;
|
| // RETURN_IN_GENERATIVE_CONSTRUCTOR
|
| bool isGenerativeConstructor = _enclosingFunction is ConstructorElement &&
|
| !(_enclosingFunction as ConstructorElement).isFactory;
|
| @@ -1776,12 +1781,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| _hasReturnWithoutValue = true;
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.RETURN_WITHOUT_VALUE, node);
|
| + StaticWarningCode.RETURN_WITHOUT_VALUE, statement);
|
| return true;
|
| } else if (_inGenerator) {
|
| // RETURN_IN_GENERATOR
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.RETURN_IN_GENERATOR, node);
|
| + CompileTimeErrorCode.RETURN_IN_GENERATOR, statement);
|
| }
|
| // RETURN_OF_INVALID_TYPE
|
| return _checkForReturnOfInvalidType(returnExpression, expectedReturnType);
|
| @@ -1796,7 +1801,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.AMBIGUOUS_EXPORT].
|
| */
|
| - bool _checkForAmbiguousExport(ExportDirective node,
|
| + bool _checkForAmbiguousExport(ExportDirective directive,
|
| ExportElement exportElement, LibraryElement exportedLibrary) {
|
| if (exportedLibrary == null) {
|
| return false;
|
| @@ -1810,7 +1815,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| Element prevElement = _exportedElements[name];
|
| if (element != null && prevElement != null && prevElement != element) {
|
| _errorReporter.reportErrorForNode(CompileTimeErrorCode.AMBIGUOUS_EXPORT,
|
| - node, [
|
| + directive, [
|
| name,
|
| prevElement.library.definingCompilationUnit.displayName,
|
| element.library.definingCompilationUnit.displayName
|
| @@ -1827,9 +1832,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * Verify that the given [expression] can be assigned to its corresponding
|
| * parameters. The [expectedStaticType] is the expected static type of the
|
| * parameter. The [actualStaticType] is the actual static type of the
|
| - * argument. The [expectedPropagatedType] is the expected propagated type of
|
| - * the parameter, may be `null`. The [actualPropagatedType] is the expected
|
| - * propagated type of the parameter, may be `null`.
|
| + * argument.
|
| *
|
| * This method corresponds to
|
| * [BestPracticesVerifier.checkForArgumentTypeNotAssignable].
|
| @@ -1880,8 +1883,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
|
|
| /**
|
| * Verify that the given [expression] can be assigned to its corresponding
|
| - * parameters. The [expectedStaticType] is the expected static type. The
|
| - * [expectedPropagatedType] is the expected propagated type, may be `null`.
|
| + * parameters. The [expectedStaticType] is the expected static type.
|
| *
|
| * This method corresponds to
|
| * [BestPracticesVerifier.checkForArgumentTypeNotAssignableWithExpectedTypes].
|
| @@ -2029,15 +2031,15 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * see [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED].
|
| */
|
| - bool _checkForCaseBlockNotTerminated(SwitchCase node) {
|
| - NodeList<Statement> statements = node.statements;
|
| + bool _checkForCaseBlockNotTerminated(SwitchCase switchCase) {
|
| + NodeList<Statement> statements = switchCase.statements;
|
| if (statements.isEmpty) {
|
| // fall-through without statements at all
|
| - AstNode parent = node.parent;
|
| + AstNode parent = switchCase.parent;
|
| if (parent is SwitchStatement) {
|
| SwitchStatement switchStatement = parent;
|
| NodeList<SwitchMember> members = switchStatement.members;
|
| - int index = members.indexOf(node);
|
| + int index = members.indexOf(switchCase);
|
| if (index != -1 && index < members.length - 1) {
|
| return false;
|
| }
|
| @@ -2061,7 +2063,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // report error
|
| _errorReporter.reportErrorForToken(
|
| - StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, node.keyword);
|
| + StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, switchCase.keyword);
|
| return true;
|
| }
|
|
|
| @@ -2071,9 +2073,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.CASE_BLOCK_NOT_TERMINATED].
|
| */
|
| - bool _checkForCaseBlocksNotTerminated(SwitchStatement node) {
|
| + bool _checkForCaseBlocksNotTerminated(SwitchStatement statement) {
|
| bool foundError = false;
|
| - NodeList<SwitchMember> members = node.members;
|
| + NodeList<SwitchMember> members = statement.members;
|
| int lastMember = members.length - 1;
|
| for (int i = 0; i < lastMember; i++) {
|
| SwitchMember member = members[i];
|
| @@ -2090,17 +2092,17 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT_MEMBER].
|
| */
|
| - bool _checkForConcreteClassWithAbstractMember(MethodDeclaration node) {
|
| - if (node.isAbstract &&
|
| + bool _checkForConcreteClassWithAbstractMember(MethodDeclaration method) {
|
| + if (method.isAbstract &&
|
| _enclosingClass != null &&
|
| !_enclosingClass.isAbstract) {
|
| - SimpleIdentifier nameNode = node.name;
|
| + SimpleIdentifier nameNode = method.name;
|
| String memberName = nameNode.name;
|
| ExecutableElement overriddenMember;
|
| - if (node.isGetter) {
|
| + if (method.isGetter) {
|
| overriddenMember = _enclosingClass.lookUpInheritedConcreteGetter(
|
| memberName, _currentLibrary);
|
| - } else if (node.isSetter) {
|
| + } else if (method.isSetter) {
|
| overriddenMember = _enclosingClass.lookUpInheritedConcreteSetter(
|
| memberName, _currentLibrary);
|
| } else {
|
| @@ -2130,8 +2132,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD].
|
| */
|
| bool _checkForConflictingConstructorNameAndMember(
|
| - ConstructorDeclaration node, ConstructorElement constructorElement) {
|
| - SimpleIdentifier constructorName = node.name;
|
| + ConstructorDeclaration constructor,
|
| + ConstructorElement constructorElement) {
|
| + SimpleIdentifier constructorName = constructor.name;
|
| String name = constructorElement.name;
|
| ClassElement classElement = constructorElement.enclosingElement;
|
| // constructors
|
| @@ -2143,10 +2146,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (name == otherConstructor.name) {
|
| if (name == null || name.length == 0) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, node);
|
| + CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_DEFAULT, constructor);
|
| } else {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, node, [name]);
|
| + CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, constructor,
|
| + [name]);
|
| }
|
| return true;
|
| }
|
| @@ -2159,16 +2163,16 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| FieldElement field = classElement.getField(name);
|
| if (field != null) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD, node,
|
| - [name]);
|
| + CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_FIELD,
|
| + constructor, [name]);
|
| return true;
|
| }
|
| // methods
|
| MethodElement method = classElement.getMethod(name);
|
| if (method != null) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD, node,
|
| - [name]);
|
| + CompileTimeErrorCode.CONFLICTING_CONSTRUCTOR_NAME_AND_METHOD,
|
| + constructor, [name]);
|
| return true;
|
| }
|
| }
|
| @@ -2176,7 +2180,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Verify that the [enclosingClass] does not have a method and getter pair
|
| + * Verify that the [_enclosingClass] does not have a method and getter pair
|
| * with the same name on, via inheritance.
|
| *
|
| * See [CompileTimeErrorCode.CONFLICTING_GETTER_AND_METHOD], and
|
| @@ -2233,9 +2237,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Verify that the superclass of the [enclosingClass] does not declare
|
| + * Verify that the superclass of the [_enclosingClass] does not declare
|
| * accessible static members with the same name as the instance
|
| - * getters/setters declared in [enclosingClass].
|
| + * getters/setters declared in [_enclosingClass].
|
| *
|
| * See [StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER], and
|
| * [StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER].
|
| @@ -2308,9 +2312,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.CONFLICTING_INSTANCE_METHOD_SETTER].
|
| */
|
| - bool _checkForConflictingInstanceMethodSetter(ClassDeclaration node) {
|
| + bool _checkForConflictingInstanceMethodSetter(ClassDeclaration declaration) {
|
| // Reference all of the class members in this class.
|
| - NodeList<ClassMember> classMembers = node.members;
|
| + NodeList<ClassMember> classMembers = declaration.members;
|
| if (classMembers.isEmpty) {
|
| return false;
|
| }
|
| @@ -2402,12 +2406,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER].
|
| */
|
| bool _checkForConflictingStaticGetterAndInstanceSetter(
|
| - MethodDeclaration node) {
|
| - if (!node.isStatic) {
|
| + MethodDeclaration method) {
|
| + if (!method.isStatic) {
|
| return false;
|
| }
|
| // prepare name
|
| - SimpleIdentifier nameNode = node.name;
|
| + SimpleIdentifier nameNode = method.name;
|
| if (nameNode == null) {
|
| return false;
|
| }
|
| @@ -2444,12 +2448,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER].
|
| */
|
| bool _checkForConflictingStaticSetterAndInstanceMember(
|
| - MethodDeclaration node) {
|
| - if (!node.isStatic) {
|
| + MethodDeclaration method) {
|
| + if (!method.isStatic) {
|
| return false;
|
| }
|
| // prepare name
|
| - SimpleIdentifier nameNode = node.name;
|
| + SimpleIdentifier nameNode = method.name;
|
| if (nameNode == null) {
|
| return false;
|
| }
|
| @@ -2492,7 +2496,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_CLASS], and
|
| * [CompileTimeErrorCode.CONFLICTING_TYPE_VARIABLE_AND_MEMBER].
|
| */
|
| - bool _checkForConflictingTypeVariableErrorCodes(ClassDeclaration node) {
|
| + bool _checkForConflictingTypeVariableErrorCodes(
|
| + ClassDeclaration declaration) {
|
| bool problemReported = false;
|
| for (TypeParameterElement typeParameter in _enclosingClass.typeParameters) {
|
| String name = typeParameter.name;
|
| @@ -2522,22 +2527,24 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER].
|
| */
|
| - bool _checkForConstConstructorWithNonConstSuper(ConstructorDeclaration node) {
|
| + bool _checkForConstConstructorWithNonConstSuper(
|
| + ConstructorDeclaration constructor) {
|
| if (!_isEnclosingConstructorConst) {
|
| return false;
|
| }
|
| // OK, const factory, checked elsewhere
|
| - if (node.factoryKeyword != null) {
|
| + if (constructor.factoryKeyword != null) {
|
| return false;
|
| }
|
| // check for mixins
|
| if (_enclosingClass.mixins.length != 0) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN, node.returnType);
|
| + CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_MIXIN,
|
| + constructor.returnType);
|
| return true;
|
| }
|
| // try to find and check super constructor invocation
|
| - for (ConstructorInitializer initializer in node.initializers) {
|
| + for (ConstructorInitializer initializer in constructor.initializers) {
|
| if (initializer is SuperConstructorInvocation) {
|
| SuperConstructorInvocation superInvocation = initializer;
|
| ConstructorElement element = superInvocation.staticElement;
|
| @@ -2569,19 +2576,20 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| // default constructor is not 'const', report problem
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_CONST_SUPER,
|
| - node.returnType, [supertype.displayName]);
|
| + constructor.returnType, [supertype.displayName]);
|
| return true;
|
| }
|
|
|
| /**
|
| - * Verify that if the given constructor [declaration] is 'const' then there
|
| + * Verify that if the given [constructor] declaration is 'const' then there
|
| * are no non-final instance variable. The [constructorElement] is the
|
| * constructor element.
|
| *
|
| * See [CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD].
|
| */
|
| bool _checkForConstConstructorWithNonFinalField(
|
| - ConstructorDeclaration node, ConstructorElement constructorElement) {
|
| + ConstructorDeclaration constructor,
|
| + ConstructorElement constructorElement) {
|
| if (!_isEnclosingConstructorConst) {
|
| return false;
|
| }
|
| @@ -2592,7 +2600,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // report problem
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, node);
|
| + CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD,
|
| + constructor);
|
| return true;
|
| }
|
|
|
| @@ -2604,7 +2613,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.CONST_DEFERRED_CLASS].
|
| */
|
| - bool _checkForConstDeferredClass(InstanceCreationExpression node,
|
| + bool _checkForConstDeferredClass(InstanceCreationExpression expression,
|
| ConstructorName constructorName, TypeName typeName) {
|
| if (typeName.isDeferred) {
|
| _errorReporter.reportErrorForNode(
|
| @@ -2621,10 +2630,10 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION].
|
| */
|
| - bool _checkForConstEvalThrowsException(ThrowExpression node) {
|
| + bool _checkForConstEvalThrowsException(ThrowExpression expression) {
|
| if (_isEnclosingConstructorConst) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION, node);
|
| + CompileTimeErrorCode.CONST_CONSTRUCTOR_THROWS_EXCEPTION, expression);
|
| return true;
|
| }
|
| return false;
|
| @@ -2635,10 +2644,10 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.CONST_FORMAL_PARAMETER].
|
| */
|
| - bool _checkForConstFormalParameter(NormalFormalParameter node) {
|
| - if (node.isConst) {
|
| + bool _checkForConstFormalParameter(NormalFormalParameter parameter) {
|
| + if (parameter.isConst) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_FORMAL_PARAMETER, node);
|
| + CompileTimeErrorCode.CONST_FORMAL_PARAMETER, parameter);
|
| return true;
|
| }
|
| return false;
|
| @@ -2655,11 +2664,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [StaticWarningCode.NEW_WITH_ABSTRACT_CLASS].
|
| */
|
| bool _checkForConstOrNewWithAbstractClass(
|
| - InstanceCreationExpression node, TypeName typeName, InterfaceType type) {
|
| + InstanceCreationExpression expression, TypeName typeName,
|
| + InterfaceType type) {
|
| if (type.element.isAbstract) {
|
| - ConstructorElement element = node.staticElement;
|
| + ConstructorElement element = expression.staticElement;
|
| if (element != null && !element.isFactory) {
|
| - if ((node.keyword as sc.KeywordToken).keyword == sc.Keyword.CONST) {
|
| + if ((expression.keyword as sc.KeywordToken).keyword ==
|
| + sc.Keyword.CONST) {
|
| _errorReporter.reportErrorForNode(
|
| StaticWarningCode.CONST_WITH_ABSTRACT_CLASS, typeName);
|
| } else {
|
| @@ -2681,8 +2692,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.INSTANTIATE_ENUM].
|
| */
|
| - bool _checkForConstOrNewWithEnum(
|
| - InstanceCreationExpression node, TypeName typeName, InterfaceType type) {
|
| + bool _checkForConstOrNewWithEnum(InstanceCreationExpression expression,
|
| + TypeName typeName, InterfaceType type) {
|
| if (type.element.isEnum) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.INSTANTIATE_ENUM, typeName);
|
| @@ -2700,11 +2711,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.CONST_WITH_NON_CONST].
|
| */
|
| - bool _checkForConstWithNonConst(InstanceCreationExpression node) {
|
| - ConstructorElement constructorElement = node.staticElement;
|
| + bool _checkForConstWithNonConst(InstanceCreationExpression expression) {
|
| + ConstructorElement constructorElement = expression.staticElement;
|
| if (constructorElement != null && !constructorElement.isConst) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_WITH_NON_CONST, node);
|
| + CompileTimeErrorCode.CONST_WITH_NON_CONST, expression);
|
| return true;
|
| }
|
| return false;
|
| @@ -2756,10 +2767,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR], and
|
| * [CompileTimeErrorCode.CONST_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT].
|
| */
|
| - bool _checkForConstWithUndefinedConstructor(InstanceCreationExpression node,
|
| - ConstructorName constructorName, TypeName typeName) {
|
| + bool _checkForConstWithUndefinedConstructor(
|
| + InstanceCreationExpression expression, ConstructorName constructorName,
|
| + TypeName typeName) {
|
| // OK if resolved
|
| - if (node.staticElement != null) {
|
| + if (expression.staticElement != null) {
|
| return false;
|
| }
|
| DartType type = typeName.type;
|
| @@ -2793,16 +2805,16 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS].
|
| */
|
| - bool _checkForDefaultValueInFunctionTypeAlias(FunctionTypeAlias node) {
|
| + bool _checkForDefaultValueInFunctionTypeAlias(FunctionTypeAlias alias) {
|
| bool result = false;
|
| - FormalParameterList formalParameterList = node.parameters;
|
| + FormalParameterList formalParameterList = alias.parameters;
|
| NodeList<FormalParameter> parameters = formalParameterList.parameters;
|
| for (FormalParameter formalParameter in parameters) {
|
| if (formalParameter is DefaultFormalParameter) {
|
| DefaultFormalParameter defaultFormalParameter = formalParameter;
|
| if (defaultFormalParameter.defaultValue != null) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS, node);
|
| + CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPE_ALIAS, alias);
|
| result = true;
|
| }
|
| }
|
| @@ -2817,18 +2829,19 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER].
|
| */
|
| bool _checkForDefaultValueInFunctionTypedParameter(
|
| - DefaultFormalParameter node) {
|
| + DefaultFormalParameter parameter) {
|
| // OK, not in a function typed parameter.
|
| if (!_isInFunctionTypedFormalParameter) {
|
| return false;
|
| }
|
| // OK, no default value.
|
| - if (node.defaultValue == null) {
|
| + if (parameter.defaultValue == null) {
|
| return false;
|
| }
|
| // Report problem.
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER, node);
|
| + CompileTimeErrorCode.DEFAULT_VALUE_IN_FUNCTION_TYPED_PARAMETER,
|
| + parameter);
|
| return true;
|
| }
|
|
|
| @@ -2838,9 +2851,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.SHARED_DEFERRED_PREFIX].
|
| */
|
| - bool _checkForDeferredPrefixCollisions(CompilationUnit node) {
|
| + bool _checkForDeferredPrefixCollisions(CompilationUnit unit) {
|
| bool foundError = false;
|
| - NodeList<Directive> directives = node.directives;
|
| + NodeList<Directive> directives = unit.directives;
|
| int count = directives.length;
|
| if (count > 0) {
|
| HashMap<PrefixElement, List<ImportDirective>> prefixToDirectivesMap =
|
| @@ -2943,7 +2956,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [StaticTypeWarningCode.EXPECTED_ONE_LIST_TYPE_ARGUMENTS].
|
| */
|
| bool _checkForExpectedOneListTypeArgument(
|
| - ListLiteral node, TypeArgumentList typeArguments) {
|
| + ListLiteral literal, TypeArgumentList typeArguments) {
|
| // check number of type arguments
|
| int num = typeArguments.arguments.length;
|
| if (num == 1) {
|
| @@ -2957,7 +2970,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Verify that the given export ([node]) has a unique name among other
|
| + * Verify that the given export [directive] has a unique name among other
|
| * exported libraries. The [exportElement] is the [ExportElement] retrieved
|
| * from the node, if the element in the node was `null`, then this method is
|
| * not called. The [exportedLibrary] is the library element containing the
|
| @@ -2965,7 +2978,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.EXPORT_DUPLICATED_LIBRARY_NAME].
|
| */
|
| - bool _checkForExportDuplicateLibraryName(ExportDirective node,
|
| + bool _checkForExportDuplicateLibraryName(ExportDirective directive,
|
| ExportElement exportElement, LibraryElement exportedLibrary) {
|
| if (exportedLibrary == null) {
|
| return false;
|
| @@ -2977,13 +2990,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (prevLibrary != exportedLibrary) {
|
| if (name.isEmpty) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_UNNAMED, node, [
|
| + StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_UNNAMED, directive, [
|
| prevLibrary.definingCompilationUnit.displayName,
|
| exportedLibrary.definingCompilationUnit.displayName
|
| ]);
|
| } else {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED, node, [
|
| + StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED, directive, [
|
| prevLibrary.definingCompilationUnit.displayName,
|
| exportedLibrary.definingCompilationUnit.displayName,
|
| name
|
| @@ -3007,7 +3020,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY].
|
| */
|
| bool _checkForExportInternalLibrary(
|
| - ExportDirective node, ExportElement exportElement) {
|
| + ExportDirective directive, ExportElement exportElement) {
|
| if (_isInSystemLibrary) {
|
| return false;
|
| }
|
| @@ -3023,7 +3036,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // report problem
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, node, [node.uri]);
|
| + CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, directive,
|
| + [directive.uri]);
|
| return true;
|
| }
|
|
|
| @@ -3032,12 +3046,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS].
|
| */
|
| - bool _checkForExtendsDeferredClass(ExtendsClause node) {
|
| - if (node == null) {
|
| + bool _checkForExtendsDeferredClass(ExtendsClause clause) {
|
| + if (clause == null) {
|
| return false;
|
| }
|
| return _checkForExtendsOrImplementsDeferredClass(
|
| - node.superclass, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| + clause.superclass, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| }
|
|
|
| /**
|
| @@ -3045,12 +3059,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS].
|
| */
|
| - bool _checkForExtendsDeferredClassInTypeAlias(ClassTypeAlias node) {
|
| - if (node == null) {
|
| + bool _checkForExtendsDeferredClassInTypeAlias(ClassTypeAlias alias) {
|
| + if (alias == null) {
|
| return false;
|
| }
|
| return _checkForExtendsOrImplementsDeferredClass(
|
| - node.superclass, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| + alias.superclass, CompileTimeErrorCode.EXTENDS_DEFERRED_CLASS);
|
| }
|
|
|
| /**
|
| @@ -3059,12 +3073,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS].
|
| */
|
| - bool _checkForExtendsDisallowedClass(ExtendsClause node) {
|
| - if (node == null) {
|
| + bool _checkForExtendsDisallowedClass(ExtendsClause clause) {
|
| + if (clause == null) {
|
| return false;
|
| }
|
| return _checkForExtendsOrImplementsDisallowedClass(
|
| - node.superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS);
|
| + clause.superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS);
|
| }
|
|
|
| /**
|
| @@ -3073,12 +3087,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS].
|
| */
|
| - bool _checkForExtendsDisallowedClassInTypeAlias(ClassTypeAlias node) {
|
| - if (node == null) {
|
| + bool _checkForExtendsDisallowedClassInTypeAlias(ClassTypeAlias alias) {
|
| + if (alias == null) {
|
| return false;
|
| }
|
| return _checkForExtendsOrImplementsDisallowedClass(
|
| - node.superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS);
|
| + alias.superclass, CompileTimeErrorCode.EXTENDS_DISALLOWED_CLASS);
|
| }
|
|
|
| /**
|
| @@ -3164,7 +3178,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [StaticWarningCode.FIELD_INITIALIZER_NOT_ASSIGNABLE].
|
| */
|
| bool _checkForFieldInitializerNotAssignable(
|
| - ConstructorFieldInitializer node, Element staticElement) {
|
| + ConstructorFieldInitializer initializer, Element staticElement) {
|
| // prepare field element
|
| if (staticElement is! FieldElement) {
|
| return false;
|
| @@ -3173,7 +3187,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| // prepare field type
|
| DartType fieldType = fieldElement.type;
|
| // prepare expression type
|
| - Expression expression = node.expression;
|
| + Expression expression = initializer.expression;
|
| if (expression == null) {
|
| return false;
|
| }
|
| @@ -3230,18 +3244,20 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR].
|
| */
|
| bool _checkForFieldInitializingFormalRedirectingConstructor(
|
| - FieldFormalParameter node) {
|
| + FieldFormalParameter parameter) {
|
| ConstructorDeclaration constructor =
|
| - node.getAncestor((node) => node is ConstructorDeclaration);
|
| + parameter.getAncestor((node) => node is ConstructorDeclaration);
|
| if (constructor == null) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, node);
|
| + CompileTimeErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR,
|
| + parameter);
|
| return true;
|
| }
|
| // constructor cannot be a factory
|
| if (constructor.factoryKeyword != null) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR, node);
|
| + CompileTimeErrorCode.FIELD_INITIALIZER_FACTORY_CONSTRUCTOR,
|
| + parameter);
|
| return true;
|
| }
|
| // constructor cannot have a redirection
|
| @@ -3249,7 +3265,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (initializer is RedirectingConstructorInvocation) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR,
|
| - node);
|
| + parameter);
|
| return true;
|
| }
|
| }
|
| @@ -3264,20 +3280,20 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.CONST_NOT_INITIALIZED], and
|
| * [StaticWarningCode.FINAL_NOT_INITIALIZED].
|
| */
|
| - bool _checkForFinalNotInitialized(VariableDeclarationList node) {
|
| + bool _checkForFinalNotInitialized(VariableDeclarationList list) {
|
| if (_isInNativeClass) {
|
| return false;
|
| }
|
| bool foundError = false;
|
| - if (!node.isSynthetic) {
|
| - NodeList<VariableDeclaration> variables = node.variables;
|
| + if (!list.isSynthetic) {
|
| + NodeList<VariableDeclaration> variables = list.variables;
|
| for (VariableDeclaration variable in variables) {
|
| if (variable.initializer == null) {
|
| - if (node.isConst) {
|
| + if (list.isConst) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.CONST_NOT_INITIALIZED, variable.name,
|
| [variable.name.name]);
|
| - } else if (node.isFinal) {
|
| + } else if (list.isFinal) {
|
| _errorReporter.reportErrorForNode(
|
| StaticWarningCode.FINAL_NOT_INITIALIZED, variable.name,
|
| [variable.name.name]);
|
| @@ -3298,8 +3314,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.CONST_NOT_INITIALIZED], and
|
| * [StaticWarningCode.FINAL_NOT_INITIALIZED].
|
| */
|
| - bool _checkForFinalNotInitializedInClass(ClassDeclaration node) {
|
| - NodeList<ClassMember> classMembers = node.members;
|
| + bool _checkForFinalNotInitializedInClass(ClassDeclaration declaration) {
|
| + NodeList<ClassMember> classMembers = declaration.members;
|
| for (ClassMember classMember in classMembers) {
|
| if (classMember is ConstructorDeclaration) {
|
| return false;
|
| @@ -3318,10 +3334,10 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| /**
|
| * If the current function is async, async*, or sync*, verify that its
|
| * declared return type is assignable to Future, Stream, or Iterable,
|
| - * respectively. If not, report the error using [node].
|
| + * respectively. If not, report the error using [returnType].
|
| */
|
| - void _checkForIllegalReturnType(TypeName node) {
|
| - if (node == null) {
|
| + void _checkForIllegalReturnType(TypeName returnType) {
|
| + if (returnType == null) {
|
| // No declared return type, so the return type must be dynamic, which is
|
| // assignable to everything.
|
| return;
|
| @@ -3331,20 +3347,22 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (!_enclosingFunction.returnType
|
| .isAssignableTo(_typeProvider.streamDynamicType)) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE, node);
|
| + StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE,
|
| + returnType);
|
| }
|
| } else {
|
| if (!_enclosingFunction.returnType
|
| .isAssignableTo(_typeProvider.futureDynamicType)) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, node);
|
| + StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, returnType);
|
| }
|
| }
|
| } else if (_enclosingFunction.isGenerator) {
|
| if (!_enclosingFunction.returnType
|
| .isAssignableTo(_typeProvider.iterableDynamicType)) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE, node);
|
| + StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE,
|
| + returnType);
|
| }
|
| }
|
| }
|
| @@ -3355,12 +3373,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS].
|
| */
|
| - bool _checkForImplementsDeferredClass(ImplementsClause node) {
|
| - if (node == null) {
|
| + bool _checkForImplementsDeferredClass(ImplementsClause clause) {
|
| + if (clause == null) {
|
| return false;
|
| }
|
| bool foundError = false;
|
| - for (TypeName type in node.interfaces) {
|
| + for (TypeName type in clause.interfaces) {
|
| if (_checkForExtendsOrImplementsDeferredClass(
|
| type, CompileTimeErrorCode.IMPLEMENTS_DEFERRED_CLASS)) {
|
| foundError = true;
|
| @@ -3375,12 +3393,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS].
|
| */
|
| - bool _checkForImplementsDisallowedClass(ImplementsClause node) {
|
| - if (node == null) {
|
| + bool _checkForImplementsDisallowedClass(ImplementsClause clause) {
|
| + if (clause == null) {
|
| return false;
|
| }
|
| bool foundError = false;
|
| - for (TypeName type in node.interfaces) {
|
| + for (TypeName type in clause.interfaces) {
|
| if (_checkForExtendsOrImplementsDisallowedClass(
|
| type, CompileTimeErrorCode.IMPLEMENTS_DISALLOWED_CLASS)) {
|
| foundError = true;
|
| @@ -3397,7 +3415,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC].
|
| * TODO(scheglov) rename thid method
|
| */
|
| - bool _checkForImplicitThisReferenceInInitializer(SimpleIdentifier node) {
|
| + bool _checkForImplicitThisReferenceInInitializer(
|
| + SimpleIdentifier identifier) {
|
| if (!_isInConstructorInitializer &&
|
| !_isInStaticMethod &&
|
| !_isInFactory &&
|
| @@ -3406,7 +3425,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| return false;
|
| }
|
| // prepare element
|
| - Element element = node.staticElement;
|
| + Element element = identifier.staticElement;
|
| if (!(element is MethodElement || element is PropertyAccessorElement)) {
|
| return false;
|
| }
|
| @@ -3421,14 +3440,14 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| return false;
|
| }
|
| // comment
|
| - AstNode parent = node.parent;
|
| + AstNode parent = identifier.parent;
|
| if (parent is CommentReference) {
|
| return false;
|
| }
|
| // qualified method invocation
|
| if (parent is MethodInvocation) {
|
| MethodInvocation invocation = parent;
|
| - if (identical(invocation.methodName, node) &&
|
| + if (identical(invocation.methodName, identifier) &&
|
| invocation.realTarget != null) {
|
| return false;
|
| }
|
| @@ -3436,26 +3455,28 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| // qualified property access
|
| if (parent is PropertyAccess) {
|
| PropertyAccess access = parent;
|
| - if (identical(access.propertyName, node) && access.realTarget != null) {
|
| + if (identical(access.propertyName, identifier) &&
|
| + access.realTarget != null) {
|
| return false;
|
| }
|
| }
|
| if (parent is PrefixedIdentifier) {
|
| PrefixedIdentifier prefixed = parent;
|
| - if (identical(prefixed.identifier, node)) {
|
| + if (identical(prefixed.identifier, identifier)) {
|
| return false;
|
| }
|
| }
|
| // report problem
|
| if (_isInStaticMethod) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC, node);
|
| + CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_STATIC, identifier);
|
| } else if (_isInFactory) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY, node);
|
| + CompileTimeErrorCode.INSTANCE_MEMBER_ACCESS_FROM_FACTORY, identifier);
|
| } else {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER, node);
|
| + CompileTimeErrorCode.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER,
|
| + identifier);
|
| }
|
| return true;
|
| }
|
| @@ -3469,7 +3490,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.IMPORT_DUPLICATED_LIBRARY_NAME].
|
| */
|
| bool _checkForImportDuplicateLibraryName(
|
| - ImportDirective node, ImportElement importElement) {
|
| + ImportDirective directive, ImportElement importElement) {
|
| // prepare imported library
|
| LibraryElement nodeLibrary = importElement.importedLibrary;
|
| if (nodeLibrary == null) {
|
| @@ -3482,13 +3503,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (prevLibrary != nodeLibrary) {
|
| if (name.isEmpty) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_UNNAMED, node, [
|
| + StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_UNNAMED, directive, [
|
| prevLibrary.definingCompilationUnit.displayName,
|
| nodeLibrary.definingCompilationUnit.displayName
|
| ]);
|
| } else {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED, node, [
|
| + StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED, directive, [
|
| prevLibrary.definingCompilationUnit.displayName,
|
| nodeLibrary.definingCompilationUnit.displayName,
|
| name
|
| @@ -3512,7 +3533,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY].
|
| */
|
| bool _checkForImportInternalLibrary(
|
| - ImportDirective node, ImportElement importElement) {
|
| + ImportDirective directive, ImportElement importElement) {
|
| if (_isInSystemLibrary) {
|
| return false;
|
| }
|
| @@ -3528,7 +3549,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // report problem
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, node, [node.uri]);
|
| + CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, directive,
|
| + [directive.uri]);
|
| return true;
|
| }
|
|
|
| @@ -3667,7 +3689,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
|
|
| /**
|
| * Verify that an 'int' can be assigned to the parameter corresponding to the
|
| - * given [expression]. This is used for prefix and postfix expressions where
|
| + * given [argument]. This is used for prefix and postfix expressions where
|
| * the argument value is implicit.
|
| *
|
| * See [StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE].
|
| @@ -3688,13 +3710,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY].
|
| */
|
| - bool _checkForInvalidAnnotationFromDeferredLibrary(Annotation node) {
|
| - Identifier nameIdentifier = node.name;
|
| + bool _checkForInvalidAnnotationFromDeferredLibrary(Annotation annotation) {
|
| + Identifier nameIdentifier = annotation.name;
|
| if (nameIdentifier is PrefixedIdentifier) {
|
| if (nameIdentifier.isDeferred) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.INVALID_ANNOTATION_FROM_DEFERRED_LIBRARY,
|
| - node.name);
|
| + annotation.name);
|
| return true;
|
| }
|
| }
|
| @@ -3735,7 +3757,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [StaticTypeWarningCode.INVALID_ASSIGNMENT].
|
| */
|
| bool _checkForInvalidCompoundAssignment(
|
| - AssignmentExpression node, Expression lhs, Expression rhs) {
|
| + AssignmentExpression assignment, Expression lhs, Expression rhs) {
|
| if (lhs == null) {
|
| return false;
|
| }
|
| @@ -3743,7 +3765,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| DartType leftType = (leftVariableElement == null)
|
| ? getStaticType(lhs)
|
| : leftVariableElement.type;
|
| - MethodElement invokedMethod = node.staticElement;
|
| + MethodElement invokedMethod = assignment.staticElement;
|
| if (invokedMethod == null) {
|
| return false;
|
| }
|
| @@ -3765,22 +3787,22 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [ConstructorFieldInitializer]. The [staticElement] is the static element
|
| * from the name in the [ConstructorFieldInitializer].
|
| */
|
| - void _checkForInvalidField(ConstructorFieldInitializer node,
|
| + void _checkForInvalidField(ConstructorFieldInitializer initializer,
|
| SimpleIdentifier fieldName, Element staticElement) {
|
| if (staticElement is FieldElement) {
|
| FieldElement fieldElement = staticElement;
|
| if (fieldElement.isSynthetic) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD, node,
|
| - [fieldName]);
|
| + CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD,
|
| + initializer, [fieldName]);
|
| } else if (fieldElement.isStatic) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, node,
|
| + CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, initializer,
|
| [fieldName]);
|
| }
|
| } else {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD, node,
|
| + CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTENT_FIELD, initializer,
|
| [fieldName]);
|
| return;
|
| }
|
| @@ -3805,10 +3827,10 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS].
|
| */
|
| - bool _checkForInvalidReferenceToThis(ThisExpression node) {
|
| - if (!_isThisInValidContext(node)) {
|
| + bool _checkForInvalidReferenceToThis(ThisExpression expression) {
|
| + if (!_isThisInValidContext(expression)) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS, node);
|
| + CompileTimeErrorCode.INVALID_REFERENCE_TO_THIS, expression);
|
| return true;
|
| }
|
| return false;
|
| @@ -3833,14 +3855,14 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Verify that the elements given [ListLiteral] are subtypes of the specified
|
| + * Verify that the elements given list [literal] are subtypes of the specified
|
| * element type. The [typeArguments] are the type arguments.
|
| *
|
| * See [CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE], and
|
| * [StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE].
|
| */
|
| bool _checkForListElementTypeNotAssignable(
|
| - ListLiteral node, TypeArgumentList typeArguments) {
|
| + ListLiteral literal, TypeArgumentList typeArguments) {
|
| NodeList<TypeName> typeNames = typeArguments.arguments;
|
| if (typeNames.length < 1) {
|
| return false;
|
| @@ -3848,8 +3870,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| DartType listElementType = typeNames[0].type;
|
| // Check every list element.
|
| bool hasProblems = false;
|
| - for (Expression element in node.elements) {
|
| - if (node.constKeyword != null) {
|
| + for (Expression element in literal.elements) {
|
| + if (literal.constKeyword != null) {
|
| // TODO(paulberry): this error should be based on the actual type of the
|
| // list element, not the static type. See dartbug.com/21119.
|
| if (_checkForArgumentTypeNotAssignableWithExpectedTypes(element,
|
| @@ -3878,7 +3900,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE].
|
| */
|
| bool _checkForMapTypeNotAssignable(
|
| - MapLiteral node, TypeArgumentList typeArguments) {
|
| + MapLiteral literal, TypeArgumentList typeArguments) {
|
| // Prepare maps key/value types.
|
| NodeList<TypeName> typeNames = typeArguments.arguments;
|
| if (typeNames.length < 2) {
|
| @@ -3888,11 +3910,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| DartType valueType = typeNames[1].type;
|
| // Check every map entry.
|
| bool hasProblems = false;
|
| - NodeList<MapLiteralEntry> entries = node.entries;
|
| + NodeList<MapLiteralEntry> entries = literal.entries;
|
| for (MapLiteralEntry entry in entries) {
|
| Expression key = entry.key;
|
| Expression value = entry.value;
|
| - if (node.constKeyword != null) {
|
| + if (literal.constKeyword != null) {
|
| // TODO(paulberry): this error should be based on the actual type of the
|
| // list element, not the static type. See dartbug.com/21119.
|
| if (_checkForArgumentTypeNotAssignableWithExpectedTypes(key, keyType,
|
| @@ -3918,7 +3940,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Verify that the [enclosingClass] does not define members with the same name
|
| + * Verify that the [_enclosingClass] does not define members with the same name
|
| * as the enclosing class.
|
| *
|
| * See [CompileTimeErrorCode.MEMBER_WITH_CLASS_NAME].
|
| @@ -4098,7 +4120,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.MIXED_RETURN_TYPES].
|
| */
|
| - bool _checkForMixedReturns(BlockFunctionBody node) {
|
| + bool _checkForMixedReturns(BlockFunctionBody body) {
|
| if (_hasReturnWithoutValue) {
|
| return false;
|
| }
|
| @@ -4182,9 +4204,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS].
|
| */
|
| - bool _checkForMultipleSuperInitializers(ConstructorDeclaration node) {
|
| + bool _checkForMultipleSuperInitializers(ConstructorDeclaration constructor) {
|
| int numSuperInitializers = 0;
|
| - for (ConstructorInitializer initializer in node.initializers) {
|
| + for (ConstructorInitializer initializer in constructor.initializers) {
|
| if (initializer is SuperConstructorInvocation) {
|
| numSuperInitializers++;
|
| if (numSuperInitializers > 1) {
|
| @@ -4201,10 +4223,10 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE].
|
| */
|
| - bool _checkForNativeFunctionBodyInNonSDKCode(NativeFunctionBody node) {
|
| + bool _checkForNativeFunctionBodyInNonSDKCode(NativeFunctionBody body) {
|
| if (!_isInSystemLibrary && !_hasExtUri) {
|
| _errorReporter.reportErrorForNode(
|
| - ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE, node);
|
| + ParserErrorCode.NATIVE_FUNCTION_BODY_IN_NON_SDK_CODE, body);
|
| return true;
|
| }
|
| return false;
|
| @@ -4220,10 +4242,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.NEW_WITH_UNDEFINED_CONSTRUCTOR].
|
| */
|
| - bool _checkForNewWithUndefinedConstructor(InstanceCreationExpression node,
|
| - ConstructorName constructorName, TypeName typeName) {
|
| + bool _checkForNewWithUndefinedConstructor(
|
| + InstanceCreationExpression expression, ConstructorName constructorName,
|
| + TypeName typeName) {
|
| // OK if resolved
|
| - if (node.staticElement != null) {
|
| + if (expression.staticElement != null) {
|
| return false;
|
| }
|
| DartType type = typeName.type;
|
| @@ -4259,7 +4282,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT].
|
| */
|
| - bool _checkForNoDefaultSuperConstructorImplicit(ClassDeclaration node) {
|
| + bool _checkForNoDefaultSuperConstructorImplicit(
|
| + ClassDeclaration declaration) {
|
| // do nothing if mixin errors have already been reported for this class.
|
| ClassElementImpl enclosingClass = _enclosingClass;
|
| if (enclosingClass.mixinErrorsReported) {
|
| @@ -4282,7 +4306,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (superUnnamedConstructor != null) {
|
| if (superUnnamedConstructor.isFactory) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, node.name,
|
| + CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, declaration.name,
|
| [superUnnamedConstructor]);
|
| return true;
|
| }
|
| @@ -4294,8 +4318,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // report problem
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT, node.name,
|
| - [superType.displayName]);
|
| + CompileTimeErrorCode.NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT,
|
| + declaration.name, [superType.displayName]);
|
| return true;
|
| }
|
|
|
| @@ -4498,8 +4522,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticTypeWarningCode.NON_BOOL_EXPRESSION].
|
| */
|
| - bool _checkForNonBoolExpression(AssertStatement node) {
|
| - Expression expression = node.condition;
|
| + bool _checkForNonBoolExpression(AssertStatement statement) {
|
| + Expression expression = statement.condition;
|
| DartType type = getStaticType(expression);
|
| if (type is InterfaceType) {
|
| if (!type.isAssignableTo(_boolType)) {
|
| @@ -4542,28 +4566,28 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT].
|
| */
|
| - bool _checkForNonConstMapAsExpressionStatement(MapLiteral node) {
|
| + bool _checkForNonConstMapAsExpressionStatement(MapLiteral literal) {
|
| // "const"
|
| - if (node.constKeyword != null) {
|
| + if (literal.constKeyword != null) {
|
| return false;
|
| }
|
| // has type arguments
|
| - if (node.typeArguments != null) {
|
| + if (literal.typeArguments != null) {
|
| return false;
|
| }
|
| // prepare statement
|
| Statement statement =
|
| - node.getAncestor((node) => node is ExpressionStatement);
|
| + literal.getAncestor((node) => node is ExpressionStatement);
|
| if (statement == null) {
|
| return false;
|
| }
|
| // OK, statement does not start with map
|
| - if (!identical(statement.beginToken, node.beginToken)) {
|
| + if (!identical(statement.beginToken, literal.beginToken)) {
|
| return false;
|
| }
|
| // report problem
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT, node);
|
| + CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT, literal);
|
| return true;
|
| }
|
|
|
| @@ -4573,14 +4597,14 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.NON_VOID_RETURN_FOR_OPERATOR].
|
| */
|
| - bool _checkForNonVoidReturnTypeForOperator(MethodDeclaration node) {
|
| + bool _checkForNonVoidReturnTypeForOperator(MethodDeclaration declaration) {
|
| // check that []= operator
|
| - SimpleIdentifier name = node.name;
|
| + SimpleIdentifier name = declaration.name;
|
| if (name.name != "[]=") {
|
| return false;
|
| }
|
| // check return type
|
| - TypeName typeName = node.returnType;
|
| + TypeName typeName = declaration.returnType;
|
| if (typeName != null) {
|
| DartType type = typeName.type;
|
| if (type != null && !type.isVoid) {
|
| @@ -4593,7 +4617,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Verify the given setter has no return type or the `void` return type.
|
| + * Verify the [typeName], used as the return type of a setter, is valid
|
| + * (either `null` or the type 'void').
|
| *
|
| * See [StaticWarningCode.NON_VOID_RETURN_FOR_SETTER].
|
| */
|
| @@ -4615,8 +4640,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_OPERATOR].
|
| */
|
| - bool _checkForOptionalParameterInOperator(MethodDeclaration node) {
|
| - FormalParameterList parameterList = node.parameters;
|
| + bool _checkForOptionalParameterInOperator(MethodDeclaration declaration) {
|
| + FormalParameterList parameterList = declaration.parameters;
|
| if (parameterList == null) {
|
| return false;
|
| }
|
| @@ -4638,19 +4663,19 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER].
|
| */
|
| - bool _checkForPrivateOptionalParameter(FormalParameter node) {
|
| + bool _checkForPrivateOptionalParameter(FormalParameter parameter) {
|
| // should be named parameter
|
| - if (node.kind != ParameterKind.NAMED) {
|
| + if (parameter.kind != ParameterKind.NAMED) {
|
| return false;
|
| }
|
| // name should start with '_'
|
| - SimpleIdentifier name = node.identifier;
|
| + SimpleIdentifier name = parameter.identifier;
|
| if (name.isSynthetic || !StringUtilities.startsWithChar(name.name, 0x5F)) {
|
| return false;
|
| }
|
| // report problem
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER, node);
|
| + CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAMETER, parameter);
|
| return true;
|
| }
|
|
|
| @@ -4661,15 +4686,15 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.RECURSIVE_CONSTRUCTOR_REDIRECT].
|
| */
|
| - bool _checkForRecursiveConstructorRedirect(
|
| - ConstructorDeclaration node, ConstructorElement constructorElement) {
|
| + bool _checkForRecursiveConstructorRedirect(ConstructorDeclaration declaration,
|
| + ConstructorElement constructorElement) {
|
| // we check generative constructor here
|
| - if (node.factoryKeyword != null) {
|
| + if (declaration.factoryKeyword != null) {
|
| return false;
|
| }
|
| // try to find redirecting constructor invocation and analyzer it for
|
| // recursion
|
| - for (ConstructorInitializer initializer in node.initializers) {
|
| + for (ConstructorInitializer initializer in declaration.initializers) {
|
| if (initializer is RedirectingConstructorInvocation) {
|
| // OK if no cycle
|
| if (!_hasRedirectingFactoryConstructorCycle(constructorElement)) {
|
| @@ -4688,19 +4713,20 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| /**
|
| * Check whether the given constructor [declaration] has redirected
|
| * constructor and references itself directly or indirectly. The
|
| - * [constructorElement] is the constructor element.
|
| + * constructor [element] is the element introduced by the declaration.
|
| *
|
| * See [CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT].
|
| */
|
| bool _checkForRecursiveFactoryRedirect(
|
| - ConstructorDeclaration node, ConstructorElement constructorElement) {
|
| + ConstructorDeclaration declaration, ConstructorElement element) {
|
| // prepare redirected constructor
|
| - ConstructorName redirectedConstructorNode = node.redirectedConstructor;
|
| + ConstructorName redirectedConstructorNode =
|
| + declaration.redirectedConstructor;
|
| if (redirectedConstructorNode == null) {
|
| return false;
|
| }
|
| // OK if no cycle
|
| - if (!_hasRedirectingFactoryConstructorCycle(constructorElement)) {
|
| + if (!_hasRedirectingFactoryConstructorCycle(element)) {
|
| return false;
|
| }
|
| // report error
|
| @@ -4717,12 +4743,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS], and
|
| * [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS].
|
| */
|
| - bool _checkForRecursiveInterfaceInheritance(ClassElement classElt) {
|
| - if (classElt == null) {
|
| + bool _checkForRecursiveInterfaceInheritance(ClassElement element) {
|
| + if (element == null) {
|
| return false;
|
| }
|
| return _safeCheckForRecursiveInterfaceInheritance(
|
| - classElt, new List<ClassElement>());
|
| + element, new List<ClassElement>());
|
| }
|
|
|
| /**
|
| @@ -4736,14 +4762,15 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR], and
|
| * [CompileTimeErrorCode.REDIRECT_GENERATIVE_TO_NON_GENERATIVE_CONSTRUCTOR].
|
| */
|
| - bool _checkForRedirectingConstructorErrorCodes(ConstructorDeclaration node) {
|
| + bool _checkForRedirectingConstructorErrorCodes(
|
| + ConstructorDeclaration declaration) {
|
| bool errorReported = false;
|
| //
|
| // Check for default values in the parameters
|
| //
|
| - ConstructorName redirectedConstructor = node.redirectedConstructor;
|
| + ConstructorName redirectedConstructor = declaration.redirectedConstructor;
|
| if (redirectedConstructor != null) {
|
| - for (FormalParameter parameter in node.parameters.parameters) {
|
| + for (FormalParameter parameter in declaration.parameters.parameters) {
|
| if (parameter is DefaultFormalParameter &&
|
| parameter.defaultValue != null) {
|
| _errorReporter.reportErrorForNode(
|
| @@ -4755,7 +4782,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // check if there are redirected invocations
|
| int numRedirections = 0;
|
| - for (ConstructorInitializer initializer in node.initializers) {
|
| + for (ConstructorInitializer initializer in declaration.initializers) {
|
| if (initializer is RedirectingConstructorInvocation) {
|
| if (numRedirections > 0) {
|
| _errorReporter.reportErrorForNode(
|
| @@ -4763,7 +4790,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| initializer);
|
| errorReported = true;
|
| }
|
| - if (node.factoryKeyword == null) {
|
| + if (declaration.factoryKeyword == null) {
|
| RedirectingConstructorInvocation invocation = initializer;
|
| ConstructorElement redirectingElement = invocation.staticElement;
|
| if (redirectingElement == null) {
|
| @@ -4788,7 +4815,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // check for other initializers
|
| if (numRedirections > 0) {
|
| - for (ConstructorInitializer initializer in node.initializers) {
|
| + for (ConstructorInitializer initializer in declaration.initializers) {
|
| if (initializer is SuperConstructorInvocation) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.SUPER_IN_REDIRECTING_CONSTRUCTOR,
|
| @@ -4810,28 +4837,28 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| /**
|
| * Check whether the given constructor [declaration] has redirected
|
| * constructor and references itself directly or indirectly. The
|
| - * [constructorElement] is the constructor element.
|
| + * constructor [element] is the element introduced by the declaration.
|
| *
|
| * See [CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONSTRUCTOR].
|
| */
|
| bool _checkForRedirectToNonConstConstructor(
|
| - ConstructorDeclaration node, ConstructorElement constructorElement) {
|
| + ConstructorDeclaration declaration, ConstructorElement element) {
|
| // prepare redirected constructor
|
| - ConstructorName redirectedConstructorNode = node.redirectedConstructor;
|
| + ConstructorName redirectedConstructorNode =
|
| + declaration.redirectedConstructor;
|
| if (redirectedConstructorNode == null) {
|
| return false;
|
| }
|
| // prepare element
|
| - if (constructorElement == null) {
|
| + if (element == null) {
|
| return false;
|
| }
|
| // OK, it is not 'const'
|
| - if (!constructorElement.isConst) {
|
| + if (!element.isConst) {
|
| return false;
|
| }
|
| // prepare redirected constructor
|
| - ConstructorElement redirectedConstructor =
|
| - constructorElement.redirectedConstructor;
|
| + ConstructorElement redirectedConstructor = element.redirectedConstructor;
|
| if (redirectedConstructor == null) {
|
| return false;
|
| }
|
| @@ -4851,10 +4878,10 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH].
|
| */
|
| - bool _checkForRethrowOutsideCatch(RethrowExpression node) {
|
| + bool _checkForRethrowOutsideCatch(RethrowExpression expression) {
|
| if (!_isInCatchClause) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, node);
|
| + CompileTimeErrorCode.RETHROW_OUTSIDE_CATCH, expression);
|
| return true;
|
| }
|
| return false;
|
| @@ -4866,13 +4893,14 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONSTRUCTOR].
|
| */
|
| - bool _checkForReturnInGenerativeConstructor(ConstructorDeclaration node) {
|
| + bool _checkForReturnInGenerativeConstructor(
|
| + ConstructorDeclaration declaration) {
|
| // ignore factory
|
| - if (node.factoryKeyword != null) {
|
| + if (declaration.factoryKeyword != null) {
|
| return false;
|
| }
|
| // block body (with possible return statement) is checked elsewhere
|
| - FunctionBody body = node.body;
|
| + FunctionBody body = declaration.body;
|
| if (body is! ExpressionFunctionBody) {
|
| return false;
|
| }
|
| @@ -4977,15 +5005,15 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE].
|
| */
|
| - bool _checkForSwitchExpressionNotAssignable(SwitchStatement node) {
|
| + bool _checkForSwitchExpressionNotAssignable(SwitchStatement statement) {
|
| // prepare 'switch' expression type
|
| - Expression expression = node.expression;
|
| + Expression expression = statement.expression;
|
| DartType expressionType = getStaticType(expression);
|
| if (expressionType == null) {
|
| return false;
|
| }
|
| // compare with type of the first 'case'
|
| - NodeList<SwitchMember> members = node.members;
|
| + NodeList<SwitchMember> members = statement.members;
|
| for (SwitchMember switchMember in members) {
|
| if (switchMember is! SwitchCase) {
|
| continue;
|
| @@ -5016,13 +5044,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * See [CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF].
|
| */
|
| bool _checkForTypeAliasCannotReferenceItself_function(
|
| - FunctionTypeAlias node) {
|
| - FunctionTypeAliasElement element = node.element;
|
| + FunctionTypeAlias alias) {
|
| + FunctionTypeAliasElement element = alias.element;
|
| if (!_hasTypedefSelfReference(element)) {
|
| return false;
|
| }
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, node);
|
| + CompileTimeErrorCode.TYPE_ALIAS_CANNOT_REFERENCE_ITSELF, alias);
|
| return true;
|
| }
|
|
|
| @@ -5031,26 +5059,26 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS].
|
| */
|
| - bool _checkForTypeAnnotationDeferredClass(TypeName node) {
|
| - if (node != null && node.isDeferred) {
|
| + bool _checkForTypeAnnotationDeferredClass(TypeName name) {
|
| + if (name != null && name.isDeferred) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS, node, [node.name]);
|
| + StaticWarningCode.TYPE_ANNOTATION_DEFERRED_CLASS, name, [name.name]);
|
| }
|
| return false;
|
| }
|
|
|
| /**
|
| - * Verify that the type arguments in the given type [name] are all within
|
| + * Verify that the type arguments in the given [typeName] are all within
|
| * their bounds.
|
| *
|
| * See [StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS].
|
| */
|
| - bool _checkForTypeArgumentNotMatchingBounds(TypeName node) {
|
| - if (node.typeArguments == null) {
|
| + bool _checkForTypeArgumentNotMatchingBounds(TypeName typeName) {
|
| + if (typeName.typeArguments == null) {
|
| return false;
|
| }
|
| // prepare Type
|
| - DartType type = node.type;
|
| + DartType type = typeName.type;
|
| if (type == null) {
|
| return false;
|
| }
|
| @@ -5064,7 +5092,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| List<DartType> typeParameters = classElement.type.typeArguments;
|
| List<TypeParameterElement> boundingElts = classElement.typeParameters;
|
| // iterate over each bounded type parameter and corresponding argument
|
| - NodeList<TypeName> typeNameArgList = node.typeArguments.arguments;
|
| + NodeList<TypeName> typeNameArgList = typeName.typeArguments.arguments;
|
| List<DartType> typeArguments = (type as InterfaceType).typeArguments;
|
| int loopThroughIndex =
|
| math.min(typeNameArgList.length, boundingElts.length);
|
| @@ -5100,12 +5128,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC].
|
| */
|
| - bool _checkForTypeParameterReferencedByStatic(TypeName node) {
|
| + bool _checkForTypeParameterReferencedByStatic(TypeName name) {
|
| if (_isInStaticMethod || _isInStaticVariableDeclaration) {
|
| - DartType type = node.type;
|
| + DartType type = name.type;
|
| if (type is TypeParameterType) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC, node);
|
| + StaticWarningCode.TYPE_PARAMETER_REFERENCED_BY_STATIC, name);
|
| return true;
|
| }
|
| }
|
| @@ -5117,8 +5145,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND].
|
| */
|
| - bool _checkForTypeParameterSupertypeOfItsBound(TypeParameter node) {
|
| - TypeParameterElement element = node.element;
|
| + bool _checkForTypeParameterSupertypeOfItsBound(TypeParameter parameter) {
|
| + TypeParameterElement element = parameter.element;
|
| // prepare bound
|
| DartType bound = element.bound;
|
| if (bound == null) {
|
| @@ -5130,7 +5158,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // report problem
|
| _errorReporter.reportErrorForNode(
|
| - StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND, node,
|
| + StaticTypeWarningCode.TYPE_PARAMETER_SUPERTYPE_OF_ITS_BOUND, parameter,
|
| [element.displayName]);
|
| return true;
|
| }
|
| @@ -5145,7 +5173,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_EXPLICIT].
|
| */
|
| bool _checkForUndefinedConstructorInInitializerImplicit(
|
| - ConstructorDeclaration node) {
|
| + ConstructorDeclaration constructor) {
|
| if (_enclosingClass == null) {
|
| return false;
|
| }
|
| @@ -5157,14 +5185,15 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| //
|
| // Ignore if the constructor is not generative.
|
| //
|
| - if (node.factoryKeyword != null) {
|
| + if (constructor.factoryKeyword != null) {
|
| return false;
|
| }
|
| //
|
| // Ignore if the constructor has either an implicit super constructor
|
| // invocation or a redirecting constructor invocation.
|
| //
|
| - for (ConstructorInitializer constructorInitializer in node.initializers) {
|
| + for (ConstructorInitializer constructorInitializer
|
| + in constructor.initializers) {
|
| if (constructorInitializer is SuperConstructorInvocation ||
|
| constructorInitializer is RedirectingConstructorInvocation) {
|
| return false;
|
| @@ -5184,8 +5213,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (superUnnamedConstructor != null) {
|
| if (superUnnamedConstructor.isFactory) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, node.returnType,
|
| - [superUnnamedConstructor]);
|
| + CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR,
|
| + constructor.returnType, [superUnnamedConstructor]);
|
| return true;
|
| }
|
| if (!superUnnamedConstructor.isDefaultConstructor ||
|
| @@ -5194,8 +5223,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| int offset;
|
| int length;
|
| {
|
| - Identifier returnType = node.returnType;
|
| - SimpleIdentifier name = node.name;
|
| + Identifier returnType = constructor.returnType;
|
| + SimpleIdentifier name = constructor.name;
|
| offset = returnType.offset;
|
| length = (name != null ? name.end : returnType.end) - offset;
|
| }
|
| @@ -5207,7 +5236,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT,
|
| - node.returnType, [superElement.name]);
|
| + constructor.returnType, [superElement.name]);
|
| return true;
|
| }
|
|
|
| @@ -5240,16 +5269,16 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| return true;
|
| }
|
|
|
| - void _checkForValidField(FieldFormalParameter node) {
|
| - ParameterElement element = node.element;
|
| + void _checkForValidField(FieldFormalParameter parameter) {
|
| + ParameterElement element = parameter.element;
|
| if (element is FieldFormalParameterElement) {
|
| FieldElement fieldElement = element.field;
|
| if (fieldElement == null || fieldElement.isSynthetic) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD,
|
| - node, [node.identifier.name]);
|
| + parameter, [parameter.identifier.name]);
|
| } else {
|
| - ParameterElement parameterElement = node.element;
|
| + ParameterElement parameterElement = parameter.element;
|
| if (parameterElement is FieldFormalParameterElementImpl) {
|
| FieldFormalParameterElementImpl fieldFormal = parameterElement;
|
| DartType declaredType = fieldFormal.type;
|
| @@ -5257,27 +5286,27 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| if (fieldElement.isSynthetic) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD,
|
| - node, [node.identifier.name]);
|
| + parameter, [parameter.identifier.name]);
|
| } else if (fieldElement.isStatic) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD, node,
|
| - [node.identifier.name]);
|
| + CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD,
|
| + parameter, [parameter.identifier.name]);
|
| } else if (declaredType != null &&
|
| fieldType != null &&
|
| !declaredType.isAssignableTo(fieldType)) {
|
| _errorReporter.reportTypeErrorForNode(
|
| StaticWarningCode.FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE,
|
| - node, [declaredType, fieldType]);
|
| + parameter, [declaredType, fieldType]);
|
| }
|
| } else {
|
| if (fieldElement.isSynthetic) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_NON_EXISTENT_FIELD,
|
| - node, [node.identifier.name]);
|
| + parameter, [parameter.identifier.name]);
|
| } else if (fieldElement.isStatic) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD, node,
|
| - [node.identifier.name]);
|
| + CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_STATIC_FIELD,
|
| + parameter, [parameter.identifier.name]);
|
| }
|
| }
|
| }
|
| @@ -5293,8 +5322,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.VOID_RETURN_FOR_GETTER].
|
| */
|
| - bool _checkForVoidReturnType(MethodDeclaration node) {
|
| - TypeName returnType = node.returnType;
|
| + bool _checkForVoidReturnType(MethodDeclaration getter) {
|
| + TypeName returnType = getter.returnType;
|
| if (returnType == null || returnType.name.name != "void") {
|
| return false;
|
| }
|
| @@ -5312,15 +5341,16 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR].
|
| */
|
| - bool _checkForWrongNumberOfParametersForOperator(MethodDeclaration node) {
|
| + bool _checkForWrongNumberOfParametersForOperator(
|
| + MethodDeclaration declaration) {
|
| // prepare number of parameters
|
| - FormalParameterList parameterList = node.parameters;
|
| + FormalParameterList parameterList = declaration.parameters;
|
| if (parameterList == null) {
|
| return false;
|
| }
|
| int numParameters = parameterList.parameters.length;
|
| // prepare operator name
|
| - SimpleIdentifier nameNode = node.name;
|
| + SimpleIdentifier nameNode = declaration.name;
|
| if (nameNode == null) {
|
| return false;
|
| }
|
| @@ -5455,11 +5485,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [StaticWarningCode.FUNCTION_WITHOUT_CALL].
|
| */
|
| - bool _checkImplementsFunctionWithoutCall(ClassDeclaration node) {
|
| - if (node.isAbstract) {
|
| + bool _checkImplementsFunctionWithoutCall(ClassDeclaration declaration) {
|
| + if (declaration.isAbstract) {
|
| return false;
|
| }
|
| - ClassElement classElement = node.element;
|
| + ClassElement classElement = declaration.element;
|
| if (classElement == null) {
|
| return false;
|
| }
|
| @@ -5478,7 +5508,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| callMethod is! MethodElement ||
|
| (callMethod as MethodElement).isAbstract) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.FUNCTION_WITHOUT_CALL, node.name);
|
| + StaticWarningCode.FUNCTION_WITHOUT_CALL, declaration.name);
|
| return true;
|
| }
|
| return false;
|
| @@ -5490,14 +5520,14 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * See [CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS].
|
| */
|
| - bool _checkImplementsSuperClass(ClassDeclaration node) {
|
| + bool _checkImplementsSuperClass(ClassDeclaration declaration) {
|
| // prepare super type
|
| InterfaceType superType = _enclosingClass.supertype;
|
| if (superType == null) {
|
| return false;
|
| }
|
| // prepare interfaces
|
| - ImplementsClause implementsClause = node.implementsClause;
|
| + ImplementsClause implementsClause = declaration.implementsClause;
|
| if (implementsClause == null) {
|
| return false;
|
| }
|
| @@ -5539,12 +5569,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * Return the error code that should be used when the given class [element]
|
| * references itself directly.
|
| */
|
| - ErrorCode _getBaseCaseErrorCode(ClassElement classElt) {
|
| - InterfaceType supertype = classElt.supertype;
|
| + ErrorCode _getBaseCaseErrorCode(ClassElement element) {
|
| + InterfaceType supertype = element.supertype;
|
| if (supertype != null && _enclosingClass == supertype.element) {
|
| return CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS;
|
| }
|
| - List<InterfaceType> mixins = classElt.mixins;
|
| + List<InterfaceType> mixins = element.mixins;
|
| for (int i = 0; i < mixins.length; i++) {
|
| if (_enclosingClass == mixins[i].element) {
|
| return CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH;
|
| @@ -5573,8 +5603,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| /**
|
| * Return the return type of the given [getter].
|
| */
|
| - DartType _getGetterType(PropertyAccessorElement propertyAccessorElement) {
|
| - FunctionType functionType = propertyAccessorElement.type;
|
| + DartType _getGetterType(PropertyAccessorElement getter) {
|
| + FunctionType functionType = getter.type;
|
| if (functionType != null) {
|
| return functionType.returnType;
|
| } else {
|
| @@ -5585,10 +5615,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| /**
|
| * Return the type of the first and only parameter of the given [setter].
|
| */
|
| - DartType _getSetterType(PropertyAccessorElement propertyAccessorElement) {
|
| + DartType _getSetterType(PropertyAccessorElement setter) {
|
| // Get the parameters for MethodDeclaration or FunctionDeclaration
|
| - List<ParameterElement> setterParameters =
|
| - propertyAccessorElement.parameters;
|
| + List<ParameterElement> setterParameters = setter.parameters;
|
| // If there are no setter parameters, return no type.
|
| if (setterParameters.length == 0) {
|
| return null;
|
| @@ -5622,12 +5651,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * Return `true` if the given [constructor] redirects to itself, directly or
|
| * indirectly.
|
| */
|
| - bool _hasRedirectingFactoryConstructorCycle(ConstructorElement element) {
|
| + bool _hasRedirectingFactoryConstructorCycle(ConstructorElement constructor) {
|
| Set<ConstructorElement> constructors = new HashSet<ConstructorElement>();
|
| - ConstructorElement current = element;
|
| + ConstructorElement current = constructor;
|
| while (current != null) {
|
| if (constructors.contains(current)) {
|
| - return identical(current, element);
|
| + return identical(current, constructor);
|
| }
|
| constructors.add(current);
|
| current = current.redirectedConstructor;
|
| @@ -5642,13 +5671,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * Return `true` if the given [element] has direct or indirect reference to
|
| * itself from anywhere except a class element or type parameter bounds.
|
| */
|
| - bool _hasTypedefSelfReference(Element target) {
|
| + bool _hasTypedefSelfReference(Element element) {
|
| Set<Element> checked = new HashSet<Element>();
|
| List<Element> toCheck = new List<Element>();
|
| GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference elementVisitor =
|
| new GeneralizingElementVisitor_ErrorVerifier_hasTypedefSelfReference(
|
| toCheck);
|
| - toCheck.add(target);
|
| + toCheck.add(element);
|
| bool firstIteration = true;
|
| while (true) {
|
| Element current;
|
| @@ -5660,7 +5689,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| // try to get next element
|
| current = toCheck.removeAt(toCheck.length - 1);
|
| - if (target == current) {
|
| + if (element == current) {
|
| if (firstIteration) {
|
| firstIteration = false;
|
| break;
|
| @@ -5692,9 +5721,9 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| - * Return `true` iff the given class [element] has a method, getter or setter
|
| - * that matches the name of the given executable [element] in either the class
|
| - * itself, or one of its' mixins that is concrete.
|
| + * Return `true` iff the given [classElement] has a concrete method, getter or
|
| + * setter that matches the name of the given [executableElement] in either the
|
| + * class itself, or one of its' mixins.
|
| *
|
| * By "match", only the name of the member is tested to match, it does not
|
| * have to equal or be a subtype of the given executable element, this is due
|
| @@ -5702,34 +5731,34 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * [_checkForNonAbstractClassInheritsAbstractMember].
|
| */
|
| bool _isMemberInClassOrMixin(
|
| - ExecutableElement executableElt, ClassElement classElt) {
|
| + ExecutableElement executableElement, ClassElement classElement) {
|
| ExecutableElement foundElt = null;
|
| - String executableName = executableElt.name;
|
| - if (executableElt is MethodElement) {
|
| - foundElt = classElt.getMethod(executableName);
|
| + String executableName = executableElement.name;
|
| + if (executableElement is MethodElement) {
|
| + foundElt = classElement.getMethod(executableName);
|
| if (foundElt != null && !(foundElt as MethodElement).isAbstract) {
|
| return true;
|
| }
|
| - List<InterfaceType> mixins = classElt.mixins;
|
| + List<InterfaceType> mixins = classElement.mixins;
|
| for (int i = 0; i < mixins.length && foundElt == null; i++) {
|
| foundElt = mixins[i].getMethod(executableName);
|
| }
|
| if (foundElt != null && !(foundElt as MethodElement).isAbstract) {
|
| return true;
|
| }
|
| - } else if (executableElt is PropertyAccessorElement) {
|
| - PropertyAccessorElement propertyAccessorElement = executableElt;
|
| + } else if (executableElement is PropertyAccessorElement) {
|
| + PropertyAccessorElement propertyAccessorElement = executableElement;
|
| if (propertyAccessorElement.isGetter) {
|
| - foundElt = classElt.getGetter(executableName);
|
| + foundElt = classElement.getGetter(executableName);
|
| }
|
| if (foundElt == null && propertyAccessorElement.isSetter) {
|
| - foundElt = classElt.getSetter(executableName);
|
| + foundElt = classElement.getSetter(executableName);
|
| }
|
| if (foundElt != null &&
|
| !(foundElt as PropertyAccessorElement).isAbstract) {
|
| return true;
|
| }
|
| - List<InterfaceType> mixins = classElt.mixins;
|
| + List<InterfaceType> mixins = classElement.mixins;
|
| for (int i = 0; i < mixins.length && foundElt == null; i++) {
|
| foundElt = mixins[i].getGetter(executableName);
|
| if (foundElt == null) {
|
| @@ -5747,19 +5776,19 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| /**
|
| * Return `true` if the given 'this' [expression] is in a valid context.
|
| */
|
| - bool _isThisInValidContext(ThisExpression node) {
|
| - for (AstNode n = node; n != null; n = n.parent) {
|
| - if (n is CompilationUnit) {
|
| + bool _isThisInValidContext(ThisExpression expression) {
|
| + for (AstNode node = expression.parent; node != null; node = node.parent) {
|
| + if (node is CompilationUnit) {
|
| return false;
|
| }
|
| - if (n is ConstructorDeclaration) {
|
| - return n.factoryKeyword == null;
|
| + if (node is ConstructorDeclaration) {
|
| + return node.factoryKeyword == null;
|
| }
|
| - if (n is ConstructorInitializer) {
|
| + if (node is ConstructorInitializer) {
|
| return false;
|
| }
|
| - if (n is MethodDeclaration) {
|
| - return !n.isStatic;
|
| + if (node is MethodDeclaration) {
|
| + return !node.isStatic;
|
| }
|
| }
|
| return false;
|
| @@ -5770,21 +5799,22 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * allowed to resolve to a static member of a supertype.
|
| */
|
| bool _isUnqualifiedReferenceToNonLocalStaticMemberAllowed(
|
| - SimpleIdentifier node) {
|
| - if (node.inDeclarationContext()) {
|
| + SimpleIdentifier identifier) {
|
| + if (identifier.inDeclarationContext()) {
|
| return true;
|
| }
|
| - AstNode parent = node.parent;
|
| + AstNode parent = identifier.parent;
|
| if (parent is ConstructorName ||
|
| parent is MethodInvocation ||
|
| parent is PropertyAccess ||
|
| parent is SuperConstructorInvocation) {
|
| return true;
|
| }
|
| - if (parent is PrefixedIdentifier && identical(parent.identifier, node)) {
|
| + if (parent is PrefixedIdentifier &&
|
| + identical(parent.identifier, identifier)) {
|
| return true;
|
| }
|
| - if (parent is Annotation && identical(parent.constructorName, node)) {
|
| + if (parent is Annotation && identical(parent.constructorName, identifier)) {
|
| return true;
|
| }
|
| if (parent is CommentReference) {
|
| @@ -5809,12 +5839,12 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| * and [CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH].
|
| */
|
| bool _safeCheckForRecursiveInterfaceInheritance(
|
| - ClassElement classElt, List<ClassElement> path) {
|
| + ClassElement element, List<ClassElement> path) {
|
| // Detect error condition.
|
| int size = path.length;
|
| // If this is not the base case (size > 0), and the enclosing class is the
|
| // given class element then an error an error.
|
| - if (size > 0 && _enclosingClass == classElt) {
|
| + if (size > 0 && _enclosingClass == element) {
|
| String enclosingClassName = _enclosingClass.displayName;
|
| if (size > 1) {
|
| // Construct a string showing the cyclic implements path:
|
| @@ -5825,7 +5855,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| buffer.write(path[i].displayName);
|
| buffer.write(separator);
|
| }
|
| - buffer.write(classElt.displayName);
|
| + buffer.write(element.displayName);
|
| _errorReporter.reportErrorForOffset(
|
| CompileTimeErrorCode.RECURSIVE_INTERFACE_INHERITANCE,
|
| _enclosingClass.nameOffset, enclosingClassName.length, [
|
| @@ -5837,30 +5867,30 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
|
| // RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_EXTENDS or
|
| // RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_IMPLEMENTS or
|
| // RECURSIVE_INTERFACE_INHERITANCE_BASE_CASE_WITH
|
| - _errorReporter.reportErrorForOffset(_getBaseCaseErrorCode(classElt),
|
| + _errorReporter.reportErrorForOffset(_getBaseCaseErrorCode(element),
|
| _enclosingClass.nameOffset, enclosingClassName.length,
|
| [enclosingClassName]);
|
| return true;
|
| }
|
| }
|
| - if (path.indexOf(classElt) > 0) {
|
| + if (path.indexOf(element) > 0) {
|
| return false;
|
| }
|
| - path.add(classElt);
|
| + path.add(element);
|
| // n-case
|
| - InterfaceType supertype = classElt.supertype;
|
| + InterfaceType supertype = element.supertype;
|
| if (supertype != null &&
|
| _safeCheckForRecursiveInterfaceInheritance(supertype.element, path)) {
|
| return true;
|
| }
|
| - List<InterfaceType> interfaceTypes = classElt.interfaces;
|
| + List<InterfaceType> interfaceTypes = element.interfaces;
|
| for (InterfaceType interfaceType in interfaceTypes) {
|
| if (_safeCheckForRecursiveInterfaceInheritance(
|
| interfaceType.element, path)) {
|
| return true;
|
| }
|
| }
|
| - List<InterfaceType> mixinTypes = classElt.mixins;
|
| + List<InterfaceType> mixinTypes = element.mixins;
|
| for (InterfaceType mixinType in mixinTypes) {
|
| if (_safeCheckForRecursiveInterfaceInheritance(mixinType.element, path)) {
|
| return true;
|
|
|