| Index: pkg/analyzer/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
|
| index 3b95611189f48233af5dd62a7457b6a6d0a1c2df..9b9e88dd0c39bf2c46374fc9a53053ac91086483 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -35,13 +35,13 @@ import 'utilities_dart.dart';
|
| typedef void ImplicitConstructorBuilderCallback(ClassElement classElement,
|
| ClassElement superclassElement, void computation());
|
|
|
| -typedef ResolverVisitor ResolverVisitorFactory(Library library, Source source,
|
| - TypeProvider typeProvider);
|
| +typedef ResolverVisitor ResolverVisitorFactory(
|
| + Library library, Source source, TypeProvider typeProvider);
|
|
|
| typedef StaticTypeAnalyzer StaticTypeAnalyzerFactory(ResolverVisitor visitor);
|
|
|
| -typedef TypeResolverVisitor TypeResolverVisitorFactory(Library library,
|
| - Source source, TypeProvider typeProvider);
|
| +typedef TypeResolverVisitor TypeResolverVisitorFactory(
|
| + Library library, Source source, TypeProvider typeProvider);
|
|
|
| typedef void VoidFunction();
|
|
|
| @@ -188,8 +188,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
|
|
| @override
|
| - Object
|
| - visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
|
| + Object visitRedirectingConstructorInvocation(
|
| + RedirectingConstructorInvocation node) {
|
| _checkForDeprecatedMemberUse(node.staticElement, node);
|
| return super.visitRedirectingConstructorInvocation(node);
|
| }
|
| @@ -237,13 +237,11 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| if (node.notOperator == null) {
|
| // the is case
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
|
| - node);
|
| + HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node);
|
| } else {
|
| // the is not case
|
| - _errorReporter.reportErrorForNode(
|
| - HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
|
| - node);
|
| + _errorReporter
|
| + .reportErrorForNode(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node);
|
| }
|
| return true;
|
| }
|
| @@ -257,13 +255,11 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| if (node.notOperator == null) {
|
| // the is case
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.UNNECESSARY_TYPE_CHECK_TRUE,
|
| - node);
|
| + HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node);
|
| } else {
|
| // the is not case
|
| - _errorReporter.reportErrorForNode(
|
| - HintCode.UNNECESSARY_TYPE_CHECK_FALSE,
|
| - node);
|
| + _errorReporter
|
| + .reportErrorForNode(HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node);
|
| }
|
| return true;
|
| } else if (rhsNameStr == _NULL_TYPE_NAME) {
|
| @@ -272,9 +268,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| _errorReporter.reportErrorForNode(HintCode.TYPE_CHECK_IS_NULL, node);
|
| } else {
|
| // the is not case
|
| - _errorReporter.reportErrorForNode(
|
| - HintCode.TYPE_CHECK_IS_NOT_NULL,
|
| - node);
|
| + _errorReporter
|
| + .reportErrorForNode(HintCode.TYPE_CHECK_IS_NOT_NULL, node);
|
| }
|
| return true;
|
| }
|
| @@ -317,16 +312,15 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| // Hint case: test propagated type information
|
| //
|
| // Compute the best types to use.
|
| - DartType expectedBestType =
|
| - expectedPropagatedType != null ? expectedPropagatedType : expectedStaticType;
|
| + DartType expectedBestType = expectedPropagatedType != null
|
| + ? expectedPropagatedType
|
| + : expectedStaticType;
|
| DartType actualBestType =
|
| actualPropagatedType != null ? actualPropagatedType : actualStaticType;
|
| if (actualBestType != null && expectedBestType != null) {
|
| if (!actualBestType.isAssignableTo(expectedBestType)) {
|
| _errorReporter.reportTypeErrorForNode(
|
| - hintCode,
|
| - expression,
|
| - [actualBestType, expectedBestType]);
|
| + hintCode, expression, [actualBestType, expectedBestType]);
|
| return true;
|
| }
|
| }
|
| @@ -351,12 +345,11 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| staticParameterElement == null ? null : staticParameterElement.type;
|
| ParameterElement propagatedParameterElement =
|
| argument.propagatedParameterElement;
|
| - DartType propagatedParameterType =
|
| - propagatedParameterElement == null ? null : propagatedParameterElement.type;
|
| - return _checkForArgumentTypeNotAssignableWithExpectedTypes(
|
| - argument,
|
| - staticParameterType,
|
| - propagatedParameterType,
|
| + DartType propagatedParameterType = propagatedParameterElement == null
|
| + ? null
|
| + : propagatedParameterElement.type;
|
| + return _checkForArgumentTypeNotAssignableWithExpectedTypes(argument,
|
| + staticParameterType, propagatedParameterType,
|
| HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE);
|
| }
|
|
|
| @@ -371,17 +364,12 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| * @return `true` if and only if an hint code is generated on the passed node
|
| * See [HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE].
|
| */
|
| - bool
|
| - _checkForArgumentTypeNotAssignableWithExpectedTypes(Expression expression,
|
| - DartType expectedStaticType, DartType expectedPropagatedType,
|
| - ErrorCode errorCode) =>
|
| - _checkForArgumentTypeNotAssignable(
|
| - expression,
|
| - expectedStaticType,
|
| - expression.staticType,
|
| - expectedPropagatedType,
|
| - expression.propagatedType,
|
| - errorCode);
|
| + bool _checkForArgumentTypeNotAssignableWithExpectedTypes(
|
| + Expression expression, DartType expectedStaticType,
|
| + DartType expectedPropagatedType, ErrorCode errorCode) =>
|
| + _checkForArgumentTypeNotAssignable(expression, expectedStaticType,
|
| + expression.staticType, expectedPropagatedType,
|
| + expression.propagatedType, errorCode);
|
|
|
| /**
|
| * This verifies that the passed arguments can be assigned to their corresponding parameters.
|
| @@ -428,9 +416,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| }
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.DEPRECATED_MEMBER_USE,
|
| - node,
|
| - [displayName]);
|
| + HintCode.DEPRECATED_MEMBER_USE, node, [displayName]);
|
| return true;
|
| }
|
| return false;
|
| @@ -496,8 +482,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| if (_TO_INT_METHOD_NAME == methodInvocation.methodName.name &&
|
| methodInvocation.argumentList.arguments.isEmpty) {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.DIVISION_OPTIMIZATION,
|
| - methodInvocation);
|
| + HintCode.DIVISION_OPTIMIZATION, methodInvocation);
|
| return true;
|
| }
|
| }
|
| @@ -520,9 +505,9 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| return false;
|
| }
|
| VariableElement leftVariableElement = ErrorVerifier.getVariableElement(lhs);
|
| - DartType leftType = (leftVariableElement == null) ?
|
| - ErrorVerifier.getStaticType(lhs) :
|
| - leftVariableElement.type;
|
| + DartType leftType = (leftVariableElement == null)
|
| + ? ErrorVerifier.getStaticType(lhs)
|
| + : leftVariableElement.type;
|
| DartType staticRightType = ErrorVerifier.getStaticType(rhs);
|
| if (!staticRightType.isAssignableTo(leftType)) {
|
| // The warning was generated on this rhs
|
| @@ -533,9 +518,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| if (leftType != null && bestRightType != null) {
|
| if (!bestRightType.isAssignableTo(leftType)) {
|
| _errorReporter.reportTypeErrorForNode(
|
| - HintCode.INVALID_ASSIGNMENT,
|
| - rhs,
|
| - [bestRightType, leftType]);
|
| + HintCode.INVALID_ASSIGNMENT, rhs, [bestRightType, leftType]);
|
| return true;
|
| }
|
| }
|
| @@ -551,17 +534,17 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| * @return `true` if and only if an error code is generated on the passed node
|
| * See [CompileTimeErrorCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION].
|
| */
|
| - bool _checkForLoadLibraryFunction(ImportDirective node,
|
| - ImportElement importElement) {
|
| + bool _checkForLoadLibraryFunction(
|
| + ImportDirective node, ImportElement importElement) {
|
| LibraryElement importedLibrary = importElement.importedLibrary;
|
| if (importedLibrary == null) {
|
| return false;
|
| }
|
| if (importedLibrary.hasLoadLibraryFunction) {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
|
| - node,
|
| - [importedLibrary.name]);
|
| + HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, node, [
|
| + importedLibrary.name
|
| + ]);
|
| return true;
|
| }
|
| return false;
|
| @@ -607,9 +590,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| BlockFunctionBody blockFunctionBody = body as BlockFunctionBody;
|
| if (!ExitDetector.exits(blockFunctionBody)) {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.MISSING_RETURN,
|
| - returnType,
|
| - [returnTypeType.displayName]);
|
| + HintCode.MISSING_RETURN, returnType, [returnTypeType.displayName]);
|
| return true;
|
| }
|
| return false;
|
| @@ -712,9 +693,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| if (identical(methodInvocation.staticType, VoidTypeImpl.instance)) {
|
| SimpleIdentifier methodName = methodInvocation.methodName;
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.USE_OF_VOID_RESULT,
|
| - methodName,
|
| - [methodName.name]);
|
| + HintCode.USE_OF_VOID_RESULT, methodName, [methodName.name]);
|
| return true;
|
| }
|
| return false;
|
| @@ -731,8 +710,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| * @return the first parent or grand-parent that is a parenthesized expression, that does not have
|
| * a parenthesized expression parent
|
| */
|
| - static ParenthesizedExpression
|
| - _wrapParenthesizedExpression(ParenthesizedExpression parenthesizedExpression) {
|
| + static ParenthesizedExpression _wrapParenthesizedExpression(
|
| + ParenthesizedExpression parenthesizedExpression) {
|
| if (parenthesizedExpression.parent is ParenthesizedExpression) {
|
| return _wrapParenthesizedExpression(
|
| parenthesizedExpression.parent as ParenthesizedExpression);
|
| @@ -763,19 +742,17 @@ class ClassScope extends EnclosedScope {
|
| AnalysisError getErrorForDuplicate(Element existing, Element duplicate) {
|
| if (existing is PropertyAccessorElement && duplicate is MethodElement) {
|
| if (existing.nameOffset < duplicate.nameOffset) {
|
| - return new AnalysisError.con2(
|
| - duplicate.source,
|
| - duplicate.nameOffset,
|
| + return new AnalysisError.con2(duplicate.source, duplicate.nameOffset,
|
| duplicate.displayName.length,
|
| - CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME,
|
| - [existing.displayName]);
|
| + CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME, [
|
| + existing.displayName
|
| + ]);
|
| } else {
|
| - return new AnalysisError.con2(
|
| - existing.source,
|
| - existing.nameOffset,
|
| + return new AnalysisError.con2(existing.source, existing.nameOffset,
|
| existing.displayName.length,
|
| - CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME,
|
| - [existing.displayName]);
|
| + CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME, [
|
| + existing.displayName
|
| + ]);
|
| }
|
| }
|
| return super.getErrorForDuplicate(existing, duplicate);
|
| @@ -806,8 +783,8 @@ class CompilationUnitBuilder {
|
| * compilation [unit] associated with the source. Throw an AnalysisException
|
| * if the element could not be built.
|
| */
|
| - CompilationUnitElementImpl buildCompilationUnit(Source source,
|
| - CompilationUnit unit) {
|
| + CompilationUnitElementImpl buildCompilationUnit(
|
| + Source source, CompilationUnit unit) {
|
| return PerformanceStatistics.resolve.makeCurrentWhile(() {
|
| if (unit == null) {
|
| return null;
|
| @@ -877,8 +854,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| *
|
| * @param errorReporter the error reporter by which errors will be reported
|
| */
|
| - ConstantVerifier(this._errorReporter, this._currentLibrary,
|
| - this._typeProvider) {
|
| + ConstantVerifier(
|
| + this._errorReporter, this._currentLibrary, this._typeProvider) {
|
| this._boolType = _typeProvider.boolType;
|
| this._intType = _typeProvider.intType;
|
| this._numType = _typeProvider.numType;
|
| @@ -895,16 +872,14 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| // should 'const' constructor
|
| if (!constructorElement.isConst) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR,
|
| - node);
|
| + CompileTimeErrorCode.NON_CONSTANT_ANNOTATION_CONSTRUCTOR, node);
|
| return null;
|
| }
|
| // should have arguments
|
| ArgumentList argumentList = node.arguments;
|
| if (argumentList == null) {
|
| _errorReporter.reportErrorForNode(
|
| - CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS,
|
| - node);
|
| + CompileTimeErrorCode.NO_ANNOTATION_CONSTRUCTOR_ARGUMENTS, node);
|
| return null;
|
| }
|
| // arguments should be constants
|
| @@ -953,8 +928,7 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| result =
|
| _validate(element, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT);
|
| if (result != null) {
|
| - _reportErrorIfFromDeferredLibrary(
|
| - element,
|
| + _reportErrorIfFromDeferredLibrary(element,
|
| CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT_FROM_DEFERRED_LIBRARY);
|
| }
|
| }
|
| @@ -975,16 +949,14 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| DartObjectImpl keyResult =
|
| _validate(key, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY);
|
| Expression valueExpression = entry.value;
|
| - DartObjectImpl valueResult =
|
| - _validate(valueExpression, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE);
|
| + DartObjectImpl valueResult = _validate(
|
| + valueExpression, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE);
|
| if (valueResult != null) {
|
| - _reportErrorIfFromDeferredLibrary(
|
| - valueExpression,
|
| + _reportErrorIfFromDeferredLibrary(valueExpression,
|
| CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE_FROM_DEFERRED_LIBRARY);
|
| }
|
| if (keyResult != null) {
|
| - _reportErrorIfFromDeferredLibrary(
|
| - key,
|
| + _reportErrorIfFromDeferredLibrary(key,
|
| CompileTimeErrorCode.NON_CONSTANT_MAP_KEY_FROM_DEFERRED_LIBRARY);
|
| if (keys.contains(keyResult)) {
|
| invalidKeys.add(key);
|
| @@ -995,8 +967,7 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| if (_implementsEqualsWhenNotAllowed(type)) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
|
| - key,
|
| - [type.displayName]);
|
| + key, [type.displayName]);
|
| }
|
| }
|
| } else {
|
| @@ -1005,8 +976,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| AnalysisErrorListener.NULL_LISTENER;
|
| ErrorReporter subErrorReporter =
|
| new ErrorReporter(errorListener, _errorReporter.source);
|
| - DartObjectImpl result =
|
| - key.accept(new ConstantVisitor.con1(_typeProvider, subErrorReporter));
|
| + DartObjectImpl result = key
|
| + .accept(new ConstantVisitor.con1(_typeProvider, subErrorReporter));
|
| if (result != null) {
|
| if (keys.contains(result)) {
|
| invalidKeys.add(key);
|
| @@ -1021,8 +992,7 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| if (reportEqualKeys) {
|
| for (Expression key in invalidKeys) {
|
| _errorReporter.reportErrorForNode(
|
| - StaticWarningCode.EQUAL_KEYS_IN_MAP,
|
| - key);
|
| + StaticWarningCode.EQUAL_KEYS_IN_MAP, key);
|
| }
|
| }
|
| return null;
|
| @@ -1047,11 +1017,10 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| if (switchMember is SwitchCase) {
|
| SwitchCase switchCase = switchMember;
|
| Expression expression = switchCase.expression;
|
| - DartObjectImpl caseResult =
|
| - _validate(expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION);
|
| + DartObjectImpl caseResult = _validate(
|
| + expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION);
|
| if (caseResult != null) {
|
| - _reportErrorIfFromDeferredLibrary(
|
| - expression,
|
| + _reportErrorIfFromDeferredLibrary(expression,
|
| CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY);
|
| DartObject value = caseResult;
|
| if (firstType == null) {
|
| @@ -1061,8 +1030,7 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| if (firstType != nType) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
|
| - expression,
|
| - [expression.toSource(), firstType.displayName]);
|
| + expression, [expression.toSource(), firstType.displayName]);
|
| foundError = true;
|
| }
|
| }
|
| @@ -1088,18 +1056,14 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| // we have already computed their values. But if we missed it for some
|
| // reason, this gives us a second chance.
|
| //
|
| - result = new EvaluationResultImpl.con1(
|
| - _validate(
|
| - initializer,
|
| - CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE));
|
| + result = new EvaluationResultImpl.con1(_validate(initializer,
|
| + CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE));
|
| element.evaluationResult = result;
|
| return null;
|
| }
|
| - _reportErrors(
|
| - result.errors,
|
| + _reportErrors(result.errors,
|
| CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE);
|
| - _reportErrorIfFromDeferredLibrary(
|
| - initializer,
|
| + _reportErrorIfFromDeferredLibrary(initializer,
|
| CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE_FROM_DEFERRED_LIBRARY);
|
| }
|
| return null;
|
| @@ -1114,16 +1078,15 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| * @return `true` if and only if an error code is generated on the passed node
|
| * See [CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS].
|
| */
|
| - bool _checkForCaseExpressionTypeImplementsEquals(SwitchStatement node,
|
| - DartType type) {
|
| + bool _checkForCaseExpressionTypeImplementsEquals(
|
| + SwitchStatement node, DartType type) {
|
| if (!_implementsEqualsWhenNotAllowed(type)) {
|
| return false;
|
| }
|
| // report error
|
| _errorReporter.reportErrorForToken(
|
| CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
|
| - node.switchKeyword,
|
| - [type.displayName]);
|
| + node.switchKeyword, [type.displayName]);
|
| return true;
|
| }
|
|
|
| @@ -1162,8 +1125,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| * @param errorCode the error code to be used if the expression is or consists of a reference to a
|
| * deferred library
|
| */
|
| - void _reportErrorIfFromDeferredLibrary(Expression expression,
|
| - ErrorCode errorCode) {
|
| + void _reportErrorIfFromDeferredLibrary(
|
| + Expression expression, ErrorCode errorCode) {
|
| DeferredLibraryReferenceDetector referenceDetector =
|
| new DeferredLibraryReferenceDetector();
|
| expression.accept(referenceDetector);
|
| @@ -1182,29 +1145,25 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| void _reportErrors(List<AnalysisError> errors, ErrorCode errorCode) {
|
| for (AnalysisError data in errors) {
|
| ErrorCode dataErrorCode = data.errorCode;
|
| - if (identical(
|
| - dataErrorCode,
|
| - CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION) ||
|
| - identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE) ||
|
| + if (identical(dataErrorCode,
|
| + CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION) ||
|
| identical(
|
| - dataErrorCode,
|
| + dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE) ||
|
| + identical(dataErrorCode,
|
| CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING) ||
|
| identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL) ||
|
| identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_INT) ||
|
| identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM) ||
|
| - identical(
|
| - dataErrorCode,
|
| + identical(dataErrorCode,
|
| CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH) ||
|
| - identical(
|
| - dataErrorCode,
|
| + identical(dataErrorCode,
|
| CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH) ||
|
| - identical(
|
| - dataErrorCode,
|
| + identical(dataErrorCode,
|
| CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH)) {
|
| _errorReporter.reportError(data);
|
| } else if (errorCode != null) {
|
| - _errorReporter.reportError(
|
| - new AnalysisError.con2(data.source, data.offset, data.length, errorCode));
|
| + _errorReporter.reportError(new AnalysisError.con2(
|
| + data.source, data.offset, data.length, errorCode));
|
| }
|
| }
|
| }
|
| @@ -1221,8 +1180,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| RecordingErrorListener errorListener = new RecordingErrorListener();
|
| ErrorReporter subErrorReporter =
|
| new ErrorReporter(errorListener, _errorReporter.source);
|
| - DartObjectImpl result =
|
| - expression.accept(new ConstantVisitor.con1(_typeProvider, subErrorReporter));
|
| + DartObjectImpl result = expression
|
| + .accept(new ConstantVisitor.con1(_typeProvider, subErrorReporter));
|
| _reportErrors(errorListener.errors, errorCode);
|
| return result;
|
| }
|
| @@ -1238,8 +1197,7 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| argument = (argument as NamedExpression).expression;
|
| }
|
| _validate(
|
| - argument,
|
| - CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT);
|
| + argument, CompileTimeErrorCode.CONST_WITH_NON_CONSTANT_ARGUMENT);
|
| }
|
| }
|
|
|
| @@ -1257,20 +1215,17 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| if (initializer is ConstructorFieldInitializer) {
|
| ConstructorFieldInitializer fieldInitializer = initializer;
|
| _validateInitializerExpression(
|
| - parameterElements,
|
| - fieldInitializer.expression);
|
| + parameterElements, fieldInitializer.expression);
|
| }
|
| if (initializer is RedirectingConstructorInvocation) {
|
| RedirectingConstructorInvocation invocation = initializer;
|
| _validateInitializerInvocationArguments(
|
| - parameterElements,
|
| - invocation.argumentList);
|
| + parameterElements, invocation.argumentList);
|
| }
|
| if (initializer is SuperConstructorInvocation) {
|
| SuperConstructorInvocation invocation = initializer;
|
| _validateInitializerInvocationArguments(
|
| - parameterElements,
|
| - invocation.argumentList);
|
| + parameterElements, invocation.argumentList);
|
| }
|
| }
|
| }
|
| @@ -1294,11 +1249,10 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| result =
|
| new DartObjectImpl(_typeProvider.nullType, NullState.NULL_STATE);
|
| } else {
|
| - result =
|
| - _validate(defaultValue, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE);
|
| + result = _validate(
|
| + defaultValue, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE);
|
| if (result != null) {
|
| - _reportErrorIfFromDeferredLibrary(
|
| - defaultValue,
|
| + _reportErrorIfFromDeferredLibrary(defaultValue,
|
| CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY);
|
| }
|
| }
|
| @@ -1316,15 +1270,15 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| * @param classDeclaration the class which should be validated
|
| * @param errorSite the site at which errors should be reported.
|
| */
|
| - void _validateFieldInitializers(ClassDeclaration classDeclaration,
|
| - ConstructorDeclaration errorSite) {
|
| + void _validateFieldInitializers(
|
| + ClassDeclaration classDeclaration, ConstructorDeclaration errorSite) {
|
| NodeList<ClassMember> members = classDeclaration.members;
|
| for (ClassMember member in members) {
|
| if (member is FieldDeclaration) {
|
| FieldDeclaration fieldDeclaration = member;
|
| if (!fieldDeclaration.isStatic) {
|
| - for (VariableDeclaration variableDeclaration in
|
| - fieldDeclaration.fields.variables) {
|
| + for (VariableDeclaration variableDeclaration
|
| + in fieldDeclaration.fields.variables) {
|
| Expression initializer = variableDeclaration.initializer;
|
| if (initializer != null) {
|
| // Ignore any errors produced during validation--if the constant
|
| @@ -1333,13 +1287,12 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| AnalysisErrorListener.NULL_LISTENER;
|
| ErrorReporter subErrorReporter =
|
| new ErrorReporter(errorListener, _errorReporter.source);
|
| - DartObjectImpl result =
|
| - initializer.accept(new ConstantVisitor.con1(_typeProvider, subErrorReporter));
|
| + DartObjectImpl result = initializer.accept(
|
| + new ConstantVisitor.con1(_typeProvider, subErrorReporter));
|
| if (result == null) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
|
| - errorSite,
|
| - [variableDeclaration.name.name]);
|
| + errorSite, [variableDeclaration.name.name]);
|
| }
|
| }
|
| }
|
| @@ -1355,23 +1308,18 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| * considered as a valid potentially constant expressions
|
| * @param expression the expression to validate
|
| */
|
| - void _validateInitializerExpression(List<ParameterElement> parameterElements,
|
| - Expression expression) {
|
| + void _validateInitializerExpression(
|
| + List<ParameterElement> parameterElements, Expression expression) {
|
| RecordingErrorListener errorListener = new RecordingErrorListener();
|
| ErrorReporter subErrorReporter =
|
| new ErrorReporter(errorListener, _errorReporter.source);
|
| DartObjectImpl result = expression.accept(
|
| new _ConstantVerifier_validateInitializerExpression(
|
| - _typeProvider,
|
| - subErrorReporter,
|
| - this,
|
| - parameterElements));
|
| - _reportErrors(
|
| - errorListener.errors,
|
| + _typeProvider, subErrorReporter, this, parameterElements));
|
| + _reportErrors(errorListener.errors,
|
| CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER);
|
| if (result != null) {
|
| - _reportErrorIfFromDeferredLibrary(
|
| - expression,
|
| + _reportErrorIfFromDeferredLibrary(expression,
|
| CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER_FROM_DEFERRED_LIBRARY);
|
| }
|
| }
|
| @@ -1383,9 +1331,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| * considered as a valid potentially constant expressions
|
| * @param argumentList the argument list to validate
|
| */
|
| - void
|
| - _validateInitializerInvocationArguments(List<ParameterElement> parameterElements,
|
| - ArgumentList argumentList) {
|
| + void _validateInitializerInvocationArguments(
|
| + List<ParameterElement> parameterElements, ArgumentList argumentList) {
|
| if (argumentList == null) {
|
| return;
|
| }
|
| @@ -1512,16 +1459,14 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| if (lhsResult.value.isTrue && isBarBar) {
|
| // report error on else block: true || !e!
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.DEAD_CODE,
|
| - node.rightOperand);
|
| + HintCode.DEAD_CODE, node.rightOperand);
|
| // only visit the LHS:
|
| _safelyVisit(lhsCondition);
|
| return null;
|
| } else if (lhsResult.value.isFalse && isAmpAmp) {
|
| // report error on if block: false && !e!
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.DEAD_CODE,
|
| - node.rightOperand);
|
| + HintCode.DEAD_CODE, node.rightOperand);
|
| // only visit the LHS:
|
| _safelyVisit(lhsCondition);
|
| return null;
|
| @@ -1575,15 +1520,13 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| if (result.value.isTrue) {
|
| // report error on else block: true ? 1 : !2!
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.DEAD_CODE,
|
| - node.elseExpression);
|
| + HintCode.DEAD_CODE, node.elseExpression);
|
| _safelyVisit(node.thenExpression);
|
| return null;
|
| } else {
|
| // report error on if block: false ? !1! : 2
|
| - _errorReporter.reportErrorForNode(
|
| - HintCode.DEAD_CODE,
|
| - node.thenExpression);
|
| + _errorReporter
|
| + .reportErrorForNode(HintCode.DEAD_CODE, node.thenExpression);
|
| _safelyVisit(node.elseExpression);
|
| return null;
|
| }
|
| @@ -1605,16 +1548,14 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| Statement elseStatement = node.elseStatement;
|
| if (elseStatement != null) {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.DEAD_CODE,
|
| - elseStatement);
|
| + HintCode.DEAD_CODE, elseStatement);
|
| _safelyVisit(node.thenStatement);
|
| return null;
|
| }
|
| } else {
|
| // report error on if block: if (false) {!} else {}
|
| - _errorReporter.reportErrorForNode(
|
| - HintCode.DEAD_CODE,
|
| - node.thenStatement);
|
| + _errorReporter
|
| + .reportErrorForNode(HintCode.DEAD_CODE, node.thenStatement);
|
| _safelyVisit(node.elseStatement);
|
| return null;
|
| }
|
| @@ -1663,9 +1604,7 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| int offset = nextCatchClause.offset;
|
| int length = lastCatchClause.end - offset;
|
| _errorReporter.reportErrorForOffset(
|
| - HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH,
|
| - offset,
|
| - length);
|
| + HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH, offset, length);
|
| return null;
|
| }
|
| }
|
| @@ -1675,10 +1614,10 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| int offset = catchClause.offset;
|
| int length = lastCatchClause.end - offset;
|
| _errorReporter.reportErrorForOffset(
|
| - HintCode.DEAD_CODE_ON_CATCH_SUBTYPE,
|
| - offset,
|
| - length,
|
| - [currentType.displayName, type.displayName]);
|
| + HintCode.DEAD_CODE_ON_CATCH_SUBTYPE, offset, length, [
|
| + currentType.displayName,
|
| + type.displayName
|
| + ]);
|
| return null;
|
| }
|
| }
|
| @@ -1697,9 +1636,7 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| int offset = nextCatchClause.offset;
|
| int length = lastCatchClause.end - offset;
|
| _errorReporter.reportErrorForOffset(
|
| - HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH,
|
| - offset,
|
| - length);
|
| + HintCode.DEAD_CODE_CATCH_FOLLOWING_CATCH, offset, length);
|
| return null;
|
| }
|
| }
|
| @@ -1738,10 +1675,11 @@ class DeadCodeVerifier extends RecursiveAstVisitor<Object> {
|
| for (int i = 0; i < size; i++) {
|
| Statement currentStatement = statements[i];
|
| _safelyVisit(currentStatement);
|
| - bool returnOrBreakingStatement =
|
| - currentStatement is ReturnStatement ||
|
| - (currentStatement is BreakStatement && currentStatement.label == null) ||
|
| - (currentStatement is ContinueStatement && currentStatement.label == null);
|
| + bool returnOrBreakingStatement = currentStatement is ReturnStatement ||
|
| + (currentStatement is BreakStatement &&
|
| + currentStatement.label == null) ||
|
| + (currentStatement is ContinueStatement &&
|
| + currentStatement.label == null);
|
| if (returnOrBreakingStatement && i != size - 1) {
|
| Statement nextStatement = statements[i + 1];
|
| Statement lastStatement = statements[size - 1];
|
| @@ -1977,9 +1915,9 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| String uri = _getStringValue(node.uri);
|
| if (uri != null) {
|
| LibraryElement library = _enclosingUnit.library;
|
| - ExportElement exportElement = _findExport(
|
| - library.exports,
|
| - _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri));
|
| + ExportElement exportElement = _findExport(library.exports,
|
| + _enclosingUnit.context.sourceFactory.resolveUri(
|
| + _enclosingUnit.source, uri));
|
| node.element = exportElement;
|
| }
|
| return super.visitExportDirective(node);
|
| @@ -2083,10 +2021,9 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| String uri = _getStringValue(node.uri);
|
| if (uri != null) {
|
| LibraryElement library = _enclosingUnit.library;
|
| - ImportElement importElement = _findImport(
|
| - library.imports,
|
| - _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri),
|
| - node.prefix);
|
| + ImportElement importElement = _findImport(library.imports,
|
| + _enclosingUnit.context.sourceFactory.resolveUri(
|
| + _enclosingUnit.source, uri), node.prefix);
|
| node.element = importElement;
|
| }
|
| return super.visitImportDirective(node);
|
| @@ -2120,9 +2057,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| }
|
| if (property == null) {
|
| _enclosingExecutable = _findWithNameAndOffset(
|
| - _enclosingClass.methods,
|
| - nameOfMethod,
|
| - methodName.offset);
|
| + _enclosingClass.methods, nameOfMethod, methodName.offset);
|
| methodName.staticElement = _enclosingExecutable;
|
| } else {
|
| PropertyAccessorElement accessor =
|
| @@ -2143,8 +2078,8 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| Object visitPartDirective(PartDirective node) {
|
| String uri = _getStringValue(node.uri);
|
| if (uri != null) {
|
| - Source partSource =
|
| - _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri);
|
| + Source partSource = _enclosingUnit.context.sourceFactory.resolveUri(
|
| + _enclosingUnit.source, uri);
|
| node.element = _findPart(_enclosingUnit.library.parts, partSource);
|
| }
|
| return super.visitPartDirective(node);
|
| @@ -2168,8 +2103,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| } finally {
|
| _enclosingParameter = outerParameter;
|
| }
|
| - } else {
|
| - }
|
| + } else {}
|
| return super.visitSimpleFormalParameter(node);
|
| }
|
|
|
| @@ -2287,8 +2221,8 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| * @param prefix the prefix with which the library was imported
|
| * @return the import element whose library has the given source and prefix
|
| */
|
| - ImportElement _findImport(List<ImportElement> imports, Source source,
|
| - SimpleIdentifier prefix) {
|
| + ImportElement _findImport(
|
| + List<ImportElement> imports, Source source, SimpleIdentifier prefix) {
|
| for (ImportElement element in imports) {
|
| if (element.importedLibrary.source == source) {
|
| PrefixElement prefixElement = element.prefix;
|
| @@ -2315,8 +2249,8 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| * @param partSource the source for the part whose element is to be returned
|
| * @return the element for the part with the given source
|
| */
|
| - CompilationUnitElement _findPart(List<CompilationUnitElement> parts,
|
| - Source partSource) {
|
| + CompilationUnitElement _findPart(
|
| + List<CompilationUnitElement> parts, Source partSource) {
|
| for (CompilationUnitElement part in parts) {
|
| if (part.source == partSource) {
|
| return part;
|
| @@ -2334,8 +2268,8 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| * @param offset the offset of the name of the element to be returned
|
| * @return the element with the given name and offset
|
| */
|
| - Element _findWithNameAndOffset(List<Element> elements, String name,
|
| - int offset) {
|
| + Element _findWithNameAndOffset(
|
| + List<Element> elements, String name, int offset) {
|
| for (Element element in elements) {
|
| if (element.displayName == name && element.nameOffset == offset) {
|
| return element;
|
| @@ -2351,8 +2285,8 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| * @param parameterName the name of the parameter being searched for
|
| * @return the element representing the parameter with that name
|
| */
|
| - ParameterElement _getElementForParameter(FormalParameter node,
|
| - SimpleIdentifier parameterName) {
|
| + ParameterElement _getElementForParameter(
|
| + FormalParameter node, SimpleIdentifier parameterName) {
|
| List<ParameterElement> parameters = null;
|
| if (_enclosingParameter != null) {
|
| parameters = _enclosingParameter.parameters;
|
| @@ -2377,8 +2311,7 @@ class DeclarationResolver extends RecursiveAstVisitor<Object> {
|
| buffer.writeln("---------");
|
| parent = parent.parent;
|
| }
|
| - AnalysisEngine.instance.logger.logError(
|
| - buffer.toString(),
|
| + AnalysisEngine.instance.logger.logError(buffer.toString(),
|
| new CaughtException(new AnalysisException(), null));
|
| }
|
| return element;
|
| @@ -2777,8 +2710,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
| return null;
|
| }
|
| String propertyName = propertyNameNode.name;
|
| - TopLevelVariableElementImpl variable =
|
| - _currentHolder.getTopLevelVariable(propertyName) as TopLevelVariableElementImpl;
|
| + TopLevelVariableElementImpl variable = _currentHolder
|
| + .getTopLevelVariable(propertyName) as TopLevelVariableElementImpl;
|
| if (variable == null) {
|
| variable = new TopLevelVariableElementImpl(node.name.name, -1);
|
| variable.final2 = true;
|
| @@ -3032,14 +2965,12 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
| buffer.write(classNode.name);
|
| buffer.write(" was not set while trying to build the element model.");
|
| AnalysisEngine.instance.logger.logError(
|
| - buffer.toString(),
|
| - new CaughtException(exception, stackTrace));
|
| + buffer.toString(), new CaughtException(exception, stackTrace));
|
| } else {
|
| String message =
|
| "Exception caught in ElementBuilder.visitMethodDeclaration()";
|
| AnalysisEngine.instance.logger.logError(
|
| - message,
|
| - new CaughtException(exception, stackTrace));
|
| + message, new CaughtException(exception, stackTrace));
|
| }
|
| } finally {
|
| if (node.name.staticElement == null) {
|
| @@ -3051,9 +2982,9 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
| buffer.write(" in ");
|
| buffer.write(classNode.name);
|
| buffer.write(" was not set while trying to resolve types.");
|
| - AnalysisEngine.instance.logger.logError(
|
| - buffer.toString(),
|
| - new CaughtException(new AnalysisException(buffer.toString()), null));
|
| + AnalysisEngine.instance.logger.logError(buffer.toString(),
|
| + new CaughtException(
|
| + new AnalysisException(buffer.toString()), null));
|
| }
|
| }
|
| return null;
|
| @@ -3231,8 +3162,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
| * @param interfaceType the interface type for which to create a default constructor
|
| * @return the [ConstructorElement]s array with the single default constructor element
|
| */
|
| - List<ConstructorElement>
|
| - _createDefaultConstructors(InterfaceTypeImpl interfaceType) {
|
| + List<ConstructorElement> _createDefaultConstructors(
|
| + InterfaceTypeImpl interfaceType) {
|
| ConstructorElementImpl constructor =
|
| new ConstructorElementImpl.forNode(null);
|
| constructor.synthetic = true;
|
| @@ -3250,8 +3181,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
| * @param typeParameters the type parameters for which types are to be created
|
| * @return an array of types corresponding to the given parameters
|
| */
|
| - List<DartType>
|
| - _createTypeParameterTypes(List<TypeParameterElement> typeParameters) {
|
| + List<DartType> _createTypeParameterTypes(
|
| + List<TypeParameterElement> typeParameters) {
|
| int typeParameterCount = typeParameters.length;
|
| List<DartType> typeArguments = new List<DartType>(typeParameterCount);
|
| for (int i = 0; i < typeParameterCount; i++) {
|
| @@ -3290,8 +3221,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
| /**
|
| * Sets the visible source range for formal parameter.
|
| */
|
| - void _setParameterVisibleRange(FormalParameter node,
|
| - ParameterElementImpl element) {
|
| + void _setParameterVisibleRange(
|
| + FormalParameter node, ParameterElementImpl element) {
|
| FunctionBody body = _getFunctionBody(node);
|
| if (body != null) {
|
| element.setVisibleRange(body.offset, body.length);
|
| @@ -3690,8 +3621,8 @@ class ElementHolder {
|
| buffer.write(" type parameters");
|
| }
|
| if (buffer.length > 0) {
|
| - AnalysisEngine.instance.logger.logError(
|
| - "Failed to capture elements: $buffer");
|
| + AnalysisEngine.instance.logger
|
| + .logError("Failed to capture elements: $buffer");
|
| }
|
| }
|
| }
|
| @@ -3746,8 +3677,8 @@ class EnclosedScope extends Scope {
|
| }
|
|
|
| @override
|
| - Element internalLookup(Identifier identifier, String name,
|
| - LibraryElement referencingLibrary) {
|
| + Element internalLookup(
|
| + Identifier identifier, String name, LibraryElement referencingLibrary) {
|
| Element element = localLookup(name, referencingLibrary);
|
| if (element != null) {
|
| return element;
|
| @@ -3756,13 +3687,9 @@ class EnclosedScope extends Scope {
|
| if (_hasHiddenName) {
|
| Element hiddenElement = _hiddenElements[name];
|
| if (hiddenElement != null) {
|
| - errorListener.onError(
|
| - new AnalysisError.con2(
|
| - getSource(identifier),
|
| - identifier.offset,
|
| - identifier.length,
|
| - CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION,
|
| - []));
|
| + errorListener.onError(new AnalysisError.con2(getSource(identifier),
|
| + identifier.offset, identifier.length,
|
| + CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION, []));
|
| return hiddenElement;
|
| }
|
| }
|
| @@ -4032,8 +3959,7 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
|
| // TODO(jwren) Do we want to take all constant expressions into account?
|
| // If for(; true; ) (or for(;;)), and the body doesn't return or the body
|
| // doesn't have a break, then return true.
|
| - bool implicitOrExplictTrue =
|
| - conditionExpression == null ||
|
| + bool implicitOrExplictTrue = conditionExpression == null ||
|
| (conditionExpression is BooleanLiteral && conditionExpression.value);
|
| if (implicitOrExplictTrue) {
|
| bool blockReturns = _nodeExits(node.body);
|
| @@ -4311,8 +4237,8 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
|
| return false;
|
| }
|
|
|
| - bool
|
| - _visitVariableDeclarations(NodeList<VariableDeclaration> variableDeclarations) {
|
| + bool _visitVariableDeclarations(
|
| + NodeList<VariableDeclaration> variableDeclarations) {
|
| for (int i = variableDeclarations.length - 1; i >= 0; i--) {
|
| if (variableDeclarations[i].accept(this)) {
|
| return true;
|
| @@ -4329,7 +4255,6 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
|
| }
|
| }
|
|
|
| -
|
| /**
|
| * Instances of the class `FunctionScope` implement the scope defined by a function.
|
| */
|
| @@ -4464,14 +4389,14 @@ class HintGenerator {
|
| }
|
| }
|
| }
|
| - ErrorReporter definingCompilationUnitErrorReporter =
|
| - new ErrorReporter(_errorListener, _compilationUnits[0].element.source);
|
| - _importsVerifier.generateDuplicateImportHints(
|
| - definingCompilationUnitErrorReporter);
|
| - _importsVerifier.generateUnusedImportHints(
|
| - definingCompilationUnitErrorReporter);
|
| - _library.accept(
|
| - new _UnusedElementsVerifier(_errorListener, _usedElementsVisitor.usedElements));
|
| + ErrorReporter definingCompilationUnitErrorReporter = new ErrorReporter(
|
| + _errorListener, _compilationUnits[0].element.source);
|
| + _importsVerifier
|
| + .generateDuplicateImportHints(definingCompilationUnitErrorReporter);
|
| + _importsVerifier
|
| + .generateUnusedImportHints(definingCompilationUnitErrorReporter);
|
| + _library.accept(new _UnusedElementsVerifier(
|
| + _errorListener, _usedElementsVisitor.usedElements));
|
| });
|
| }
|
|
|
| @@ -4621,8 +4546,7 @@ class HtmlTagInfoBuilder implements ht.XmlVisitor {
|
| }
|
|
|
| @override
|
| - visitXmlAttributeNode(ht.XmlAttributeNode node) {
|
| - }
|
| + visitXmlAttributeNode(ht.XmlAttributeNode node) {}
|
|
|
| @override
|
| visitXmlTagNode(ht.XmlTagNode node) {
|
| @@ -4813,16 +4737,13 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| _context.sourceFactory.resolveUri(htmlSource, scriptSourcePath);
|
| script.scriptSource = scriptSource;
|
| if (!_context.exists(scriptSource)) {
|
| - _reportValueError(
|
| - HtmlWarningCode.URI_DOES_NOT_EXIST,
|
| - scriptAttribute,
|
| - [scriptSourcePath]);
|
| + _reportValueError(HtmlWarningCode.URI_DOES_NOT_EXIST,
|
| + scriptAttribute, [scriptSourcePath]);
|
| }
|
| } on URISyntaxException catch (exception) {
|
| - _reportValueError(
|
| - HtmlWarningCode.INVALID_URI,
|
| - scriptAttribute,
|
| - [scriptSourcePath]);
|
| + _reportValueError(HtmlWarningCode.INVALID_URI, scriptAttribute, [
|
| + scriptSourcePath
|
| + ]);
|
| }
|
| }
|
| node.scriptElement = script;
|
| @@ -4917,15 +4838,10 @@ class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
|
| * @param length the number of characters to be highlighted
|
| * @param arguments the arguments used to compose the error message
|
| */
|
| - void _reportErrorForOffset(ErrorCode errorCode, int offset, int length,
|
| - List<Object> arguments) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - _htmlElement.source,
|
| - offset,
|
| - length,
|
| - errorCode,
|
| - arguments));
|
| + void _reportErrorForOffset(
|
| + ErrorCode errorCode, int offset, int length, List<Object> arguments) {
|
| + _errorListener.onError(new AnalysisError.con2(
|
| + _htmlElement.source, offset, length, errorCode, arguments));
|
| }
|
|
|
| /**
|
| @@ -4972,11 +4888,7 @@ class ImplicitConstructorBuilder extends ScopedVisitor {
|
| */
|
| ImplicitConstructorBuilder(Source source, LibraryElement libraryElement,
|
| LibraryScope libraryScope, TypeProvider typeProvider, this._callback)
|
| - : super.con3(
|
| - libraryElement,
|
| - source,
|
| - typeProvider,
|
| - libraryScope,
|
| + : super.con3(libraryElement, source, typeProvider, libraryScope,
|
| libraryScope.errorListener);
|
|
|
| @override
|
| @@ -5004,15 +4916,10 @@ class ImplicitConstructorBuilder extends ScopedVisitor {
|
| constructorFound = true;
|
| }
|
| if (_findForwardedConstructors(
|
| - classElement,
|
| - superclassName,
|
| - superclassType,
|
| - callback) &&
|
| + classElement, superclassName, superclassType, callback) &&
|
| !constructorFound) {
|
| - reportErrorForNode(
|
| - CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS,
|
| - node.withClause,
|
| - [superclassType.element.name]);
|
| + reportErrorForNode(CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS,
|
| + node.withClause, [superclassType.element.name]);
|
| classElement.mixinErrorsReported = true;
|
| }
|
| });
|
| @@ -5041,23 +4948,15 @@ class ImplicitConstructorBuilder extends ScopedVisitor {
|
| new List<ConstructorElement>();
|
| void callback(ConstructorElement explicitConstructor,
|
| List<DartType> parameterTypes, List<DartType> argumentTypes) {
|
| - implicitConstructors.add(
|
| - _createImplicitContructor(
|
| - classElement.type,
|
| - explicitConstructor,
|
| - parameterTypes,
|
| - argumentTypes));
|
| + implicitConstructors.add(_createImplicitContructor(
|
| + classElement.type, explicitConstructor, parameterTypes,
|
| + argumentTypes));
|
| }
|
| if (_findForwardedConstructors(
|
| - classElement,
|
| - superclassName,
|
| - superclassType,
|
| - callback)) {
|
| + classElement, superclassName, superclassType, callback)) {
|
| if (implicitConstructors.isEmpty) {
|
| - reportErrorForNode(
|
| - CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS,
|
| - node,
|
| - [superclassElement.name]);
|
| + reportErrorForNode(CompileTimeErrorCode.MIXIN_HAS_NO_CONSTRUCTORS,
|
| + node, [superclassElement.name]);
|
| } else {
|
| classElement.constructors = implicitConstructors;
|
| }
|
| @@ -5133,9 +5032,9 @@ class ImplicitConstructorBuilder extends ScopedVisitor {
|
| * can't be used as a mixin anyway).
|
| */
|
| bool _findForwardedConstructors(ClassElementImpl classElement,
|
| - TypeName superclassName, InterfaceType superclassType, void
|
| - callback(ConstructorElement explicitConstructor, List<DartType> parameterTypes,
|
| - List<DartType> argumentTypes)) {
|
| + TypeName superclassName, InterfaceType superclassType, void callback(
|
| + ConstructorElement explicitConstructor, List<DartType> parameterTypes,
|
| + List<DartType> argumentTypes)) {
|
| ClassElement superclassElement = superclassType.element;
|
| List<ConstructorElement> constructors = superclassElement.constructors;
|
| int count = constructors.length;
|
| @@ -5164,8 +5063,8 @@ class ImplicitConstructorBuilder extends ScopedVisitor {
|
| * @param parameterTypes the parameter types that must be matched by the type arguments
|
| * @return the argument types that correspond to the parameter types
|
| */
|
| - List<DartType> _getArgumentTypes(TypeArgumentList typeArguments,
|
| - List<DartType> parameterTypes) {
|
| + List<DartType> _getArgumentTypes(
|
| + TypeArgumentList typeArguments, List<DartType> parameterTypes) {
|
| DynamicTypeImpl dynamic = DynamicTypeImpl.instance;
|
| int parameterCount = parameterTypes.length;
|
| List<DartType> types = new List<DartType>(parameterCount);
|
| @@ -5226,13 +5125,8 @@ class ImplicitConstructorComputer {
|
| */
|
| void add(CompilationUnit unit, Source source, LibraryElement libraryElement,
|
| LibraryScope libraryScope) {
|
| - unit.accept(
|
| - new ImplicitConstructorBuilder(
|
| - source,
|
| - libraryElement,
|
| - libraryScope,
|
| - typeProvider,
|
| - _defer));
|
| + unit.accept(new ImplicitConstructorBuilder(
|
| + source, libraryElement, libraryScope, typeProvider, _defer));
|
| }
|
|
|
| /**
|
| @@ -5261,8 +5155,8 @@ class ImplicitConstructorComputer {
|
| * [classElement], until after implicit constructors have been built for
|
| * [superclassElement].
|
| */
|
| - void _defer(ClassElement classElement, ClassElement superclassElement, void
|
| - computation()) {
|
| + void _defer(ClassElement classElement, ClassElement superclassElement,
|
| + void computation()) {
|
| assert(!_computations.containsKey(classElement));
|
| _computations[classElement] = computation;
|
| _dependencies.addEdge(classElement, superclassElement);
|
| @@ -5421,8 +5315,7 @@ class ImportsVerifier extends RecursiveAstVisitor<Object> {
|
| void generateDuplicateImportHints(ErrorReporter errorReporter) {
|
| for (ImportDirective duplicateImport in _duplicateImports) {
|
| errorReporter.reportErrorForNode(
|
| - HintCode.DUPLICATE_IMPORT,
|
| - duplicateImport.uri);
|
| + HintCode.DUPLICATE_IMPORT, duplicateImport.uri);
|
| }
|
| }
|
|
|
| @@ -5445,8 +5338,7 @@ class ImportsVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| }
|
| errorReporter.reportErrorForNode(
|
| - HintCode.UNUSED_IMPORT,
|
| - unusedImport.uri);
|
| + HintCode.UNUSED_IMPORT, unusedImport.uri);
|
| }
|
| }
|
|
|
| @@ -5489,9 +5381,7 @@ class ImportsVerifier extends RecursiveAstVisitor<Object> {
|
| // exports from the libraryElement.
|
| //
|
| _addAdditionalLibrariesForExports(
|
| - libraryElement,
|
| - importDirective,
|
| - new List<LibraryElement>());
|
| + libraryElement, importDirective, new List<LibraryElement>());
|
| }
|
| }
|
| }
|
| @@ -5588,9 +5478,7 @@ class ImportsVerifier extends RecursiveAstVisitor<Object> {
|
| for (LibraryElement exportedLibraryElt in library.exportedLibraries) {
|
| _putIntoLibraryMap(exportedLibraryElt, importDirective);
|
| _addAdditionalLibrariesForExports(
|
| - exportedLibraryElt,
|
| - importDirective,
|
| - exportPath);
|
| + exportedLibraryElt, importDirective, exportPath);
|
| }
|
| }
|
|
|
| @@ -5623,8 +5511,8 @@ class ImportsVerifier extends RecursiveAstVisitor<Object> {
|
| * used to simply add the mapping between the library element an an import directive without
|
| * needing to check to see if a list needs to be created.
|
| */
|
| - void _putIntoLibraryMap(LibraryElement libraryElement,
|
| - ImportDirective importDirective) {
|
| + void _putIntoLibraryMap(
|
| + LibraryElement libraryElement, ImportDirective importDirective) {
|
| List<ImportDirective> importList = _libraryMap[libraryElement];
|
| if (importList == null) {
|
| importList = new List<ImportDirective>();
|
| @@ -5800,18 +5688,16 @@ class InheritanceManager {
|
| * @return the inherited executable element with the member name, or `null` if no such
|
| * member exists
|
| */
|
| - ExecutableElement lookupInheritance(ClassElement classElt,
|
| - String memberName) {
|
| + ExecutableElement lookupInheritance(
|
| + ClassElement classElt, String memberName) {
|
| if (memberName == null || memberName.isEmpty) {
|
| return null;
|
| }
|
| ExecutableElement executable = _computeClassChainLookupMap(
|
| - classElt,
|
| - new HashSet<ClassElement>()).get(memberName);
|
| + classElt, new HashSet<ClassElement>()).get(memberName);
|
| if (executable == null) {
|
| - return _computeInterfaceLookupMap(
|
| - classElt,
|
| - new HashSet<ClassElement>()).get(memberName);
|
| + return _computeInterfaceLookupMap(classElt, new HashSet<ClassElement>())
|
| + .get(memberName);
|
| }
|
| return executable;
|
| }
|
| @@ -5845,17 +5731,15 @@ class InheritanceManager {
|
| * @param memberName the name of the executable element to find and return
|
| * @return the member's function type, or `null` if no such member exists
|
| */
|
| - FunctionType lookupMemberType(InterfaceType interfaceType,
|
| - String memberName) {
|
| + FunctionType lookupMemberType(
|
| + InterfaceType interfaceType, String memberName) {
|
| ExecutableElement iteratorMember =
|
| lookupMember(interfaceType.element, memberName);
|
| if (iteratorMember == null) {
|
| return null;
|
| }
|
| return substituteTypeArgumentsInMemberFromInheritance(
|
| - iteratorMember.type,
|
| - memberName,
|
| - interfaceType);
|
| + iteratorMember.type, memberName, interfaceType);
|
| }
|
|
|
| /**
|
| @@ -5868,8 +5752,8 @@ class InheritanceManager {
|
| * @param memberName the name of the class member to query
|
| * @return a list of overridden methods
|
| */
|
| - List<ExecutableElement> lookupOverrides(ClassElement classElt,
|
| - String memberName) {
|
| + List<ExecutableElement> lookupOverrides(
|
| + ClassElement classElt, String memberName) {
|
| List<ExecutableElement> result = new List<ExecutableElement>();
|
| if (memberName == null || memberName.isEmpty) {
|
| return result;
|
| @@ -5883,8 +5767,8 @@ class InheritanceManager {
|
| if (overriddenElement is MultiplyInheritedExecutableElement) {
|
| MultiplyInheritedExecutableElement multiplyInheritedElement =
|
| overriddenElement;
|
| - for (ExecutableElement element in
|
| - multiplyInheritedElement.inheritedElements) {
|
| + for (ExecutableElement element
|
| + in multiplyInheritedElement.inheritedElements) {
|
| result.add(element);
|
| }
|
| } else {
|
| @@ -5906,9 +5790,9 @@ class InheritanceManager {
|
| * @param definingType the type that is overriding the member
|
| * @return the passed function type with any parameterized types substituted
|
| */
|
| - FunctionType
|
| - substituteTypeArgumentsInMemberFromInheritance(FunctionType baseFunctionType,
|
| - String memberName, InterfaceType definingType) {
|
| + FunctionType substituteTypeArgumentsInMemberFromInheritance(
|
| + FunctionType baseFunctionType, String memberName,
|
| + InterfaceType definingType) {
|
| // if the baseFunctionType is null, or does not have any parameters,
|
| // return it.
|
| if (baseFunctionType == null ||
|
| @@ -5945,8 +5829,8 @@ class InheritanceManager {
|
| * @return a mapping between the set of all string names of the members inherited from the passed
|
| * [ClassElement] superclass hierarchy, and the associated [ExecutableElement]
|
| */
|
| - MemberMap _computeClassChainLookupMap(ClassElement classElt,
|
| - HashSet<ClassElement> visitedClasses) {
|
| + MemberMap _computeClassChainLookupMap(
|
| + ClassElement classElt, HashSet<ClassElement> visitedClasses) {
|
| MemberMap resultMap = _classLookup[classElt];
|
| if (resultMap != null) {
|
| return resultMap;
|
| @@ -5966,8 +5850,8 @@ class InheritanceManager {
|
| if (!visitedClasses.contains(superclassElt)) {
|
| visitedClasses.add(superclassElt);
|
| try {
|
| - resultMap =
|
| - new MemberMap.con2(_computeClassChainLookupMap(superclassElt, visitedClasses));
|
| + resultMap = new MemberMap.con2(
|
| + _computeClassChainLookupMap(superclassElt, visitedClasses));
|
| //
|
| // Substitute the super types down the hierarchy.
|
| //
|
| @@ -5999,8 +5883,8 @@ class InheritanceManager {
|
| if (!visitedClasses.contains(mixinElement)) {
|
| visitedClasses.add(mixinElement);
|
| try {
|
| - MemberMap map =
|
| - new MemberMap.con2(_computeClassChainLookupMap(mixinElement, visitedClasses));
|
| + MemberMap map = new MemberMap.con2(
|
| + _computeClassChainLookupMap(mixinElement, visitedClasses));
|
| //
|
| // Substitute the super types down the hierarchy.
|
| //
|
| @@ -6113,8 +5997,8 @@ class InheritanceManager {
|
| * @return a mapping between the set of all string names of the members inherited from the passed
|
| * [ClassElement] interface hierarchy, and the associated [ExecutableElement]
|
| */
|
| - MemberMap _computeInterfaceLookupMap(ClassElement classElt,
|
| - HashSet<ClassElement> visitedInterfaces) {
|
| + MemberMap _computeInterfaceLookupMap(
|
| + ClassElement classElt, HashSet<ClassElement> visitedInterfaces) {
|
| MemberMap resultMap = _interfaceLookup[classElt];
|
| if (resultMap != null) {
|
| return resultMap;
|
| @@ -6146,8 +6030,8 @@ class InheritanceManager {
|
| * are no classes above this one in the class hierarchy. Otherwise, a list of interface
|
| * lookup maps.
|
| */
|
| - List<MemberMap> _gatherInterfaceLookupMaps(ClassElement classElt,
|
| - HashSet<ClassElement> visitedInterfaces) {
|
| + List<MemberMap> _gatherInterfaceLookupMaps(
|
| + ClassElement classElt, HashSet<ClassElement> visitedInterfaces) {
|
| InterfaceType supertype = classElt.supertype;
|
| ClassElement superclassElement =
|
| supertype != null ? supertype.element : null;
|
| @@ -6264,8 +6148,8 @@ class InheritanceManager {
|
| * @param memberName the name of the member to lookup in the class
|
| * @return the found [ExecutableElement], or `null` if no such member was found
|
| */
|
| - ExecutableElement _lookupMemberInClass(ClassElement classElt,
|
| - String memberName) {
|
| + ExecutableElement _lookupMemberInClass(
|
| + ClassElement classElt, String memberName) {
|
| List<MethodElement> methods = classElt.methods;
|
| for (MethodElement method in methods) {
|
| if (memberName == method.name &&
|
| @@ -6294,8 +6178,8 @@ class InheritanceManager {
|
| * @param type the type that will be recorded into the passed map
|
| * @param doIncludeAbstract `true` if abstract members will be put into the map
|
| */
|
| - void _recordMapWithClassMembers(MemberMap map, InterfaceType type,
|
| - bool doIncludeAbstract) {
|
| + void _recordMapWithClassMembers(
|
| + MemberMap map, InterfaceType type, bool doIncludeAbstract) {
|
| List<MethodElement> methods = type.methods;
|
| for (MethodElement method in methods) {
|
| if (method.isAccessibleIn(_library) &&
|
| @@ -6332,8 +6216,8 @@ class InheritanceManager {
|
| errorSet = new HashSet<AnalysisError>();
|
| _errorsInClassElement[classElt] = errorSet;
|
| }
|
| - errorSet.add(
|
| - new AnalysisError.con2(classElt.source, offset, length, errorCode, arguments));
|
| + errorSet.add(new AnalysisError.con2(
|
| + classElt.source, offset, length, errorCode, arguments));
|
| }
|
|
|
| /**
|
| @@ -6348,8 +6232,8 @@ class InheritanceManager {
|
| * defined in superclasses of [classElt].
|
| * @return the inheritance lookup map for [classElt].
|
| */
|
| - MemberMap _resolveInheritanceLookup(ClassElement classElt, HashMap<String,
|
| - List<ExecutableElement>> unionMap) {
|
| + MemberMap _resolveInheritanceLookup(ClassElement classElt,
|
| + HashMap<String, List<ExecutableElement>> unionMap) {
|
| MemberMap resultMap = new MemberMap();
|
| unionMap.forEach((String key, List<ExecutableElement> list) {
|
| int numOfEltsWithMatchingNames = list.length;
|
| @@ -6404,8 +6288,9 @@ class InheritanceManager {
|
| continue;
|
| }
|
| bool subtypeOfAllTypes = true;
|
| - for (int j =
|
| - 0; j < numOfEltsWithMatchingNames && subtypeOfAllTypes; j++) {
|
| + for (int j = 0;
|
| + j < numOfEltsWithMatchingNames && subtypeOfAllTypes;
|
| + j++) {
|
| if (i != j) {
|
| if (!subtype.isSubtypeOf(executableElementTypes[j])) {
|
| subtypeOfAllTypes = false;
|
| @@ -6458,12 +6343,12 @@ class InheritanceManager {
|
| if (!classHasMember) {
|
| String firstTwoFuntionTypesStr =
|
| "${executableElementTypes[0]}, ${executableElementTypes[1]}";
|
| - _reportError(
|
| - classElt,
|
| - classElt.nameOffset,
|
| + _reportError(classElt, classElt.nameOffset,
|
| classElt.displayName.length,
|
| - StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE,
|
| - [key, firstTwoFuntionTypesStr]);
|
| + StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE, [
|
| + key,
|
| + firstTwoFuntionTypesStr
|
| + ]);
|
| }
|
| } else {
|
| //
|
| @@ -6476,7 +6361,8 @@ class InheritanceManager {
|
| // union_multipleSubtypes_*
|
| //
|
| List<ExecutableElement> elementArrayToMerge =
|
| - new List<ExecutableElement>(subtypesOfAllOtherTypesIndexes.length);
|
| + new List<ExecutableElement>(
|
| + subtypesOfAllOtherTypesIndexes.length);
|
| for (int i = 0; i < elementArrayToMerge.length; i++) {
|
| elementArrayToMerge[i] =
|
| elements[subtypesOfAllOtherTypesIndexes[i]];
|
| @@ -6487,9 +6373,7 @@ class InheritanceManager {
|
| }
|
| }
|
| } else {
|
| - _reportError(
|
| - classElt,
|
| - classElt.nameOffset,
|
| + _reportError(classElt, classElt.nameOffset,
|
| classElt.displayName.length,
|
| StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD,
|
| [key]);
|
| @@ -6506,8 +6390,8 @@ class InheritanceManager {
|
| * @param superType the supertype to substitute into the members of the [MemberMap]
|
| * @param map the MemberMap to perform the substitutions on
|
| */
|
| - void _substituteTypeParametersDownHierarchy(InterfaceType superType,
|
| - MemberMap map) {
|
| + void _substituteTypeParametersDownHierarchy(
|
| + InterfaceType superType, MemberMap map) {
|
| for (int i = 0; i < map.size; i++) {
|
| ExecutableElement executableElement = map.getValue(i);
|
| if (executableElement is MethodMember) {
|
| @@ -6516,8 +6400,7 @@ class InheritanceManager {
|
| map.setValue(i, executableElement);
|
| } else if (executableElement is PropertyAccessorMember) {
|
| executableElement = PropertyAccessorMember.from(
|
| - executableElement as PropertyAccessorMember,
|
| - superType);
|
| + executableElement as PropertyAccessorMember, superType);
|
| map.setValue(i, executableElement);
|
| }
|
| }
|
| @@ -6532,8 +6415,8 @@ class InheritanceManager {
|
| * @param lookupMaps the maps to be unioned together.
|
| * @return the resulting union map.
|
| */
|
| - HashMap<String, List<ExecutableElement>>
|
| - _unionInterfaceLookupMaps(List<MemberMap> lookupMaps) {
|
| + HashMap<String, List<ExecutableElement>> _unionInterfaceLookupMaps(
|
| + List<MemberMap> lookupMaps) {
|
| HashMap<String, List<ExecutableElement>> unionMap =
|
| new HashMap<String, List<ExecutableElement>>();
|
| for (MemberMap lookupMap in lookupMaps) {
|
| @@ -6566,7 +6449,8 @@ class InheritanceManager {
|
| for (ExecutableElement executableElementInList in list) {
|
| bool isMethod2 = executableElementInList is MethodElement;
|
| if (isMethod1 == isMethod2 &&
|
| - executableElementInList.type == newExecutableElementEntry.type) {
|
| + executableElementInList.type ==
|
| + newExecutableElementEntry.type) {
|
| alreadyInList = true;
|
| break;
|
| }
|
| @@ -6595,8 +6479,8 @@ class InheritanceManager {
|
| * <i>s</i> of type <b>dynamic</b> and return type <b>dynamic</b>.
|
| *
|
| */
|
| - static ExecutableElement
|
| - _computeMergedExecutableElement(List<ExecutableElement> elementArrayToMerge) {
|
| + static ExecutableElement _computeMergedExecutableElement(
|
| + List<ExecutableElement> elementArrayToMerge) {
|
| int h = _getNumOfPositionalParameters(elementArrayToMerge[0]);
|
| int r = _getNumOfRequiredParameters(elementArrayToMerge[0]);
|
| Set<String> namedParametersList = new HashSet<String>();
|
| @@ -6612,11 +6496,8 @@ class InheritanceManager {
|
| }
|
| namedParametersList.addAll(_getNamedParameterNames(element));
|
| }
|
| - return _createSyntheticExecutableElement(
|
| - elementArrayToMerge,
|
| - elementArrayToMerge[0].displayName,
|
| - r,
|
| - h - r,
|
| + return _createSyntheticExecutableElement(elementArrayToMerge,
|
| + elementArrayToMerge[0].displayName, r, h - r,
|
| new List.from(namedParametersList));
|
| }
|
|
|
| @@ -6631,13 +6512,13 @@ class InheritanceManager {
|
| * @param namedParameters the list of [String]s that are the named parameters
|
| * @return the created synthetic element
|
| */
|
| - static ExecutableElement
|
| - _createSyntheticExecutableElement(List<ExecutableElement> elementArrayToMerge,
|
| - String name, int numOfRequiredParameters, int numOfPositionalParameters,
|
| + static ExecutableElement _createSyntheticExecutableElement(
|
| + List<ExecutableElement> elementArrayToMerge, String name,
|
| + int numOfRequiredParameters, int numOfPositionalParameters,
|
| List<String> namedParameters) {
|
| DynamicTypeImpl dynamicType = DynamicTypeImpl.instance;
|
| - SimpleIdentifier nameIdentifier =
|
| - new SimpleIdentifier(new sc.StringToken(sc.TokenType.IDENTIFIER, name, 0));
|
| + SimpleIdentifier nameIdentifier = new SimpleIdentifier(
|
| + new sc.StringToken(sc.TokenType.IDENTIFIER, name, 0));
|
| ExecutableElementImpl executable;
|
| if (elementArrayToMerge[0] is MethodElement) {
|
| MultiplyInheritedMethodElementImpl unionedMethod =
|
| @@ -6654,8 +6535,7 @@ class InheritanceManager {
|
| unionedPropertyAccessor.inheritedElements = elementArrayToMerge;
|
| executable = unionedPropertyAccessor;
|
| }
|
| - int numOfParameters =
|
| - numOfRequiredParameters +
|
| + int numOfParameters = numOfRequiredParameters +
|
| numOfPositionalParameters +
|
| namedParameters.length;
|
| List<ParameterElement> parameters =
|
| @@ -6690,8 +6570,8 @@ class InheritanceManager {
|
| /**
|
| * Given some [ExecutableElement], return the list of named parameters.
|
| */
|
| - static List<String>
|
| - _getNamedParameterNames(ExecutableElement executableElement) {
|
| + static List<String> _getNamedParameterNames(
|
| + ExecutableElement executableElement) {
|
| List<String> namedParameterNames = new List<String>();
|
| List<ParameterElement> parameters = executableElement.parameters;
|
| for (int i = 0; i < parameters.length; i++) {
|
| @@ -6706,8 +6586,8 @@ class InheritanceManager {
|
| /**
|
| * Given some [ExecutableElement] return the number of parameters of the specified kind.
|
| */
|
| - static int _getNumOfParameters(ExecutableElement executableElement,
|
| - ParameterKind parameterKind) {
|
| + static int _getNumOfParameters(
|
| + ExecutableElement executableElement, ParameterKind parameterKind) {
|
| int parameterCount = 0;
|
| List<ParameterElement> parameters = executableElement.parameters;
|
| for (int i = 0; i < parameters.length; i++) {
|
| @@ -6724,8 +6604,8 @@ class InheritanceManager {
|
| *
|
| * Note: by positional we mean [ParameterKind.REQUIRED] or [ParameterKind.POSITIONAL].
|
| */
|
| - static int
|
| - _getNumOfPositionalParameters(ExecutableElement executableElement) =>
|
| + static int _getNumOfPositionalParameters(
|
| + ExecutableElement executableElement) =>
|
| _getNumOfParameters(executableElement, ParameterKind.REQUIRED) +
|
| _getNumOfParameters(executableElement, ParameterKind.POSITIONAL);
|
|
|
| @@ -6770,10 +6650,11 @@ class INIT_STATE extends Enum<INIT_STATE> {
|
| const INIT_STATE('INIT_IN_INITIALIZERS', 3);
|
|
|
| static const List<INIT_STATE> values = const [
|
| - NOT_INIT,
|
| - INIT_IN_DECLARATION,
|
| - INIT_IN_FIELD_FORMAL,
|
| - INIT_IN_INITIALIZERS];
|
| + NOT_INIT,
|
| + INIT_IN_DECLARATION,
|
| + INIT_IN_FIELD_FORMAL,
|
| + INIT_IN_INITIALIZERS
|
| + ];
|
|
|
| const INIT_STATE(String name, int ordinal) : super(name, ordinal);
|
| }
|
| @@ -7015,8 +6896,8 @@ class Library {
|
| LibraryElementImpl get libraryElement {
|
| if (_libraryElement == null) {
|
| try {
|
| - _libraryElement =
|
| - _analysisContext.computeLibraryElement(librarySource) as LibraryElementImpl;
|
| + _libraryElement = _analysisContext
|
| + .computeLibraryElement(librarySource) as LibraryElementImpl;
|
| } on AnalysisException catch (exception, stackTrace) {
|
| AnalysisEngine.instance.logger.logError(
|
| "Could not compute library element for ${librarySource.fullName}",
|
| @@ -7076,12 +6957,9 @@ class Library {
|
| Source getSource(UriBasedDirective directive) {
|
| StringLiteral uriLiteral = directive.uri;
|
| if (uriLiteral is StringInterpolation) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - librarySource,
|
| - uriLiteral.offset,
|
| - uriLiteral.length,
|
| - CompileTimeErrorCode.URI_WITH_INTERPOLATION));
|
| + _errorListener.onError(new AnalysisError.con2(librarySource,
|
| + uriLiteral.offset, uriLiteral.length,
|
| + CompileTimeErrorCode.URI_WITH_INTERPOLATION));
|
| return null;
|
| }
|
| String uriContent = uriLiteral.stringValue.trim();
|
| @@ -7097,23 +6975,15 @@ class Library {
|
| Source source =
|
| _analysisContext.sourceFactory.resolveUri(librarySource, uriContent);
|
| if (!_analysisContext.exists(source)) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - librarySource,
|
| - uriLiteral.offset,
|
| - uriLiteral.length,
|
| - CompileTimeErrorCode.URI_DOES_NOT_EXIST,
|
| - [uriContent]));
|
| + _errorListener.onError(new AnalysisError.con2(librarySource,
|
| + uriLiteral.offset, uriLiteral.length,
|
| + CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent]));
|
| }
|
| return source;
|
| } on URISyntaxException catch (exception) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - librarySource,
|
| - uriLiteral.offset,
|
| - uriLiteral.length,
|
| - CompileTimeErrorCode.INVALID_URI,
|
| - [uriContent]));
|
| + _errorListener.onError(new AnalysisError.con2(librarySource,
|
| + uriLiteral.offset, uriLiteral.length,
|
| + CompileTimeErrorCode.INVALID_URI, [uriContent]));
|
| }
|
| return null;
|
| }
|
| @@ -7217,26 +7087,21 @@ class LibraryElementBuilder {
|
| String partLibraryName =
|
| _getPartLibraryName(partSource, partUnit, directivesToResolve);
|
| if (partLibraryName == null) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - librarySource,
|
| - partUri.offset,
|
| - partUri.length,
|
| - CompileTimeErrorCode.PART_OF_NON_PART,
|
| - [partUri.toSource()]));
|
| + _errorListener.onError(new AnalysisError.con2(librarySource,
|
| + partUri.offset, partUri.length,
|
| + CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSource()]));
|
| } else if (libraryNameNode == null) {
|
| // TODO(brianwilkerson) Collect the names declared by the part.
|
| // If they are all the same then we can use that name as the
|
| // inferred name of the library and present it in a quick-fix.
|
| // partLibraryNames.add(partLibraryName);
|
| } else if (libraryNameNode.name != partLibraryName) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - librarySource,
|
| - partUri.offset,
|
| - partUri.length,
|
| - StaticWarningCode.PART_OF_DIFFERENT_LIBRARY,
|
| - [libraryNameNode.name, partLibraryName]));
|
| + _errorListener.onError(new AnalysisError.con2(librarySource,
|
| + partUri.offset, partUri.length,
|
| + StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [
|
| + libraryNameNode.name,
|
| + partLibraryName
|
| + ]));
|
| }
|
| if (entryPoint == null) {
|
| entryPoint = _findEntryPoint(part);
|
| @@ -7247,17 +7112,14 @@ class LibraryElementBuilder {
|
| }
|
| }
|
| if (hasPartDirective && libraryNameNode == null) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con1(
|
| - librarySource,
|
| - ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART));
|
| + _errorListener.onError(new AnalysisError.con1(librarySource,
|
| + ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART));
|
| }
|
| //
|
| // Create and populate the library element.
|
| //
|
| LibraryElementImpl libraryElement = new LibraryElementImpl.forNode(
|
| - _analysisContext.getContextFor(librarySource),
|
| - libraryNameNode);
|
| + _analysisContext.getContextFor(librarySource), libraryNameNode);
|
| libraryElement.definingCompilationUnit = definingCompilationUnitElement;
|
| if (entryPoint != null) {
|
| libraryElement.entryPoint = entryPoint;
|
| @@ -7328,26 +7190,21 @@ class LibraryElementBuilder {
|
| String partLibraryName =
|
| _getPartLibraryName(partSource, partUnit, directivesToResolve);
|
| if (partLibraryName == null) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - librarySource,
|
| - partUri.offset,
|
| - partUri.length,
|
| - CompileTimeErrorCode.PART_OF_NON_PART,
|
| - [partUri.toSource()]));
|
| + _errorListener.onError(new AnalysisError.con2(librarySource,
|
| + partUri.offset, partUri.length,
|
| + CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSource()]));
|
| } else if (libraryNameNode == null) {
|
| // TODO(brianwilkerson) Collect the names declared by the part.
|
| // If they are all the same then we can use that name as the
|
| // inferred name of the library and present it in a quick-fix.
|
| // partLibraryNames.add(partLibraryName);
|
| } else if (libraryNameNode.name != partLibraryName) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - librarySource,
|
| - partUri.offset,
|
| - partUri.length,
|
| - StaticWarningCode.PART_OF_DIFFERENT_LIBRARY,
|
| - [libraryNameNode.name, partLibraryName]));
|
| + _errorListener.onError(new AnalysisError.con2(librarySource,
|
| + partUri.offset, partUri.length,
|
| + StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [
|
| + libraryNameNode.name,
|
| + partLibraryName
|
| + ]));
|
| }
|
| if (entryPoint == null) {
|
| entryPoint = _findEntryPoint(part);
|
| @@ -7359,17 +7216,14 @@ class LibraryElementBuilder {
|
| }
|
| }
|
| if (hasPartDirective && libraryNameNode == null) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con1(
|
| - librarySource,
|
| - ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART));
|
| + _errorListener.onError(new AnalysisError.con1(librarySource,
|
| + ResolverErrorCode.MISSING_LIBRARY_DIRECTIVE_WITH_PART));
|
| }
|
| //
|
| // Create and populate the library element.
|
| //
|
| LibraryElementImpl libraryElement = new LibraryElementImpl.forNode(
|
| - _analysisContext.getContextFor(librarySource),
|
| - libraryNameNode);
|
| + _analysisContext.getContextFor(librarySource), libraryNameNode);
|
| libraryElement.definingCompilationUnit = definingCompilationUnitElement;
|
| if (entryPoint != null) {
|
| libraryElement.entryPoint = entryPoint;
|
| @@ -7524,8 +7378,8 @@ class LibraryImportScope extends Scope {
|
| }
|
|
|
| @override
|
| - Element internalLookup(Identifier identifier, String name,
|
| - LibraryElement referencingLibrary) {
|
| + Element internalLookup(
|
| + Identifier identifier, String name, LibraryElement referencingLibrary) {
|
| Element foundElement = localLookup(name, referencingLibrary);
|
| if (foundElement != null) {
|
| return foundElement;
|
| @@ -7538,17 +7392,13 @@ class LibraryImportScope extends Scope {
|
| foundElement = element;
|
| } else if (!identical(foundElement, element)) {
|
| foundElement = MultiplyDefinedElementImpl.fromElements(
|
| - _definingLibrary.context,
|
| - foundElement,
|
| - element);
|
| + _definingLibrary.context, foundElement, element);
|
| }
|
| }
|
| }
|
| if (foundElement is MultiplyDefinedElementImpl) {
|
| foundElement = _removeSdkElements(
|
| - identifier,
|
| - name,
|
| - foundElement as MultiplyDefinedElementImpl);
|
| + identifier, name, foundElement as MultiplyDefinedElementImpl);
|
| }
|
| if (foundElement is MultiplyDefinedElementImpl) {
|
| String foundEltName = foundElement.displayName;
|
| @@ -7560,13 +7410,12 @@ class LibraryImportScope extends Scope {
|
| libraryNames[i] = _getLibraryName(conflictingMembers[i]);
|
| }
|
| libraryNames.sort();
|
| - errorListener.onError(
|
| - new AnalysisError.con2(
|
| - getSource(identifier),
|
| - identifier.offset,
|
| - identifier.length,
|
| - StaticWarningCode.AMBIGUOUS_IMPORT,
|
| - [foundEltName, StringUtilities.printListOfQuotedNames(libraryNames)]));
|
| + errorListener.onError(new AnalysisError.con2(getSource(identifier),
|
| + identifier.offset, identifier.length,
|
| + StaticWarningCode.AMBIGUOUS_IMPORT, [
|
| + foundEltName,
|
| + StringUtilities.printListOfQuotedNames(libraryNames)
|
| + ]));
|
| return foundElement;
|
| }
|
| if (foundElement != null) {
|
| @@ -7618,11 +7467,11 @@ class LibraryImportScope extends Scope {
|
| for (int i = 0; i < count; i++) {
|
| LibraryElement importedLibrary = imports[i].importedLibrary;
|
| if (importedLibrary != null) {
|
| - for (LibraryElement exportedLibrary in
|
| - importedLibrary.exportedLibraries) {
|
| + for (LibraryElement exportedLibrary
|
| + in importedLibrary.exportedLibraries) {
|
| if (identical(exportedLibrary, library)) {
|
| - indirectSources.add(
|
| - importedLibrary.definingCompilationUnit.displayName);
|
| + indirectSources
|
| + .add(importedLibrary.definingCompilationUnit.displayName);
|
| }
|
| }
|
| }
|
| @@ -7669,13 +7518,13 @@ class LibraryImportScope extends Scope {
|
| if (sdkElement != null && to > 0) {
|
| String sdkLibName = _getLibraryName(sdkElement);
|
| String otherLibName = _getLibraryName(conflictingMembers[0]);
|
| - errorListener.onError(
|
| - new AnalysisError.con2(
|
| - getSource(identifier),
|
| - identifier.offset,
|
| - identifier.length,
|
| - StaticWarningCode.CONFLICTING_DART_IMPORT,
|
| - [name, sdkLibName, otherLibName]));
|
| + errorListener.onError(new AnalysisError.con2(getSource(identifier),
|
| + identifier.offset, identifier.length,
|
| + StaticWarningCode.CONFLICTING_DART_IMPORT, [
|
| + name,
|
| + sdkLibName,
|
| + otherLibName
|
| + ]));
|
| }
|
| if (to == length) {
|
| // None of the members were removed
|
| @@ -7685,8 +7534,8 @@ class LibraryImportScope extends Scope {
|
| return conflictingMembers[0];
|
| } else if (to == 0) {
|
| // All members were removed
|
| - AnalysisEngine.instance.logger.logInformation(
|
| - "Multiply defined SDK element: $foundElement");
|
| + AnalysisEngine.instance.logger
|
| + .logInformation("Multiply defined SDK element: $foundElement");
|
| return foundElement;
|
| }
|
| List<Element> remaining = new List<Element>(to);
|
| @@ -7800,8 +7649,8 @@ class LibraryResolver {
|
| * @return the element representing the resolved library
|
| * @throws AnalysisException if the library could not be resolved for some reason
|
| */
|
| - LibraryElement resolveEmbeddedLibrary(Source librarySource,
|
| - CompilationUnit unit, bool fullAnalysis) {
|
| + LibraryElement resolveEmbeddedLibrary(
|
| + Source librarySource, CompilationUnit unit, bool fullAnalysis) {
|
| //
|
| // Create the objects representing the library being resolved and the core
|
| // library.
|
| @@ -7814,8 +7663,7 @@ class LibraryResolver {
|
| _coreLibrary = createLibrary(_coreLibrarySource);
|
| if (_coreLibrary == null) {
|
| LibraryResolver2.missingCoreLibrary(
|
| - analysisContext,
|
| - _coreLibrarySource);
|
| + analysisContext, _coreLibrarySource);
|
| }
|
| }
|
| _asyncLibrary = _libraryMap[_asyncLibrarySource];
|
| @@ -7825,8 +7673,7 @@ class LibraryResolver {
|
| _asyncLibrary = createLibrary(_asyncLibrarySource);
|
| if (_asyncLibrary == null) {
|
| LibraryResolver2.missingAsyncLibrary(
|
| - analysisContext,
|
| - _asyncLibrarySource);
|
| + analysisContext, _asyncLibrarySource);
|
| }
|
| }
|
| //
|
| @@ -7998,9 +7845,7 @@ class LibraryResolver {
|
| if (dependentLibraries != null) {
|
| for (Library dependentLibrary in dependentLibraries) {
|
| _addLibrariesInCycle(
|
| - dependentLibrary,
|
| - librariesInCycle,
|
| - dependencyMap);
|
| + dependentLibrary, librariesInCycle, dependencyMap);
|
| }
|
| }
|
| }
|
| @@ -8015,8 +7860,9 @@ class LibraryResolver {
|
| * @param visitedLibraries the libraries that have already been visited, used to prevent infinite
|
| * recursion
|
| */
|
| - void _addToDependencyMap(Library library, HashMap<Library,
|
| - List<Library>> dependencyMap, Set<Library> visitedLibraries) {
|
| + void _addToDependencyMap(Library library,
|
| + HashMap<Library, List<Library>> dependencyMap,
|
| + Set<Library> visitedLibraries) {
|
| if (visitedLibraries.add(library)) {
|
| bool asyncFound = false;
|
| for (Library referencedLibrary in library.importsAndExports) {
|
| @@ -8116,16 +7962,12 @@ class LibraryResolver {
|
| imports.add(importElement);
|
| if (analysisContext.computeKindOf(importedSource) !=
|
| SourceKind.LIBRARY) {
|
| - ErrorCode errorCode = (importElement.isDeferred ?
|
| - StaticWarningCode.IMPORT_OF_NON_LIBRARY :
|
| - CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - library.librarySource,
|
| - uriLiteral.offset,
|
| - uriLiteral.length,
|
| - errorCode,
|
| - [uriLiteral.toSource()]));
|
| + ErrorCode errorCode = (importElement.isDeferred
|
| + ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
|
| + : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
|
| + _errorListener.onError(new AnalysisError.con2(
|
| + library.librarySource, uriLiteral.offset, uriLiteral.length,
|
| + errorCode, [uriLiteral.toSource()]));
|
| }
|
| }
|
| }
|
| @@ -8152,13 +7994,11 @@ class LibraryResolver {
|
| exports.add(exportElement);
|
| if (analysisContext.computeKindOf(exportedSource) !=
|
| SourceKind.LIBRARY) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - library.librarySource,
|
| - uriLiteral.offset,
|
| - uriLiteral.length,
|
| - CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
|
| - [uriLiteral.toSource()]));
|
| + _errorListener.onError(new AnalysisError.con2(
|
| + library.librarySource, uriLiteral.offset, uriLiteral.length,
|
| + CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY, [
|
| + uriLiteral.toSource()
|
| + ]));
|
| }
|
| }
|
| }
|
| @@ -8176,8 +8016,8 @@ class LibraryResolver {
|
| libraryElement.imports = imports;
|
| libraryElement.exports = exports;
|
| if (libraryElement.entryPoint == null) {
|
| - Namespace namespace =
|
| - new NamespaceBuilder().createExportNamespaceForLibrary(libraryElement);
|
| + Namespace namespace = new NamespaceBuilder()
|
| + .createExportNamespaceForLibrary(libraryElement);
|
| Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
|
| if (element is FunctionElement) {
|
| libraryElement.entryPoint = element;
|
| @@ -8230,10 +8070,7 @@ class LibraryResolver {
|
| new ImplicitConstructorComputer(_typeProvider);
|
| for (Library library in _librariesInCycles) {
|
| for (Source source in library.compilationUnitSources) {
|
| - computer.add(
|
| - library.getAST(source),
|
| - source,
|
| - library.libraryElement,
|
| + computer.add(library.getAST(source), source, library.libraryElement,
|
| library.libraryScope);
|
| }
|
| }
|
| @@ -8265,8 +8102,8 @@ class LibraryResolver {
|
| // TODO(brianwilkerson) We need to sort the type aliases such that all
|
| // aliases referenced by an alias T are resolved before we resolve T.
|
| for (LibraryResolver_TypeAliasInfo info in typeAliases) {
|
| - TypeResolverVisitor visitor =
|
| - new TypeResolverVisitor.con1(info._library, info._source, _typeProvider);
|
| + TypeResolverVisitor visitor = new TypeResolverVisitor.con1(
|
| + info._library, info._source, _typeProvider);
|
| info._typeAlias.accept(visitor);
|
| }
|
| });
|
| @@ -8284,9 +8121,9 @@ class LibraryResolver {
|
| for (Source source in library.compilationUnitSources) {
|
| TypeResolverVisitorFactory typeResolverVisitorFactory =
|
| analysisContext.typeResolverVisitorFactory;
|
| - TypeResolverVisitor visitor = (typeResolverVisitorFactory == null) ?
|
| - new TypeResolverVisitor.con1(library, source, _typeProvider) :
|
| - typeResolverVisitorFactory(library, source, _typeProvider);
|
| + TypeResolverVisitor visitor = (typeResolverVisitorFactory == null)
|
| + ? new TypeResolverVisitor.con1(library, source, _typeProvider)
|
| + : typeResolverVisitorFactory(library, source, _typeProvider);
|
| library.getAST(source).accept(visitor);
|
| }
|
| }
|
| @@ -8318,8 +8155,8 @@ class LibraryResolver {
|
| * @param library the library to be processed to find libraries that have not yet been traversed
|
| * @throws AnalysisException if some portion of the library graph could not be traversed
|
| */
|
| - void _computeEmbeddedLibraryDependencies(Library library,
|
| - CompilationUnit unit) {
|
| + void _computeEmbeddedLibraryDependencies(
|
| + Library library, CompilationUnit unit) {
|
| Source librarySource = library.librarySource;
|
| HashSet<Source> exportedSources = new HashSet<Source>();
|
| HashSet<Source> importedSources = new HashSet<Source>();
|
| @@ -8336,10 +8173,8 @@ class LibraryResolver {
|
| }
|
| }
|
| }
|
| - _computeLibraryDependenciesFromDirectives(
|
| - library,
|
| - new List.from(importedSources),
|
| - new List.from(exportedSources));
|
| + _computeLibraryDependenciesFromDirectives(library,
|
| + new List.from(importedSources), new List.from(exportedSources));
|
| }
|
|
|
| /**
|
| @@ -8367,8 +8202,7 @@ class LibraryResolver {
|
| */
|
| void _computeLibraryDependencies(Library library) {
|
| Source librarySource = library.librarySource;
|
| - _computeLibraryDependenciesFromDirectives(
|
| - library,
|
| + _computeLibraryDependenciesFromDirectives(library,
|
| analysisContext.computeImportedLibraries(librarySource),
|
| analysisContext.computeExportedLibraries(librarySource));
|
| }
|
| @@ -8496,8 +8330,8 @@ class LibraryResolver {
|
| */
|
| void _performConstantEvaluation() {
|
| PerformanceStatistics.resolve.makeCurrentWhile(() {
|
| - ConstantValueComputer computer =
|
| - new ConstantValueComputer(_typeProvider, analysisContext.declaredVariables);
|
| + ConstantValueComputer computer = new ConstantValueComputer(
|
| + _typeProvider, analysisContext.declaredVariables);
|
| for (Library library in _librariesInCycles) {
|
| for (Source source in library.compilationUnitSources) {
|
| try {
|
| @@ -8521,13 +8355,13 @@ class LibraryResolver {
|
| CompilationUnit unit = library.getAST(source);
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(_errorListener, source);
|
| - ConstantVerifier constantVerifier =
|
| - new ConstantVerifier(errorReporter, library.libraryElement, _typeProvider);
|
| + ConstantVerifier constantVerifier = new ConstantVerifier(
|
| + errorReporter, library.libraryElement, _typeProvider);
|
| unit.accept(constantVerifier);
|
| } on AnalysisException catch (exception, stackTrace) {
|
| AnalysisEngine.instance.logger.logError(
|
| "Internal Error: Could not access AST for ${source.fullName} "
|
| - "during constant verification",
|
| + "during constant verification",
|
| new CaughtException(exception, stackTrace));
|
| }
|
| }
|
| @@ -8562,9 +8396,9 @@ class LibraryResolver {
|
| new VariableResolverVisitor.con1(library, source, _typeProvider));
|
| ResolverVisitorFactory visitorFactory =
|
| analysisContext.resolverVisitorFactory;
|
| - ResolverVisitor visitor = visitorFactory != null ?
|
| - visitorFactory(library, source, _typeProvider) :
|
| - new ResolverVisitor.con1(library, source, _typeProvider);
|
| + ResolverVisitor visitor = visitorFactory != null
|
| + ? visitorFactory(library, source, _typeProvider)
|
| + : new ResolverVisitor.con1(library, source, _typeProvider);
|
| ast.accept(visitor);
|
| }
|
| });
|
| @@ -8685,8 +8519,8 @@ class LibraryResolver2 {
|
| * @return the element representing the resolved library
|
| * @throws AnalysisException if the library could not be resolved for some reason
|
| */
|
| - LibraryElement resolveLibrary(Source librarySource,
|
| - List<ResolvableLibrary> librariesInCycle) {
|
| + LibraryElement resolveLibrary(
|
| + Source librarySource, List<ResolvableLibrary> librariesInCycle) {
|
| //
|
| // Build the map of libraries that are known.
|
| //
|
| @@ -8831,16 +8665,12 @@ class LibraryResolver2 {
|
| imports.add(importElement);
|
| if (analysisContext.computeKindOf(importedSource) !=
|
| SourceKind.LIBRARY) {
|
| - ErrorCode errorCode = (importElement.isDeferred ?
|
| - StaticWarningCode.IMPORT_OF_NON_LIBRARY :
|
| - CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - library.librarySource,
|
| - uriLiteral.offset,
|
| - uriLiteral.length,
|
| - errorCode,
|
| - [uriLiteral.toSource()]));
|
| + ErrorCode errorCode = (importElement.isDeferred
|
| + ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
|
| + : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
|
| + _errorListener.onError(new AnalysisError.con2(
|
| + library.librarySource, uriLiteral.offset, uriLiteral.length,
|
| + errorCode, [uriLiteral.toSource()]));
|
| }
|
| }
|
| }
|
| @@ -8870,13 +8700,11 @@ class LibraryResolver2 {
|
| exports.add(exportElement);
|
| if (analysisContext.computeKindOf(exportedSource) !=
|
| SourceKind.LIBRARY) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - library.librarySource,
|
| - uriLiteral.offset,
|
| - uriLiteral.length,
|
| - CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
|
| - [uriLiteral.toSource()]));
|
| + _errorListener.onError(new AnalysisError.con2(
|
| + library.librarySource, uriLiteral.offset, uriLiteral.length,
|
| + CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY, [
|
| + uriLiteral.toSource()
|
| + ]));
|
| }
|
| }
|
| }
|
| @@ -8894,8 +8722,8 @@ class LibraryResolver2 {
|
| libraryElement.imports = imports;
|
| libraryElement.exports = exports;
|
| if (libraryElement.entryPoint == null) {
|
| - Namespace namespace =
|
| - new NamespaceBuilder().createExportNamespaceForLibrary(libraryElement);
|
| + Namespace namespace = new NamespaceBuilder()
|
| + .createExportNamespaceForLibrary(libraryElement);
|
| Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
|
| if (element is FunctionElement) {
|
| libraryElement.entryPoint = element;
|
| @@ -8946,15 +8774,12 @@ class LibraryResolver2 {
|
| ImplicitConstructorComputer computer =
|
| new ImplicitConstructorComputer(_typeProvider);
|
| for (ResolvableLibrary library in _librariesInCycle) {
|
| - for (ResolvableCompilationUnit unit in
|
| - library.resolvableCompilationUnits) {
|
| + for (ResolvableCompilationUnit unit
|
| + in library.resolvableCompilationUnits) {
|
| Source source = unit.source;
|
| CompilationUnit ast = unit.compilationUnit;
|
| - computer.add(
|
| - ast,
|
| - source,
|
| - library.libraryElement,
|
| - library.libraryScope);
|
| + computer
|
| + .add(ast, source, library.libraryElement, library.libraryScope);
|
| }
|
| }
|
| computer.compute();
|
| @@ -8991,13 +8816,13 @@ class LibraryResolver2 {
|
| List<LibraryResolver2_TypeAliasInfo> typeAliases =
|
| new List<LibraryResolver2_TypeAliasInfo>();
|
| for (ResolvableLibrary library in _librariesInCycle) {
|
| - for (ResolvableCompilationUnit unit in
|
| - library.resolvableCompilationUnits) {
|
| - for (CompilationUnitMember member in
|
| - unit.compilationUnit.declarations) {
|
| + for (ResolvableCompilationUnit unit
|
| + in library.resolvableCompilationUnits) {
|
| + for (CompilationUnitMember member
|
| + in unit.compilationUnit.declarations) {
|
| if (member is FunctionTypeAlias) {
|
| - typeAliases.add(
|
| - new LibraryResolver2_TypeAliasInfo(library, unit.source, member));
|
| + typeAliases.add(new LibraryResolver2_TypeAliasInfo(
|
| + library, unit.source, member));
|
| }
|
| }
|
| }
|
| @@ -9005,8 +8830,8 @@ class LibraryResolver2 {
|
| // TODO(brianwilkerson) We need to sort the type aliases such that all
|
| // aliases referenced by an alias T are resolved before we resolve T.
|
| for (LibraryResolver2_TypeAliasInfo info in typeAliases) {
|
| - TypeResolverVisitor visitor =
|
| - new TypeResolverVisitor.con4(info._library, info._source, _typeProvider);
|
| + TypeResolverVisitor visitor = new TypeResolverVisitor.con4(
|
| + info._library, info._source, _typeProvider);
|
| info._typeAlias.accept(visitor);
|
| }
|
| });
|
| @@ -9021,8 +8846,8 @@ class LibraryResolver2 {
|
| void _buildTypeHierarchies() {
|
| PerformanceStatistics.resolve.makeCurrentWhile(() {
|
| for (ResolvableLibrary library in _librariesInCycle) {
|
| - for (ResolvableCompilationUnit unit in
|
| - library.resolvableCompilationUnits) {
|
| + for (ResolvableCompilationUnit unit
|
| + in library.resolvableCompilationUnits) {
|
| Source source = unit.source;
|
| CompilationUnit ast = unit.compilationUnit;
|
| TypeResolverVisitor visitor =
|
| @@ -9053,11 +8878,11 @@ class LibraryResolver2 {
|
| */
|
| void _performConstantEvaluation() {
|
| PerformanceStatistics.resolve.makeCurrentWhile(() {
|
| - ConstantValueComputer computer =
|
| - new ConstantValueComputer(_typeProvider, analysisContext.declaredVariables);
|
| + ConstantValueComputer computer = new ConstantValueComputer(
|
| + _typeProvider, analysisContext.declaredVariables);
|
| for (ResolvableLibrary library in _librariesInCycle) {
|
| - for (ResolvableCompilationUnit unit in
|
| - library.resolvableCompilationUnits) {
|
| + for (ResolvableCompilationUnit unit
|
| + in library.resolvableCompilationUnits) {
|
| CompilationUnit ast = unit.compilationUnit;
|
| if (ast != null) {
|
| computer.add(ast);
|
| @@ -9068,13 +8893,13 @@ class LibraryResolver2 {
|
| // As a temporary workaround for issue 21572, run ConstantVerifier now.
|
| // TODO(paulberry): remove this workaround once issue 21572 is fixed.
|
| for (ResolvableLibrary library in _librariesInCycle) {
|
| - for (ResolvableCompilationUnit unit in
|
| - library.resolvableCompilationUnits) {
|
| + for (ResolvableCompilationUnit unit
|
| + in library.resolvableCompilationUnits) {
|
| CompilationUnit ast = unit.compilationUnit;
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(_errorListener, unit.source);
|
| - ConstantVerifier constantVerifier =
|
| - new ConstantVerifier(errorReporter, library.libraryElement, _typeProvider);
|
| + ConstantVerifier constantVerifier = new ConstantVerifier(
|
| + errorReporter, library.libraryElement, _typeProvider);
|
| ast.accept(constantVerifier);
|
| }
|
| }
|
| @@ -9102,8 +8927,8 @@ class LibraryResolver2 {
|
| */
|
| void _resolveReferencesAndTypesInLibrary(ResolvableLibrary library) {
|
| PerformanceStatistics.resolve.makeCurrentWhile(() {
|
| - for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits)
|
| - {
|
| + for (ResolvableCompilationUnit unit
|
| + in library.resolvableCompilationUnits) {
|
| Source source = unit.source;
|
| CompilationUnit ast = unit.compilationUnit;
|
| ast.accept(
|
| @@ -9120,8 +8945,8 @@ class LibraryResolver2 {
|
| * [analysisContext] and throw an exception. [asyncLibrarySource] is the source
|
| * representing the async library.
|
| */
|
| - static void missingAsyncLibrary(AnalysisContext analysisContext,
|
| - Source asyncLibrarySource) {
|
| + static void missingAsyncLibrary(
|
| + AnalysisContext analysisContext, Source asyncLibrarySource) {
|
| throw new AnalysisException("Could not resolve dart:async");
|
| }
|
|
|
| @@ -9133,13 +8958,12 @@ class LibraryResolver2 {
|
| * @param coreLibrarySource the source representing the core library
|
| * @throws AnalysisException always
|
| */
|
| - static void missingCoreLibrary(AnalysisContext analysisContext,
|
| - Source coreLibrarySource) {
|
| + static void missingCoreLibrary(
|
| + AnalysisContext analysisContext, Source coreLibrarySource) {
|
| throw new AnalysisException("Could not resolve dart:core");
|
| }
|
| }
|
|
|
| -
|
| /**
|
| * Instances of the class `TypeAliasInfo` hold information about a [TypeAlias].
|
| */
|
| @@ -9191,8 +9015,8 @@ class LibraryScope extends EnclosedScope {
|
| * @param definingLibrary the element representing the library represented by this scope
|
| * @param errorListener the listener that is to be informed when an error is encountered
|
| */
|
| - LibraryScope(LibraryElement definingLibrary,
|
| - AnalysisErrorListener errorListener)
|
| + LibraryScope(
|
| + LibraryElement definingLibrary, AnalysisErrorListener errorListener)
|
| : super(new LibraryImportScope(definingLibrary, errorListener)) {
|
| _defineTopLevelNames(definingLibrary);
|
| }
|
| @@ -9209,12 +9033,11 @@ class LibraryScope extends EnclosedScope {
|
| offset = accessor.variable.nameOffset;
|
| }
|
| }
|
| - return new AnalysisError.con2(
|
| - duplicate.source,
|
| - offset,
|
| + return new AnalysisError.con2(duplicate.source, offset,
|
| duplicate.displayName.length,
|
| - CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER,
|
| - [existing.displayName]);
|
| + CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, [
|
| + existing.displayName
|
| + ]);
|
| }
|
| return super.getErrorForDuplicate(existing, duplicate);
|
| }
|
| @@ -9236,8 +9059,8 @@ class LibraryScope extends EnclosedScope {
|
| for (FunctionElement element in compilationUnit.functions) {
|
| define(element);
|
| }
|
| - for (FunctionTypeAliasElement element in
|
| - compilationUnit.functionTypeAliases) {
|
| + for (FunctionTypeAliasElement element
|
| + in compilationUnit.functionTypeAliases) {
|
| define(element);
|
| }
|
| for (ClassElement element in compilationUnit.types) {
|
| @@ -9502,7 +9325,8 @@ class NamespaceBuilder {
|
| * @return the export namespace that was created
|
| */
|
| Namespace createExportNamespaceForLibrary(LibraryElement library) =>
|
| - new Namespace(_createExportMapping(library, new HashSet<LibraryElement>()));
|
| + new Namespace(
|
| + _createExportMapping(library, new HashSet<LibraryElement>()));
|
|
|
| /**
|
| * Create a namespace representing the import namespace of the given library.
|
| @@ -9547,8 +9371,8 @@ class NamespaceBuilder {
|
| * @param definedNames the mapping table to which the names in the given namespace are to be added
|
| * @param namespace the namespace containing the names to be added to this namespace
|
| */
|
| - void _addAllFromMap(Map<String, Element> definedNames, Map<String,
|
| - Element> newNames) {
|
| + void _addAllFromMap(
|
| + Map<String, Element> definedNames, Map<String, Element> newNames) {
|
| newNames.forEach((String name, Element element) {
|
| definedNames[name] = element;
|
| });
|
| @@ -9560,8 +9384,8 @@ class NamespaceBuilder {
|
| * @param definedNames the mapping table to which the names in the given namespace are to be added
|
| * @param namespace the namespace containing the names to be added to this namespace
|
| */
|
| - void _addAllFromNamespace(Map<String, Element> definedNames,
|
| - Namespace namespace) {
|
| + void _addAllFromNamespace(
|
| + Map<String, Element> definedNames, Namespace namespace) {
|
| if (namespace != null) {
|
| _addAllFromMap(definedNames, namespace.definedNames);
|
| }
|
| @@ -9599,8 +9423,8 @@ class NamespaceBuilder {
|
| for (FunctionElement element in compilationUnit.functions) {
|
| _addIfPublic(definedNames, element);
|
| }
|
| - for (FunctionTypeAliasElement element in
|
| - compilationUnit.functionTypeAliases) {
|
| + for (FunctionTypeAliasElement element
|
| + in compilationUnit.functionTypeAliases) {
|
| _addIfPublic(definedNames, element);
|
| }
|
| for (ClassElement element in compilationUnit.types) {
|
| @@ -9614,8 +9438,9 @@ class NamespaceBuilder {
|
| * @param definedNames the mapping table to which the namespace operations are to be applied
|
| * @param combinators the combinators to be applied
|
| */
|
| - HashMap<String, Element> _applyCombinators(HashMap<String,
|
| - Element> definedNames, List<NamespaceCombinator> combinators) {
|
| + HashMap<String, Element> _applyCombinators(
|
| + HashMap<String, Element> definedNames,
|
| + List<NamespaceCombinator> combinators) {
|
| for (NamespaceCombinator combinator in combinators) {
|
| if (combinator is HideElementCombinator) {
|
| _hide(definedNames, combinator.hiddenNames);
|
| @@ -9623,8 +9448,8 @@ class NamespaceBuilder {
|
| definedNames = _show(definedNames, combinator.shownNames);
|
| } else {
|
| // Internal error.
|
| - AnalysisEngine.instance.logger.logError(
|
| - "Unknown type of combinator: ${combinator.runtimeType}");
|
| + AnalysisEngine.instance.logger
|
| + .logError("Unknown type of combinator: ${combinator.runtimeType}");
|
| }
|
| }
|
| return definedNames;
|
| @@ -9636,8 +9461,8 @@ class NamespaceBuilder {
|
| * @param definedNames the names that were defined before this operation
|
| * @param prefixElement the element defining the prefix to be added to the names
|
| */
|
| - HashMap<String, Element> _applyPrefix(HashMap<String, Element> definedNames,
|
| - PrefixElement prefixElement) {
|
| + HashMap<String, Element> _applyPrefix(
|
| + HashMap<String, Element> definedNames, PrefixElement prefixElement) {
|
| if (prefixElement != null) {
|
| String prefix = prefixElement.name;
|
| HashMap<String, Element> newNames = new HashMap<String, Element>();
|
| @@ -9659,8 +9484,8 @@ class NamespaceBuilder {
|
| * be added by another library
|
| * @return the mapping table that was created
|
| */
|
| - HashMap<String, Element> _createExportMapping(LibraryElement library,
|
| - HashSet<LibraryElement> visitedElements) {
|
| + HashMap<String, Element> _createExportMapping(
|
| + LibraryElement library, HashSet<LibraryElement> visitedElements) {
|
| visitedElements.add(library);
|
| try {
|
| HashMap<String, Element> definedNames = new HashMap<String, Element>();
|
| @@ -9678,9 +9503,9 @@ class NamespaceBuilder {
|
| _addAllFromMap(definedNames, exportedNames);
|
| }
|
| }
|
| - _addAllFromNamespace(
|
| - definedNames,
|
| - (library.context as InternalAnalysisContext).getPublicNamespace(library));
|
| + _addAllFromNamespace(definedNames,
|
| + (library.context as InternalAnalysisContext)
|
| + .getPublicNamespace(library));
|
| return definedNames;
|
| } finally {
|
| visitedElements.remove(library);
|
| @@ -9707,8 +9532,8 @@ class NamespaceBuilder {
|
| * @param definedNames the names that were defined before this operation
|
| * @param shownNames the names to be shown
|
| */
|
| - HashMap<String, Element> _show(HashMap<String, Element> definedNames,
|
| - List<String> shownNames) {
|
| + HashMap<String, Element> _show(
|
| + HashMap<String, Element> definedNames, List<String> shownNames) {
|
| HashMap<String, Element> newNames = new HashMap<String, Element>();
|
| for (String name in shownNames) {
|
| Element element = definedNames[name];
|
| @@ -9755,17 +9580,14 @@ class OverrideVerifier extends RecursiveAstVisitor<Object> {
|
| if (_getOverriddenMember(element) == null) {
|
| if (element is MethodElement) {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD,
|
| - node.name);
|
| + HintCode.OVERRIDE_ON_NON_OVERRIDING_METHOD, node.name);
|
| } else if (element is PropertyAccessorElement) {
|
| if (element.isGetter) {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER,
|
| - node.name);
|
| + HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER, node.name);
|
| } else {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER,
|
| - node.name);
|
| + HintCode.OVERRIDE_ON_NON_OVERRIDING_SETTER, node.name);
|
| }
|
| }
|
| }
|
| @@ -10287,18 +10109,15 @@ class ResolvableLibrary {
|
| */
|
| class ResolverErrorCode extends ErrorCode {
|
| static const ResolverErrorCode BREAK_LABEL_ON_SWITCH_MEMBER =
|
| - const ResolverErrorCode(
|
| - 'BREAK_LABEL_ON_SWITCH_MEMBER',
|
| + const ResolverErrorCode('BREAK_LABEL_ON_SWITCH_MEMBER',
|
| "Break label resolves to case or default statement");
|
|
|
| static const ResolverErrorCode CONTINUE_LABEL_ON_SWITCH =
|
| - const ResolverErrorCode(
|
| - 'CONTINUE_LABEL_ON_SWITCH',
|
| + const ResolverErrorCode('CONTINUE_LABEL_ON_SWITCH',
|
| "A continue label resolves to switch, must be loop or switch member");
|
|
|
| static const ResolverErrorCode MISSING_LIBRARY_DIRECTIVE_WITH_PART =
|
| - const ResolverErrorCode(
|
| - 'MISSING_LIBRARY_DIRECTIVE_WITH_PART',
|
| + const ResolverErrorCode('MISSING_LIBRARY_DIRECTIVE_WITH_PART',
|
| "Libraries that have parts must have a library directive");
|
|
|
| /**
|
| @@ -10394,20 +10213,20 @@ class ResolverVisitor extends ScopedVisitor {
|
| * @param source the source representing the compilation unit being visited
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| - ResolverVisitor.con1(Library library, Source source,
|
| - TypeProvider typeProvider, {StaticTypeAnalyzer typeAnalyzer,
|
| + ResolverVisitor.con1(
|
| + Library library, Source source, TypeProvider typeProvider,
|
| + {StaticTypeAnalyzer typeAnalyzer,
|
| StaticTypeAnalyzerFactory typeAnalyzerFactory})
|
| : super.con1(library, source, typeProvider) {
|
| this._inheritanceManager = library.inheritanceManager;
|
| this._elementResolver = new ElementResolver(this);
|
| - this._typeAnalyzer = typeAnalyzer != null ?
|
| - typeAnalyzer :
|
| - (typeAnalyzerFactory != null ?
|
| - typeAnalyzerFactory(this) :
|
| - new StaticTypeAnalyzer(this));
|
| + this._typeAnalyzer = typeAnalyzer != null
|
| + ? typeAnalyzer
|
| + : (typeAnalyzerFactory != null
|
| + ? typeAnalyzerFactory(this)
|
| + : new StaticTypeAnalyzer(this));
|
| }
|
|
|
| -
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| *
|
| @@ -10438,13 +10257,10 @@ class ResolverVisitor extends ScopedVisitor {
|
| * during resolution
|
| */
|
| ResolverVisitor.con3(LibraryElement definingLibrary, Source source,
|
| - TypeProvider typeProvider, Scope nameScope, AnalysisErrorListener errorListener)
|
| + TypeProvider typeProvider, Scope nameScope,
|
| + AnalysisErrorListener errorListener)
|
| : super.con3(
|
| - definingLibrary,
|
| - source,
|
| - typeProvider,
|
| - nameScope,
|
| - errorListener) {
|
| + definingLibrary, source, typeProvider, nameScope, errorListener) {
|
| this._inheritanceManager = new InheritanceManager(definingLibrary);
|
| this._elementResolver = new ElementResolver(this);
|
| this._typeAnalyzer = new StaticTypeAnalyzer(this);
|
| @@ -10457,8 +10273,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| * @param source the source representing the compilation unit being visited
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| - ResolverVisitor.con4(ResolvableLibrary library, Source source,
|
| - TypeProvider typeProvider)
|
| + ResolverVisitor.con4(
|
| + ResolvableLibrary library, Source source, TypeProvider typeProvider)
|
| : super.con4(library, source, typeProvider) {
|
| this._inheritanceManager = library.inheritanceManager;
|
| this._elementResolver = new ElementResolver(this);
|
| @@ -10593,8 +10409,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| * @param potentialType the potential type of the elements
|
| * @param allowPrecisionLoss see @{code overrideVariable} docs
|
| */
|
| - void overrideExpression(Expression expression, DartType potentialType,
|
| - bool allowPrecisionLoss) {
|
| + void overrideExpression(
|
| + Expression expression, DartType potentialType, bool allowPrecisionLoss) {
|
| VariableElement element = getOverridableStaticElement(expression);
|
| if (element != null) {
|
| overrideVariable(element, potentialType, allowPrecisionLoss);
|
| @@ -11304,8 +11120,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
|
|
| @override
|
| - Object
|
| - visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
|
| + Object visitRedirectingConstructorInvocation(
|
| + RedirectingConstructorInvocation node) {
|
| //
|
| // We visit the argument list, but do not visit the optional identifier
|
| // because it needs to be visited in the context of the constructor
|
| @@ -11408,8 +11224,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| * If the variable <i>v</i> is accessed by a closure in <i>s<sub>1</sub></i> then the variable
|
| * <i>v</i> is not potentially mutated anywhere in the scope of <i>v</i>.
|
| */
|
| - void
|
| - _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(AstNode target) {
|
| + void _clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(
|
| + AstNode target) {
|
| for (Element element in _promoteManager.promotedElements) {
|
| if ((element as VariableElementImpl).isPotentiallyMutatedInScope) {
|
| if (_isVariableAccessedInClosure(element, target)) {
|
| @@ -11454,8 +11270,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| DartType iteratorType = iteratorFunction.returnType;
|
| if (iteratorType is InterfaceType) {
|
| InterfaceType iteratorInterfaceType = iteratorType;
|
| - FunctionType currentFunction =
|
| - _inheritanceManager.lookupMemberType(iteratorInterfaceType, "current");
|
| + FunctionType currentFunction = _inheritanceManager.lookupMemberType(
|
| + iteratorInterfaceType, "current");
|
| if (currentFunction == null) {
|
| // TODO(brianwilkerson) Should we report this error?
|
| return null;
|
| @@ -11470,8 +11286,8 @@ class ResolverVisitor extends ScopedVisitor {
|
| * If given "mayBeClosure" is [FunctionExpression] without explicit parameters types and its
|
| * required type is [FunctionType], then infer parameters types from [FunctionType].
|
| */
|
| - void _inferFunctionExpressionParametersTypes(Expression mayBeClosure,
|
| - DartType mayByFunctionType) {
|
| + void _inferFunctionExpressionParametersTypes(
|
| + Expression mayBeClosure, DartType mayByFunctionType) {
|
| // prepare closure
|
| if (mayBeClosure is! FunctionExpression) {
|
| return;
|
| @@ -11495,8 +11311,9 @@ class ResolverVisitor extends ScopedVisitor {
|
| // set inferred types for parameters
|
| NodeList<FormalParameter> parameters = closure.parameters.parameters;
|
| List<ParameterElement> expectedParameters = expectedClosureType.parameters;
|
| - for (int i =
|
| - 0; i < parameters.length && i < expectedParameters.length; i++) {
|
| + for (int i = 0;
|
| + i < parameters.length && i < expectedParameters.length;
|
| + i++) {
|
| FormalParameter parameter = parameters[i];
|
| ParameterElement element = parameter.element;
|
| DartType currentType = _overrideManager.getBestType(element);
|
| @@ -11573,7 +11390,6 @@ class ResolverVisitor extends ScopedVisitor {
|
| return false;
|
| }
|
|
|
| -
|
| // This last-statement-is-return heuristic is unsound for adversarial
|
| // code, but probably works well in the common case:
|
| //
|
| @@ -11831,8 +11647,8 @@ abstract class Scope {
|
| String name = _getName(element);
|
| if (name != null && !name.isEmpty) {
|
| if (_definedNames.containsKey(name)) {
|
| - errorListener.onError(
|
| - getErrorForDuplicate(_definedNames[name], element));
|
| + errorListener
|
| + .onError(getErrorForDuplicate(_definedNames[name], element));
|
| } else {
|
| _definedNames[name] = element;
|
| _hasName = true;
|
| @@ -11875,11 +11691,8 @@ abstract class Scope {
|
| // TODO(jwren) There are 4 error codes for duplicate, but only 1 is being
|
| // generated.
|
| Source source = duplicate.source;
|
| - return new AnalysisError.con2(
|
| - source,
|
| - duplicate.nameOffset,
|
| - duplicate.displayName.length,
|
| - CompileTimeErrorCode.DUPLICATE_DEFINITION,
|
| + return new AnalysisError.con2(source, duplicate.nameOffset,
|
| + duplicate.displayName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION,
|
| [existing.displayName]);
|
| }
|
|
|
| @@ -11912,8 +11725,8 @@ abstract class Scope {
|
| * implement library-level privacy
|
| * @return the element with which the given name is associated
|
| */
|
| - Element internalLookup(Identifier identifier, String name,
|
| - LibraryElement referencingLibrary);
|
| + Element internalLookup(
|
| + Identifier identifier, String name, LibraryElement referencingLibrary);
|
|
|
| /**
|
| * Return the element with which the given name is associated, or `null` if the name is not
|
| @@ -12073,8 +11886,8 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
|
| * @param source the source representing the compilation unit being visited
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| - ScopedVisitor.con4(ResolvableLibrary library, this.source, this.typeProvider)
|
| - {
|
| + ScopedVisitor.con4(
|
| + ResolvableLibrary library, this.source, this.typeProvider) {
|
| this._definingLibrary = library.libraryElement;
|
| LibraryScope libraryScope = library.libraryScope;
|
| this._errorListener = libraryScope.errorListener;
|
| @@ -12138,8 +11951,8 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
|
| */
|
| void reportErrorForNode(ErrorCode errorCode, AstNode node,
|
| [List<Object> arguments]) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(source, node.offset, node.length, errorCode, arguments));
|
| + _errorListener.onError(new AnalysisError.con2(
|
| + source, node.offset, node.length, errorCode, arguments));
|
| }
|
|
|
| /**
|
| @@ -12165,13 +11978,8 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
|
| */
|
| void reportErrorForToken(ErrorCode errorCode, sc.Token token,
|
| [List<Object> arguments]) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - source,
|
| - token.offset,
|
| - token.length,
|
| - errorCode,
|
| - arguments));
|
| + _errorListener.onError(new AnalysisError.con2(
|
| + source, token.offset, token.length, errorCode, arguments));
|
| }
|
|
|
| /**
|
| @@ -12305,8 +12113,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
|
| }
|
| buffer.write(" in ");
|
| buffer.write(definingLibrary.source.fullName);
|
| - AnalysisEngine.instance.logger.logInformation(
|
| - buffer.toString(),
|
| + AnalysisEngine.instance.logger.logInformation(buffer.toString(),
|
| new CaughtException(new AnalysisException(), null));
|
| } else {
|
| _nameScope = new FunctionScope(_nameScope, constructorElement);
|
| @@ -12457,15 +12264,15 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
|
| while (parent != null) {
|
| if (parent is Declaration) {
|
| Element parentElement = (parent as Declaration).element;
|
| - buffer.write(
|
| - parentElement == null ? "<unknown> " : "${parentElement.name} ");
|
| + buffer.write(parentElement == null
|
| + ? "<unknown> "
|
| + : "${parentElement.name} ");
|
| }
|
| parent = parent.parent;
|
| }
|
| buffer.write("in ");
|
| buffer.write(definingLibrary.source.fullName);
|
| - AnalysisEngine.instance.logger.logInformation(
|
| - buffer.toString(),
|
| + AnalysisEngine.instance.logger.logInformation(buffer.toString(),
|
| new CaughtException(new AnalysisException(), null));
|
| } else {
|
| _nameScope = new FunctionScope(_nameScope, functionElement);
|
| @@ -12695,9 +12502,7 @@ class SubtypeManager {
|
| // subtypes
|
| HashSet<ClassElement> allSubtypes = new HashSet<ClassElement>();
|
| _safelyComputeAllSubtypes(
|
| - classElement,
|
| - new HashSet<ClassElement>(),
|
| - allSubtypes);
|
| + classElement, new HashSet<ClassElement>(), allSubtypes);
|
| return allSubtypes;
|
| }
|
|
|
| @@ -12789,8 +12594,8 @@ class SubtypeManager {
|
| * @param supertypeElement the key for the [subtypeMap] map
|
| * @param subtypeElement the value for the [subtypeMap] map
|
| */
|
| - void _putInSubtypeMap(ClassElement supertypeElement,
|
| - ClassElement subtypeElement) {
|
| + void _putInSubtypeMap(
|
| + ClassElement supertypeElement, ClassElement subtypeElement) {
|
| HashSet<ClassElement> subtypes = _subtypeMap[supertypeElement];
|
| if (subtypes == null) {
|
| subtypes = new HashSet<ClassElement>();
|
| @@ -12880,15 +12685,10 @@ class ToDoFinder {
|
| new JavaPatternMatcher(TodoCode.TODO_REGEX, commentToken.lexeme);
|
| if (matcher.find()) {
|
| int offset =
|
| - commentToken.offset +
|
| - matcher.start() +
|
| - matcher.group(1).length;
|
| + commentToken.offset + matcher.start() + matcher.group(1).length;
|
| int length = matcher.group(2).length;
|
| _errorReporter.reportErrorForOffset(
|
| - TodoCode.TODO,
|
| - offset,
|
| - length,
|
| - [matcher.group(2)]);
|
| + TodoCode.TODO, offset, length, [matcher.group(2)]);
|
| }
|
| }
|
| }
|
| @@ -12936,8 +12736,8 @@ class TypeOverrideManager {
|
| * @param variableList the list of variables whose overriding types are to be captured
|
| * @return a table mapping elements to their overriding types
|
| */
|
| - Map<VariableElement, DartType>
|
| - captureOverrides(VariableDeclarationList variableList) {
|
| + Map<VariableElement, DartType> captureOverrides(
|
| + VariableDeclarationList variableList) {
|
| if (_currentScope == null) {
|
| throw new IllegalStateException(
|
| "Cannot capture overrides without a scope");
|
| @@ -13124,8 +12924,8 @@ class TypeOverrideManager_TypeOverrideScope {
|
| * @param variableList the list of variables whose overriding types are to be captured
|
| * @return a table mapping elements to their overriding types
|
| */
|
| - Map<VariableElement, DartType>
|
| - captureOverrides(VariableDeclarationList variableList) {
|
| + Map<VariableElement, DartType> captureOverrides(
|
| + VariableDeclarationList variableList) {
|
| Map<VariableElement, DartType> overrides =
|
| new HashMap<VariableElement, DartType>();
|
| if (variableList.isConst || variableList.isFinal) {
|
| @@ -13710,8 +13510,8 @@ class TypeProviderImpl implements TypeProvider {
|
| InterfaceType _getType(Namespace namespace, String typeName) {
|
| Element element = namespace.get(typeName);
|
| if (element == null) {
|
| - AnalysisEngine.instance.logger.logInformation(
|
| - "No definition of type $typeName");
|
| + AnalysisEngine.instance.logger
|
| + .logInformation("No definition of type $typeName");
|
| return null;
|
| }
|
| return (element as ClassElement).type;
|
| @@ -13722,8 +13522,8 @@ class TypeProviderImpl implements TypeProvider {
|
| *
|
| * @param library the library containing the definitions of the core types
|
| */
|
| - void _initializeFrom(LibraryElement coreLibrary,
|
| - LibraryElement asyncLibrary) {
|
| + void _initializeFrom(
|
| + LibraryElement coreLibrary, LibraryElement asyncLibrary) {
|
| Namespace coreNamespace =
|
| new NamespaceBuilder().createPublicNamespaceForLibrary(coreLibrary);
|
| Namespace asyncNamespace =
|
| @@ -13784,8 +13584,8 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| * @param source the source representing the compilation unit being visited
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| - TypeResolverVisitor.con1(Library library, Source source,
|
| - TypeProvider typeProvider)
|
| + TypeResolverVisitor.con1(
|
| + Library library, Source source, TypeProvider typeProvider)
|
| : super.con1(library, source, typeProvider) {
|
| _dynamicType = typeProvider.dynamicType;
|
| _undefinedType = typeProvider.undefinedType;
|
| @@ -13819,13 +13619,10 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| * during resolution
|
| */
|
| TypeResolverVisitor.con3(LibraryElement definingLibrary, Source source,
|
| - TypeProvider typeProvider, Scope nameScope, AnalysisErrorListener errorListener)
|
| + TypeProvider typeProvider, Scope nameScope,
|
| + AnalysisErrorListener errorListener)
|
| : super.con3(
|
| - definingLibrary,
|
| - source,
|
| - typeProvider,
|
| - nameScope,
|
| - errorListener) {
|
| + definingLibrary, source, typeProvider, nameScope, errorListener) {
|
| _dynamicType = typeProvider.dynamicType;
|
| _undefinedType = typeProvider.undefinedType;
|
| }
|
| @@ -13837,8 +13634,8 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| * @param source the source representing the compilation unit being visited
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| - TypeResolverVisitor.con4(ResolvableLibrary library, Source source,
|
| - TypeProvider typeProvider)
|
| + TypeResolverVisitor.con4(
|
| + ResolvableLibrary library, Source source, TypeProvider typeProvider)
|
| : super.con4(library, source, typeProvider) {
|
| _dynamicType = typeProvider.dynamicType;
|
| _undefinedType = typeProvider.undefinedType;
|
| @@ -13927,14 +13724,11 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| ClassElementImpl classElement = _getClassElement(node.name);
|
| InterfaceType superclassType = null;
|
| if (extendsClause != null) {
|
| - ErrorCode errorCode = (withClause == null ?
|
| - CompileTimeErrorCode.EXTENDS_NON_CLASS :
|
| - CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS);
|
| - superclassType = _resolveType(
|
| - extendsClause.superclass,
|
| - errorCode,
|
| - CompileTimeErrorCode.EXTENDS_ENUM,
|
| - errorCode);
|
| + ErrorCode errorCode = (withClause == null
|
| + ? CompileTimeErrorCode.EXTENDS_NON_CLASS
|
| + : CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS);
|
| + superclassType = _resolveType(extendsClause.superclass, errorCode,
|
| + CompileTimeErrorCode.EXTENDS_ENUM, errorCode);
|
| if (!identical(superclassType, typeProvider.objectType)) {
|
| classElement.validMixin = false;
|
| }
|
| @@ -13971,11 +13765,8 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| Object visitClassTypeAlias(ClassTypeAlias node) {
|
| super.visitClassTypeAlias(node);
|
| ErrorCode errorCode = CompileTimeErrorCode.MIXIN_WITH_NON_CLASS_SUPERCLASS;
|
| - InterfaceType superclassType = _resolveType(
|
| - node.superclass,
|
| - errorCode,
|
| - CompileTimeErrorCode.EXTENDS_ENUM,
|
| - errorCode);
|
| + InterfaceType superclassType = _resolveType(node.superclass, errorCode,
|
| + CompileTimeErrorCode.EXTENDS_ENUM, errorCode);
|
| if (superclassType == null) {
|
| superclassType = typeProvider.objectType;
|
| }
|
| @@ -14006,8 +13797,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| buffer.write(" in ");
|
| buffer.write(source.fullName);
|
| buffer.write(" was not set while trying to resolve types.");
|
| - AnalysisEngine.instance.logger.logError(
|
| - buffer.toString(),
|
| + AnalysisEngine.instance.logger.logError(buffer.toString(),
|
| new CaughtException(new AnalysisException(), null));
|
| } else {
|
| ClassElement definingClass = element.enclosingElement as ClassElement;
|
| @@ -14077,8 +13867,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| buffer.write(" in ");
|
| buffer.write(source.fullName);
|
| buffer.write(" was not set while trying to resolve types.");
|
| - AnalysisEngine.instance.logger.logError(
|
| - buffer.toString(),
|
| + AnalysisEngine.instance.logger.logError(buffer.toString(),
|
| new CaughtException(new AnalysisException(), null));
|
| }
|
| element.returnType = _computeReturnType(node.returnType);
|
| @@ -14135,8 +13924,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| buffer.write(" in ");
|
| buffer.write(source.fullName);
|
| buffer.write(" was not set while trying to resolve types.");
|
| - AnalysisEngine.instance.logger.logError(
|
| - buffer.toString(),
|
| + AnalysisEngine.instance.logger.logError(buffer.toString(),
|
| new CaughtException(new AnalysisException(), null));
|
| }
|
| element.returnType = _computeReturnType(node.returnType);
|
| @@ -14241,17 +14029,16 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| (parent.parent as InstanceCreationExpression).isConst) {
|
| // If, if this is a const expression, then generate a
|
| // CompileTimeErrorCode.CONST_WITH_NON_TYPE error.
|
| - reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_WITH_NON_TYPE,
|
| + reportErrorForNode(CompileTimeErrorCode.CONST_WITH_NON_TYPE,
|
| prefixedIdentifier.identifier,
|
| [prefixedIdentifier.identifier.name]);
|
| } else {
|
| // Else, if this expression is a new expression, report a
|
| // NEW_WITH_NON_TYPE warning.
|
| - reportErrorForNode(
|
| - StaticWarningCode.NEW_WITH_NON_TYPE,
|
| - prefixedIdentifier.identifier,
|
| - [prefixedIdentifier.identifier.name]);
|
| + reportErrorForNode(StaticWarningCode.NEW_WITH_NON_TYPE,
|
| + prefixedIdentifier.identifier, [
|
| + prefixedIdentifier.identifier.name
|
| + ]);
|
| }
|
| _setElement(prefix, element);
|
| return null;
|
| @@ -14282,22 +14069,16 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| if (creation.isConst) {
|
| if (element == null) {
|
| reportErrorForNode(
|
| - CompileTimeErrorCode.UNDEFINED_CLASS,
|
| - typeNameSimple,
|
| - [typeName]);
|
| + CompileTimeErrorCode.UNDEFINED_CLASS, typeNameSimple, [typeName]);
|
| } else {
|
| - reportErrorForNode(
|
| - CompileTimeErrorCode.CONST_WITH_NON_TYPE,
|
| - typeNameSimple,
|
| - [typeName]);
|
| + reportErrorForNode(CompileTimeErrorCode.CONST_WITH_NON_TYPE,
|
| + typeNameSimple, [typeName]);
|
| }
|
| elementValid = false;
|
| } else {
|
| if (element != null) {
|
| reportErrorForNode(
|
| - StaticWarningCode.NEW_WITH_NON_TYPE,
|
| - typeNameSimple,
|
| - [typeName]);
|
| + StaticWarningCode.NEW_WITH_NON_TYPE, typeNameSimple, [typeName]);
|
| elementValid = false;
|
| }
|
| }
|
| @@ -14312,47 +14093,34 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| SimpleIdentifier typeNameSimple = _getTypeSimpleIdentifier(typeName);
|
| RedirectingConstructorKind redirectingConstructorKind;
|
| if (_isBuiltInIdentifier(node) && _isTypeAnnotation(node)) {
|
| - reportErrorForNode(
|
| - CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE,
|
| - typeName,
|
| - [typeName.name]);
|
| + reportErrorForNode(CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE,
|
| + typeName, [typeName.name]);
|
| } else if (typeNameSimple.name == "boolean") {
|
| reportErrorForNode(
|
| - StaticWarningCode.UNDEFINED_CLASS_BOOLEAN,
|
| - typeNameSimple,
|
| - []);
|
| + StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, typeNameSimple, []);
|
| } else if (_isTypeNameInCatchClause(node)) {
|
| - reportErrorForNode(
|
| - StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE,
|
| - typeName,
|
| + reportErrorForNode(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName,
|
| [typeName.name]);
|
| } else if (_isTypeNameInAsExpression(node)) {
|
| reportErrorForNode(
|
| - StaticWarningCode.CAST_TO_NON_TYPE,
|
| - typeName,
|
| - [typeName.name]);
|
| + StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.name]);
|
| } else if (_isTypeNameInIsExpression(node)) {
|
| - reportErrorForNode(
|
| - StaticWarningCode.TYPE_TEST_WITH_UNDEFINED_NAME,
|
| - typeName,
|
| - [typeName.name]);
|
| + reportErrorForNode(StaticWarningCode.TYPE_TEST_WITH_UNDEFINED_NAME,
|
| + typeName, [typeName.name]);
|
| } else if ((redirectingConstructorKind =
|
| - _getRedirectingConstructorKind(node)) != null) {
|
| - ErrorCode errorCode =
|
| - (redirectingConstructorKind == RedirectingConstructorKind.CONST ?
|
| - CompileTimeErrorCode.REDIRECT_TO_NON_CLASS :
|
| - StaticWarningCode.REDIRECT_TO_NON_CLASS);
|
| + _getRedirectingConstructorKind(node)) !=
|
| + null) {
|
| + ErrorCode errorCode = (redirectingConstructorKind ==
|
| + RedirectingConstructorKind.CONST
|
| + ? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS
|
| + : StaticWarningCode.REDIRECT_TO_NON_CLASS);
|
| reportErrorForNode(errorCode, typeName, [typeName.name]);
|
| } else if (_isTypeNameInTypeArgumentList(node)) {
|
| - reportErrorForNode(
|
| - StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT,
|
| - typeName,
|
| - [typeName.name]);
|
| + reportErrorForNode(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT,
|
| + typeName, [typeName.name]);
|
| } else {
|
| reportErrorForNode(
|
| - StaticWarningCode.UNDEFINED_CLASS,
|
| - typeName,
|
| - [typeName.name]);
|
| + StaticWarningCode.UNDEFINED_CLASS, typeName, [typeName.name]);
|
| }
|
| elementValid = false;
|
| }
|
| @@ -14392,32 +14160,25 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| // The name does not represent a type.
|
| RedirectingConstructorKind redirectingConstructorKind;
|
| if (_isTypeNameInCatchClause(node)) {
|
| - reportErrorForNode(
|
| - StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE,
|
| - typeName,
|
| + reportErrorForNode(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName,
|
| [typeName.name]);
|
| } else if (_isTypeNameInAsExpression(node)) {
|
| reportErrorForNode(
|
| - StaticWarningCode.CAST_TO_NON_TYPE,
|
| - typeName,
|
| - [typeName.name]);
|
| + StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.name]);
|
| } else if (_isTypeNameInIsExpression(node)) {
|
| - reportErrorForNode(
|
| - StaticWarningCode.TYPE_TEST_WITH_NON_TYPE,
|
| - typeName,
|
| + reportErrorForNode(StaticWarningCode.TYPE_TEST_WITH_NON_TYPE, typeName,
|
| [typeName.name]);
|
| } else if ((redirectingConstructorKind =
|
| - _getRedirectingConstructorKind(node)) != null) {
|
| - ErrorCode errorCode =
|
| - (redirectingConstructorKind == RedirectingConstructorKind.CONST ?
|
| - CompileTimeErrorCode.REDIRECT_TO_NON_CLASS :
|
| - StaticWarningCode.REDIRECT_TO_NON_CLASS);
|
| + _getRedirectingConstructorKind(node)) !=
|
| + null) {
|
| + ErrorCode errorCode = (redirectingConstructorKind ==
|
| + RedirectingConstructorKind.CONST
|
| + ? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS
|
| + : StaticWarningCode.REDIRECT_TO_NON_CLASS);
|
| reportErrorForNode(errorCode, typeName, [typeName.name]);
|
| } else if (_isTypeNameInTypeArgumentList(node)) {
|
| - reportErrorForNode(
|
| - StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT,
|
| - typeName,
|
| - [typeName.name]);
|
| + reportErrorForNode(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT,
|
| + typeName, [typeName.name]);
|
| } else {
|
| AstNode parent = typeName.parent;
|
| while (parent is TypeName) {
|
| @@ -14430,9 +14191,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| // Ignored. The error will be reported elsewhere.
|
| } else {
|
| reportErrorForNode(
|
| - StaticWarningCode.NOT_A_TYPE,
|
| - typeName,
|
| - [typeName.name]);
|
| + StaticWarningCode.NOT_A_TYPE, typeName, [typeName.name]);
|
| }
|
| }
|
| _setElement(typeName, _dynamicType.element);
|
| @@ -14456,10 +14215,11 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| typeArguments[i] = argumentType;
|
| }
|
| } else {
|
| - reportErrorForNode(
|
| - _getInvalidTypeParametersErrorCode(node),
|
| - node,
|
| - [typeName.name, parameterCount, argumentCount]);
|
| + reportErrorForNode(_getInvalidTypeParametersErrorCode(node), node, [
|
| + typeName.name,
|
| + parameterCount,
|
| + argumentCount
|
| + ]);
|
| for (int i = 0; i < parameterCount; i++) {
|
| typeArguments[i] = _dynamicType;
|
| }
|
| @@ -14653,8 +14413,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| ConstructorDeclaration constructorDeclaration =
|
| parent as ConstructorDeclaration;
|
| if (identical(
|
| - constructorDeclaration.redirectedConstructor,
|
| - constructorName)) {
|
| + constructorDeclaration.redirectedConstructor, constructorName)) {
|
| if (constructorDeclaration.constKeyword != null) {
|
| return RedirectingConstructorKind.CONST;
|
| }
|
| @@ -14827,8 +14586,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| void _resolve(ClassElementImpl classElement, WithClause withClause,
|
| ImplementsClause implementsClause) {
|
| if (withClause != null) {
|
| - List<InterfaceType> mixinTypes = _resolveTypes(
|
| - withClause.mixinTypes,
|
| + List<InterfaceType> mixinTypes = _resolveTypes(withClause.mixinTypes,
|
| CompileTimeErrorCode.MIXIN_OF_NON_CLASS,
|
| CompileTimeErrorCode.MIXIN_OF_ENUM,
|
| CompileTimeErrorCode.MIXIN_OF_NON_CLASS);
|
| @@ -14838,8 +14596,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| if (implementsClause != null) {
|
| NodeList<TypeName> interfaces = implementsClause.interfaces;
|
| - List<InterfaceType> interfaceTypes = _resolveTypes(
|
| - interfaces,
|
| + List<InterfaceType> interfaceTypes = _resolveTypes(interfaces,
|
| CompileTimeErrorCode.IMPLEMENTS_NON_CLASS,
|
| CompileTimeErrorCode.IMPLEMENTS_ENUM,
|
| CompileTimeErrorCode.IMPLEMENTS_DYNAMIC);
|
| @@ -14864,9 +14621,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| if (element != null && element == element2) {
|
| detectedRepeatOnIndex[j] = true;
|
| reportErrorForNode(
|
| - CompileTimeErrorCode.IMPLEMENTS_REPEATED,
|
| - typeName2,
|
| - [name2]);
|
| + CompileTimeErrorCode.IMPLEMENTS_REPEATED, typeName2, [name2]);
|
| }
|
| }
|
| }
|
| @@ -14917,7 +14672,8 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| * @return an array containing all of the types that were resolved.
|
| */
|
| List<InterfaceType> _resolveTypes(NodeList<TypeName> typeNames,
|
| - ErrorCode nonTypeError, ErrorCode enumTypeError, ErrorCode dynamicTypeError) {
|
| + ErrorCode nonTypeError, ErrorCode enumTypeError,
|
| + ErrorCode dynamicTypeError) {
|
| List<InterfaceType> types = new List<InterfaceType>();
|
| for (TypeName typeName in typeNames) {
|
| InterfaceType type =
|
| @@ -15034,8 +14790,8 @@ class VariableResolverVisitor extends ScopedVisitor {
|
| * @param source the source representing the compilation unit being visited
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| - VariableResolverVisitor.con1(Library library, Source source,
|
| - TypeProvider typeProvider)
|
| + VariableResolverVisitor.con1(
|
| + Library library, Source source, TypeProvider typeProvider)
|
| : super.con1(library, source, typeProvider);
|
|
|
| /**
|
| @@ -15049,13 +14805,10 @@ class VariableResolverVisitor extends ScopedVisitor {
|
| * during resolution
|
| */
|
| VariableResolverVisitor.con2(LibraryElement definingLibrary, Source source,
|
| - TypeProvider typeProvider, Scope nameScope, AnalysisErrorListener errorListener)
|
| + TypeProvider typeProvider, Scope nameScope,
|
| + AnalysisErrorListener errorListener)
|
| : super.con3(
|
| - definingLibrary,
|
| - source,
|
| - typeProvider,
|
| - nameScope,
|
| - errorListener);
|
| + definingLibrary, source, typeProvider, nameScope, errorListener);
|
|
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| @@ -15064,8 +14817,8 @@ class VariableResolverVisitor extends ScopedVisitor {
|
| * @param source the source representing the compilation unit being visited
|
| * @param typeProvider the object used to access the types from the core library
|
| */
|
| - VariableResolverVisitor.con3(ResolvableLibrary library, Source source,
|
| - TypeProvider typeProvider)
|
| + VariableResolverVisitor.con3(
|
| + ResolvableLibrary library, Source source, TypeProvider typeProvider)
|
| : super.con4(library, source, typeProvider);
|
|
|
| @override
|
| @@ -15177,28 +14930,22 @@ class _ConstantVerifier_validateInitializerExpression extends ConstantVisitor {
|
| if (type != null) {
|
| if (type.isDynamic) {
|
| return new DartObjectImpl(
|
| - verifier._typeProvider.objectType,
|
| - DynamicState.DYNAMIC_STATE);
|
| + verifier._typeProvider.objectType, DynamicState.DYNAMIC_STATE);
|
| } else if (type.isSubtypeOf(verifier._boolType)) {
|
| return new DartObjectImpl(
|
| - verifier._typeProvider.boolType,
|
| - BoolState.UNKNOWN_VALUE);
|
| + verifier._typeProvider.boolType, BoolState.UNKNOWN_VALUE);
|
| } else if (type.isSubtypeOf(verifier._typeProvider.doubleType)) {
|
| return new DartObjectImpl(
|
| - verifier._typeProvider.doubleType,
|
| - DoubleState.UNKNOWN_VALUE);
|
| + verifier._typeProvider.doubleType, DoubleState.UNKNOWN_VALUE);
|
| } else if (type.isSubtypeOf(verifier._intType)) {
|
| return new DartObjectImpl(
|
| - verifier._typeProvider.intType,
|
| - IntState.UNKNOWN_VALUE);
|
| + verifier._typeProvider.intType, IntState.UNKNOWN_VALUE);
|
| } else if (type.isSubtypeOf(verifier._numType)) {
|
| return new DartObjectImpl(
|
| - verifier._typeProvider.numType,
|
| - NumState.UNKNOWN_VALUE);
|
| + verifier._typeProvider.numType, NumState.UNKNOWN_VALUE);
|
| } else if (type.isSubtypeOf(verifier._stringType)) {
|
| return new DartObjectImpl(
|
| - verifier._typeProvider.stringType,
|
| - StringState.UNKNOWN_VALUE);
|
| + verifier._typeProvider.stringType, StringState.UNKNOWN_VALUE);
|
| }
|
| //
|
| // We don't test for other types of objects (such as List, Map,
|
| @@ -15222,8 +14969,7 @@ class _ElementBuilder_visitClassDeclaration extends UnifyingAstVisitor<Object> {
|
|
|
| List<ClassMember> nonFields;
|
|
|
| - _ElementBuilder_visitClassDeclaration(this.builder, this.nonFields)
|
| - : super();
|
| + _ElementBuilder_visitClassDeclaration(this.builder, this.nonFields) : super();
|
|
|
| @override
|
| Object visitConstructorDeclaration(ConstructorDeclaration node) {
|
| @@ -15409,8 +15155,8 @@ class _GatherUsedElementsVisitor extends RecursiveAstVisitor {
|
| }
|
| }
|
|
|
| -class _ResolverVisitor_isVariableAccessedInClosure extends
|
| - RecursiveAstVisitor<Object> {
|
| +class _ResolverVisitor_isVariableAccessedInClosure
|
| + extends RecursiveAstVisitor<Object> {
|
| final Element variable;
|
|
|
| bool result = false;
|
| @@ -15442,9 +15188,8 @@ class _ResolverVisitor_isVariableAccessedInClosure extends
|
| }
|
| }
|
|
|
| -
|
| -class _ResolverVisitor_isVariablePotentiallyMutatedIn extends
|
| - RecursiveAstVisitor<Object> {
|
| +class _ResolverVisitor_isVariablePotentiallyMutatedIn
|
| + extends RecursiveAstVisitor<Object> {
|
| final Element variable;
|
|
|
| bool result = false;
|
| @@ -15465,15 +15210,14 @@ class _ResolverVisitor_isVariablePotentiallyMutatedIn extends
|
| }
|
| }
|
|
|
| -
|
| -class _TypeResolverVisitor_visitClassMembersInScope extends
|
| - UnifyingAstVisitor<Object> {
|
| +class _TypeResolverVisitor_visitClassMembersInScope
|
| + extends UnifyingAstVisitor<Object> {
|
| final TypeResolverVisitor TypeResolverVisitor_this;
|
|
|
| List<ClassMember> nonFields;
|
|
|
| - _TypeResolverVisitor_visitClassMembersInScope(this.TypeResolverVisitor_this,
|
| - this.nonFields)
|
| + _TypeResolverVisitor_visitClassMembersInScope(
|
| + this.TypeResolverVisitor_this, this.nonFields)
|
| : super();
|
|
|
| @override
|
| @@ -15501,7 +15245,6 @@ class _TypeResolverVisitor_visitClassMembersInScope extends
|
| Object visitWithClause(WithClause node) => null;
|
| }
|
|
|
| -
|
| /**
|
| * Instances of the class [_UnusedElementsVerifier] traverse an element
|
| * structure looking for cases of [HintCode.UNUSED_ELEMENT] and
|
| @@ -15526,10 +15269,10 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| @override
|
| visitClassElement(ClassElement element) {
|
| if (!_isUsedElement(element)) {
|
| - _reportErrorForElement(
|
| - HintCode.UNUSED_ELEMENT,
|
| - element,
|
| - [element.kind.displayName, element.displayName]);
|
| + _reportErrorForElement(HintCode.UNUSED_ELEMENT, element, [
|
| + element.kind.displayName,
|
| + element.displayName
|
| + ]);
|
| }
|
| super.visitClassElement(element);
|
| }
|
| @@ -15538,9 +15281,7 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| visitFieldElement(FieldElement element) {
|
| if (!_isReadMember(element)) {
|
| _reportErrorForElement(
|
| - HintCode.UNUSED_FIELD,
|
| - element,
|
| - [element.displayName]);
|
| + HintCode.UNUSED_FIELD, element, [element.displayName]);
|
| }
|
| super.visitFieldElement(element);
|
| }
|
| @@ -15548,10 +15289,10 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| @override
|
| visitFunctionElement(FunctionElement element) {
|
| if (!_isUsedElement(element)) {
|
| - _reportErrorForElement(
|
| - HintCode.UNUSED_ELEMENT,
|
| - element,
|
| - [element.kind.displayName, element.displayName]);
|
| + _reportErrorForElement(HintCode.UNUSED_ELEMENT, element, [
|
| + element.kind.displayName,
|
| + element.displayName
|
| + ]);
|
| }
|
| super.visitFunctionElement(element);
|
| }
|
| @@ -15560,19 +15301,17 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| visitLocalVariableElement(LocalVariableElement element) {
|
| if (!_isUsedElement(element)) {
|
| _reportErrorForElement(
|
| - HintCode.UNUSED_LOCAL_VARIABLE,
|
| - element,
|
| - [element.displayName]);
|
| + HintCode.UNUSED_LOCAL_VARIABLE, element, [element.displayName]);
|
| }
|
| }
|
|
|
| @override
|
| visitMethodElement(MethodElement element) {
|
| if (!_isUsedMember(element)) {
|
| - _reportErrorForElement(
|
| - HintCode.UNUSED_ELEMENT,
|
| - element,
|
| - [element.kind.displayName, element.displayName]);
|
| + _reportErrorForElement(HintCode.UNUSED_ELEMENT, element, [
|
| + element.kind.displayName,
|
| + element.displayName
|
| + ]);
|
| }
|
| super.visitMethodElement(element);
|
| }
|
| @@ -15580,10 +15319,10 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| @override
|
| visitPropertyAccessorElement(PropertyAccessorElement element) {
|
| if (!_isUsedMember(element)) {
|
| - _reportErrorForElement(
|
| - HintCode.UNUSED_ELEMENT,
|
| - element,
|
| - [element.kind.displayName, element.displayName]);
|
| + _reportErrorForElement(HintCode.UNUSED_ELEMENT, element, [
|
| + element.kind.displayName,
|
| + element.displayName
|
| + ]);
|
| }
|
| super.visitPropertyAccessorElement(element);
|
| }
|
| @@ -15626,21 +15365,16 @@ class _UnusedElementsVerifier extends RecursiveElementVisitor {
|
| return _usedElements.elements.contains(element);
|
| }
|
|
|
| - void _reportErrorForElement(ErrorCode errorCode, Element element,
|
| - List<Object> arguments) {
|
| + void _reportErrorForElement(
|
| + ErrorCode errorCode, Element element, List<Object> arguments) {
|
| if (element != null) {
|
| - _errorListener.onError(
|
| - new AnalysisError.con2(
|
| - element.source,
|
| - element.nameOffset,
|
| - element.displayName.length,
|
| - errorCode,
|
| - arguments));
|
| + _errorListener.onError(new AnalysisError.con2(element.source,
|
| + element.nameOffset, element.displayName.length, errorCode,
|
| + arguments));
|
| }
|
| }
|
| }
|
|
|
| -
|
| class _UsedElements {
|
| /**
|
| * Resolved, locally defined elements that are used or potentially can be
|
|
|