| 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 4e5138857c854b9dde59f4bcd249de6849d4c27a..8110c8cfb3097cc034a67e5342374f96a6255472 100644
|
| --- a/pkg/analyzer/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart
|
| @@ -293,9 +293,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 _checkForArgumentTypeNotAssignable(Expression expression,
|
| - DartType expectedStaticType, DartType actualStaticType,
|
| - DartType expectedPropagatedType, DartType actualPropagatedType,
|
| + bool _checkForArgumentTypeNotAssignable(
|
| + Expression expression,
|
| + DartType expectedStaticType,
|
| + DartType actualStaticType,
|
| + DartType expectedPropagatedType,
|
| + DartType actualPropagatedType,
|
| ErrorCode hintCode) {
|
| //
|
| // Warning case: test static type information
|
| @@ -347,8 +350,10 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| DartType propagatedParameterType = propagatedParameterElement == null
|
| ? null
|
| : propagatedParameterElement.type;
|
| - return _checkForArgumentTypeNotAssignableWithExpectedTypes(argument,
|
| - staticParameterType, propagatedParameterType,
|
| + return _checkForArgumentTypeNotAssignableWithExpectedTypes(
|
| + argument,
|
| + staticParameterType,
|
| + propagatedParameterType,
|
| HintCode.ARGUMENT_TYPE_NOT_ASSIGNABLE);
|
| }
|
|
|
| @@ -364,11 +369,17 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| * 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);
|
| + 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.
|
| @@ -541,7 +552,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
| }
|
| if (importedLibrary.hasLoadLibraryFunction) {
|
| _errorReporter.reportErrorForNode(
|
| - HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION, node,
|
| + HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
|
| + node,
|
| [importedLibrary.name]);
|
| return true;
|
| }
|
| @@ -740,12 +752,16 @@ 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(duplicate.source, duplicate.nameOffset,
|
| + return new AnalysisError(
|
| + duplicate.source,
|
| + duplicate.nameOffset,
|
| duplicate.displayName.length,
|
| CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME,
|
| [existing.displayName]);
|
| } else {
|
| - return new AnalysisError(existing.source, existing.nameOffset,
|
| + return new AnalysisError(
|
| + existing.source,
|
| + existing.nameOffset,
|
| existing.displayName.length,
|
| CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME,
|
| [existing.displayName]);
|
| @@ -919,8 +935,11 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| new ConstantEvaluationEngine(_typeProvider, declaredVariables);
|
| ConstantVisitor constantVisitor =
|
| new ConstantVisitor(evaluationEngine, _errorReporter);
|
| - evaluationEngine.evaluateConstructorCall(node,
|
| - node.argumentList.arguments, constructor, constantVisitor,
|
| + evaluationEngine.evaluateConstructorCall(
|
| + node,
|
| + node.argumentList.arguments,
|
| + constructor,
|
| + constantVisitor,
|
| _errorReporter);
|
| }
|
| }
|
| @@ -976,7 +995,8 @@ 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 {
|
| @@ -1040,7 +1060,8 @@ 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;
|
| }
|
| }
|
| @@ -1093,7 +1114,8 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| // report error
|
| _errorReporter.reportErrorForToken(
|
| CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
|
| - node.switchKeyword, [type.displayName]);
|
| + node.switchKeyword,
|
| + [type.displayName]);
|
| return true;
|
| }
|
|
|
| @@ -1299,11 +1321,13 @@ class ConstantVerifier extends RecursiveAstVisitor<Object> {
|
| new ErrorReporter(errorListener, _errorReporter.source);
|
| DartObjectImpl result = initializer.accept(new ConstantVisitor(
|
| new ConstantEvaluationEngine(
|
| - _typeProvider, declaredVariables), subErrorReporter));
|
| + _typeProvider, declaredVariables),
|
| + subErrorReporter));
|
| if (result == null) {
|
| _errorReporter.reportErrorForNode(
|
| CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
|
| - errorSite, [variableDeclaration.name.name]);
|
| + errorSite,
|
| + [variableDeclaration.name.name]);
|
| }
|
| }
|
| }
|
| @@ -1625,10 +1649,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;
|
| }
|
| }
|
| @@ -1925,9 +1949,10 @@ 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);
|
| @@ -2031,9 +2056,11 @@ 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);
|
| @@ -2084,8 +2111,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);
|
| @@ -3012,8 +3039,8 @@ class ElementBuilder extends RecursiveAstVisitor<Object> {
|
| } else {
|
| String message =
|
| "Exception caught in ElementBuilder.visitMethodDeclaration()";
|
| - AnalysisEngine.instance.logger.logError(
|
| - message, new CaughtException(exception, stackTrace));
|
| + AnalysisEngine.instance.logger
|
| + .logError(message, new CaughtException(exception, stackTrace));
|
| }
|
| } finally {
|
| if (node.name.staticElement == null) {
|
| @@ -3025,7 +3052,8 @@ 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(),
|
| + AnalysisEngine.instance.logger.logError(
|
| + buffer.toString(),
|
| new CaughtException(
|
| new AnalysisException(buffer.toString()), null));
|
| }
|
| @@ -3726,8 +3754,10 @@ class EnclosedScope extends Scope {
|
| if (_hasHiddenName) {
|
| Element hiddenElement = _hiddenElements[name];
|
| if (hiddenElement != null) {
|
| - errorListener.onError(new AnalysisError(getSource(identifier),
|
| - identifier.offset, identifier.length,
|
| + errorListener.onError(new AnalysisError(
|
| + getSource(identifier),
|
| + identifier.offset,
|
| + identifier.length,
|
| CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION, []));
|
| return hiddenElement;
|
| }
|
| @@ -5673,7 +5703,8 @@ class InheritanceManager {
|
| * @return the passed function type with any parameterized types substituted
|
| */
|
| FunctionType substituteTypeArgumentsInMemberFromInheritance(
|
| - FunctionType baseFunctionType, String memberName,
|
| + FunctionType baseFunctionType,
|
| + String memberName,
|
| InterfaceType definingType) {
|
| // if the baseFunctionType is null, or does not have any parameters,
|
| // return it.
|
| @@ -6230,12 +6261,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 {
|
| //
|
| @@ -6247,9 +6278,8 @@ class InheritanceManager {
|
| // Tests: test_getMapOfMembersInheritedFromInterfaces_
|
| // union_multipleSubtypes_*
|
| //
|
| - List<ExecutableElement> elementArrayToMerge =
|
| - new List<ExecutableElement>(
|
| - subtypesOfAllOtherTypesIndexes.length);
|
| + List<ExecutableElement> elementArrayToMerge = new List<
|
| + ExecutableElement>(subtypesOfAllOtherTypesIndexes.length);
|
| for (int i = 0; i < elementArrayToMerge.length; i++) {
|
| elementArrayToMerge[i] =
|
| elements[subtypesOfAllOtherTypesIndexes[i]];
|
| @@ -6260,7 +6290,9 @@ class InheritanceManager {
|
| }
|
| }
|
| } else {
|
| - _reportError(classElt, classElt.nameOffset,
|
| + _reportError(
|
| + classElt,
|
| + classElt.nameOffset,
|
| classElt.displayName.length,
|
| StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD,
|
| [key]);
|
| @@ -6383,8 +6415,11 @@ 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));
|
| }
|
|
|
| @@ -6400,8 +6435,10 @@ class InheritanceManager {
|
| * @return the created synthetic element
|
| */
|
| static ExecutableElement _createSyntheticExecutableElement(
|
| - List<ExecutableElement> elementArrayToMerge, String name,
|
| - int numOfRequiredParameters, int numOfPositionalParameters,
|
| + List<ExecutableElement> elementArrayToMerge,
|
| + String name,
|
| + int numOfRequiredParameters,
|
| + int numOfPositionalParameters,
|
| List<String> namedParameters) {
|
| DynamicTypeImpl dynamicType = DynamicTypeImpl.instance;
|
| SimpleIdentifier nameIdentifier = new SimpleIdentifier(
|
| @@ -6783,8 +6820,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}",
|
| @@ -6861,9 +6898,12 @@ class Library {
|
| Source source =
|
| _analysisContext.sourceFactory.resolveUri(librarySource, uriContent);
|
| if (!_analysisContext.exists(source)) {
|
| - errorListener.onError(new AnalysisError(librarySource,
|
| - uriLiteral.offset, uriLiteral.length,
|
| - CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent]));
|
| + errorListener.onError(new AnalysisError(
|
| + librarySource,
|
| + uriLiteral.offset,
|
| + uriLiteral.length,
|
| + CompileTimeErrorCode.URI_DOES_NOT_EXIST,
|
| + [uriContent]));
|
| }
|
| return source;
|
| } on URISyntaxException {
|
| @@ -6968,21 +7008,24 @@ class LibraryElementBuilder {
|
| String partLibraryName =
|
| _getPartLibraryName(partSource, partUnit, directivesToResolve);
|
| if (partLibraryName == null) {
|
| - _errorListener.onError(new AnalysisError(librarySource,
|
| - partUri.offset, partUri.length,
|
| - CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSource()]));
|
| + _errorListener.onError(new AnalysisError(
|
| + 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(librarySource,
|
| - partUri.offset, partUri.length,
|
| - StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [
|
| - libraryNameNode.name,
|
| - partLibraryName
|
| - ]));
|
| + _errorListener.onError(new AnalysisError(
|
| + librarySource,
|
| + partUri.offset,
|
| + partUri.length,
|
| + StaticWarningCode.PART_OF_DIFFERENT_LIBRARY,
|
| + [libraryNameNode.name, partLibraryName]));
|
| }
|
| if (entryPoint == null) {
|
| entryPoint = _findEntryPoint(part);
|
| @@ -7072,21 +7115,24 @@ class LibraryElementBuilder {
|
| String partLibraryName =
|
| _getPartLibraryName(partSource, partUnit, directivesToResolve);
|
| if (partLibraryName == null) {
|
| - _errorListener.onError(new AnalysisError(librarySource,
|
| - partUri.offset, partUri.length,
|
| - CompileTimeErrorCode.PART_OF_NON_PART, [partUri.toSource()]));
|
| + _errorListener.onError(new AnalysisError(
|
| + 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(librarySource,
|
| - partUri.offset, partUri.length,
|
| - StaticWarningCode.PART_OF_DIFFERENT_LIBRARY, [
|
| - libraryNameNode.name,
|
| - partLibraryName
|
| - ]));
|
| + _errorListener.onError(new AnalysisError(
|
| + librarySource,
|
| + partUri.offset,
|
| + partUri.length,
|
| + StaticWarningCode.PART_OF_DIFFERENT_LIBRARY,
|
| + [libraryNameNode.name, partLibraryName]));
|
| }
|
| if (entryPoint == null) {
|
| entryPoint = _findEntryPoint(part);
|
| @@ -7291,8 +7337,10 @@ class LibraryImportScope extends Scope {
|
| libraryNames[i] = _getLibraryName(conflictingMembers[i]);
|
| }
|
| libraryNames.sort();
|
| - errorListener.onError(new AnalysisError(getSource(identifier),
|
| - identifier.offset, identifier.length,
|
| + errorListener.onError(new AnalysisError(
|
| + getSource(identifier),
|
| + identifier.offset,
|
| + identifier.length,
|
| StaticWarningCode.AMBIGUOUS_IMPORT, [
|
| foundEltName,
|
| StringUtilities.printListOfQuotedNames(libraryNames)
|
| @@ -7393,13 +7441,12 @@ class LibraryImportScope extends Scope {
|
| if (sdkElement != null && nonSdkElements.length > 0) {
|
| String sdkLibName = _getLibraryName(sdkElement);
|
| String otherLibName = _getLibraryName(nonSdkElements[0]);
|
| - errorListener.onError(new AnalysisError(getSource(identifier),
|
| - identifier.offset, identifier.length,
|
| - StaticWarningCode.CONFLICTING_DART_IMPORT, [
|
| - name,
|
| - sdkLibName,
|
| - otherLibName
|
| - ]));
|
| + errorListener.onError(new AnalysisError(
|
| + getSource(identifier),
|
| + identifier.offset,
|
| + identifier.length,
|
| + StaticWarningCode.CONFLICTING_DART_IMPORT,
|
| + [name, sdkLibName, otherLibName]));
|
| }
|
| if (nonSdkElements.length == conflictingElements.length) {
|
| // None of the members were removed
|
| @@ -7748,7 +7795,8 @@ class LibraryResolver {
|
| * @param visitedLibraries the libraries that have already been visited, used to prevent infinite
|
| * recursion
|
| */
|
| - void _addToDependencyMap(Library library,
|
| + void _addToDependencyMap(
|
| + Library library,
|
| HashMap<Library, List<Library>> dependencyMap,
|
| Set<Library> visitedLibraries) {
|
| if (visitedLibraries.add(library)) {
|
| @@ -7853,8 +7901,11 @@ class LibraryResolver {
|
| ErrorCode errorCode = (importElement.isDeferred
|
| ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
|
| : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
|
| - _errorListener.onError(new AnalysisError(library.librarySource,
|
| - uriLiteral.offset, uriLiteral.length, errorCode,
|
| + _errorListener.onError(new AnalysisError(
|
| + library.librarySource,
|
| + uriLiteral.offset,
|
| + uriLiteral.length,
|
| + errorCode,
|
| [uriLiteral.toSource()]));
|
| }
|
| }
|
| @@ -7883,8 +7934,10 @@ class LibraryResolver {
|
| exports.add(exportElement);
|
| if (analysisContext.computeKindOf(exportedSource) !=
|
| SourceKind.LIBRARY) {
|
| - _errorListener.onError(new AnalysisError(library.librarySource,
|
| - uriLiteral.offset, uriLiteral.length,
|
| + _errorListener.onError(new AnalysisError(
|
| + library.librarySource,
|
| + uriLiteral.offset,
|
| + uriLiteral.length,
|
| CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
|
| [uriLiteral.toSource()]));
|
| }
|
| @@ -8041,7 +8094,8 @@ class LibraryResolver {
|
| */
|
| void _computeLibraryDependencies(Library library) {
|
| Source librarySource = library.librarySource;
|
| - _computeLibraryDependenciesFromDirectives(library,
|
| + _computeLibraryDependenciesFromDirectives(
|
| + library,
|
| analysisContext.computeImportedLibraries(librarySource),
|
| analysisContext.computeExportedLibraries(librarySource));
|
| }
|
| @@ -8195,7 +8249,9 @@ class LibraryResolver {
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(_errorListener, source);
|
| ConstantVerifier constantVerifier = new ConstantVerifier(
|
| - errorReporter, library.libraryElement, _typeProvider,
|
| + errorReporter,
|
| + library.libraryElement,
|
| + _typeProvider,
|
| analysisContext.declaredVariables);
|
| unit.accept(constantVerifier);
|
| } on AnalysisException catch (exception, stackTrace) {
|
| @@ -8498,8 +8554,11 @@ class LibraryResolver2 {
|
| ErrorCode errorCode = (importElement.isDeferred
|
| ? StaticWarningCode.IMPORT_OF_NON_LIBRARY
|
| : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
|
| - _errorListener.onError(new AnalysisError(library.librarySource,
|
| - uriLiteral.offset, uriLiteral.length, errorCode,
|
| + _errorListener.onError(new AnalysisError(
|
| + library.librarySource,
|
| + uriLiteral.offset,
|
| + uriLiteral.length,
|
| + errorCode,
|
| [uriLiteral.toSource()]));
|
| }
|
| }
|
| @@ -8531,8 +8590,10 @@ class LibraryResolver2 {
|
| exports.add(exportElement);
|
| if (analysisContext.computeKindOf(exportedSource) !=
|
| SourceKind.LIBRARY) {
|
| - _errorListener.onError(new AnalysisError(library.librarySource,
|
| - uriLiteral.offset, uriLiteral.length,
|
| + _errorListener.onError(new AnalysisError(
|
| + library.librarySource,
|
| + uriLiteral.offset,
|
| + uriLiteral.length,
|
| CompileTimeErrorCode.EXPORT_OF_NON_LIBRARY,
|
| [uriLiteral.toSource()]));
|
| }
|
| @@ -8626,7 +8687,9 @@ class LibraryResolver2 {
|
| Source source = unit.source;
|
| CompilationUnit ast = unit.compilationUnit;
|
| TypeResolverVisitor visitor = new TypeResolverVisitor(
|
| - library.libraryElement, source, _typeProvider,
|
| + library.libraryElement,
|
| + source,
|
| + _typeProvider,
|
| library.libraryScope.errorListener,
|
| nameScope: library.libraryScope);
|
| ast.accept(visitor);
|
| @@ -8676,7 +8739,9 @@ class LibraryResolver2 {
|
| ErrorReporter errorReporter =
|
| new ErrorReporter(_errorListener, unit.source);
|
| ConstantVerifier constantVerifier = new ConstantVerifier(
|
| - errorReporter, library.libraryElement, _typeProvider,
|
| + errorReporter,
|
| + library.libraryElement,
|
| + _typeProvider,
|
| analysisContext.declaredVariables);
|
| ast.accept(constantVerifier);
|
| }
|
| @@ -8814,7 +8879,9 @@ class LibraryScope extends EnclosedScope {
|
| offset = accessor.variable.nameOffset;
|
| }
|
| }
|
| - return new AnalysisError(duplicate.source, offset,
|
| + return new AnalysisError(
|
| + duplicate.source,
|
| + offset,
|
| duplicate.displayName.length,
|
| CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER,
|
| [existing.displayName]);
|
| @@ -9296,7 +9363,8 @@ class NamespaceBuilder {
|
| definedNames.addAll(exportedNames);
|
| }
|
| }
|
| - _addAllFromNamespace(definedNames,
|
| + _addAllFromNamespace(
|
| + definedNames,
|
| (library.context as InternalAnalysisContext)
|
| .getPublicNamespace(library));
|
| return definedNames;
|
| @@ -10020,10 +10088,11 @@ class ResolverVisitor extends ScopedVisitor {
|
| */
|
| ResolverVisitor(LibraryElement definingLibrary, Source source,
|
| TypeProvider typeProvider, AnalysisErrorListener errorListener,
|
| - {Scope nameScope, InheritanceManager inheritanceManager,
|
| + {Scope nameScope,
|
| + InheritanceManager inheritanceManager,
|
| StaticTypeAnalyzerFactory typeAnalyzerFactory})
|
| : super(definingLibrary, source, typeProvider, errorListener,
|
| - nameScope: nameScope) {
|
| + nameScope: nameScope) {
|
| if (inheritanceManager == null) {
|
| this._inheritanceManager = new InheritanceManager(definingLibrary);
|
| } else {
|
| @@ -10051,10 +10120,10 @@ class ResolverVisitor extends ScopedVisitor {
|
| Library library, Source source, TypeProvider typeProvider,
|
| {StaticTypeAnalyzerFactory typeAnalyzerFactory})
|
| : this(
|
| - library.libraryElement, source, typeProvider, library.errorListener,
|
| - nameScope: library.libraryScope,
|
| - inheritanceManager: library.inheritanceManager,
|
| - typeAnalyzerFactory: typeAnalyzerFactory);
|
| + library.libraryElement, source, typeProvider, library.errorListener,
|
| + nameScope: library.libraryScope,
|
| + inheritanceManager: library.inheritanceManager,
|
| + typeAnalyzerFactory: typeAnalyzerFactory);
|
|
|
| /**
|
| * Return the element representing the function containing the current node, or `null` if
|
| @@ -10710,9 +10779,16 @@ class ResolverVisitor extends ScopedVisitor {
|
| if (loopVariable != null && iterable != null) {
|
| LocalVariableElement loopElement = loopVariable.element;
|
| if (loopElement != null) {
|
| - DartType iteratorElementType = _getIteratorElementType(iterable);
|
| - overrideVariable(loopElement, iteratorElementType, true);
|
| - _recordPropagatedType(loopVariable.identifier, iteratorElementType);
|
| + DartType propagatedType = null;
|
| + if (node.awaitKeyword == null) {
|
| + propagatedType = _getIteratorElementType(iterable);
|
| + } else {
|
| + propagatedType = _getStreamElementType(iterable);
|
| + }
|
| + if (propagatedType != null) {
|
| + overrideVariable(loopElement, propagatedType, true);
|
| + _recordPropagatedType(loopVariable.identifier, propagatedType);
|
| + }
|
| }
|
| } else if (identifier != null && iterable != null) {
|
| Element identifierElement = identifier.staticElement;
|
| @@ -11094,12 +11170,11 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
|
|
| /**
|
| - * The given expression is the expression used to compute the iterator for a for-each statement.
|
| - * Attempt to compute the type of objects that will be assigned to the loop variable and return
|
| - * that type. Return `null` if the type could not be determined.
|
| - *
|
| - * @param iterator the iterator for a for-each statement
|
| - * @return the type of objects that will be assigned to the loop variable
|
| + * The given expression is the expression used to compute the iterator for a
|
| + * for-each statement. Attempt to compute the type of objects that will be
|
| + * assigned to the loop variable and return that type. Return `null` if the
|
| + * type could not be determined. The [iteratorExpression] is the expression
|
| + * that will return the Iterable being iterated over.
|
| */
|
| DartType _getIteratorElementType(Expression iteratorExpression) {
|
| DartType expressionType = iteratorExpression.bestType;
|
| @@ -11127,6 +11202,40 @@ class ResolverVisitor extends ScopedVisitor {
|
| }
|
|
|
| /**
|
| + * The given expression is the expression used to compute the stream for an
|
| + * asyncronous for-each statement. Attempt to compute the type of objects that
|
| + * will be assigned to the loop variable and return that type. Return `null`
|
| + * if the type could not be determined. The [streamExpression] is the
|
| + * expression that will return the stream being iterated over.
|
| + */
|
| + DartType _getStreamElementType(Expression streamExpression) {
|
| + DartType streamType = streamExpression.bestType;
|
| + if (streamType is InterfaceType) {
|
| + FunctionType listenFunction =
|
| + _inheritanceManager.lookupMemberType(streamType, "listen");
|
| + if (listenFunction == null) {
|
| + return null;
|
| + }
|
| + List<ParameterElement> listenParameters = listenFunction.parameters;
|
| + if (listenParameters == null || listenParameters.length < 1) {
|
| + return null;
|
| + }
|
| + DartType onDataType = listenParameters[0].type;
|
| + if (onDataType is FunctionType) {
|
| + List<ParameterElement> onDataParameters = onDataType.parameters;
|
| + if (onDataParameters == null || onDataParameters.length < 1) {
|
| + return null;
|
| + }
|
| + DartType eventType = onDataParameters[0].type;
|
| + if (eventType.element == streamType.typeParameters[0]) {
|
| + return streamType.typeArguments[0];
|
| + }
|
| + }
|
| + }
|
| + return null;
|
| + }
|
| +
|
| + /**
|
| * If given "mayBeClosure" is [FunctionExpression] without explicit parameters types and its
|
| * required type is [FunctionType], then infer parameters types from [FunctionType].
|
| */
|
| @@ -11535,8 +11644,11 @@ 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(source, duplicate.nameOffset,
|
| - duplicate.displayName.length, CompileTimeErrorCode.DUPLICATE_DEFINITION,
|
| + return new AnalysisError(
|
| + source,
|
| + duplicate.nameOffset,
|
| + duplicate.displayName.length,
|
| + CompileTimeErrorCode.DUPLICATE_DEFINITION,
|
| [existing.displayName]);
|
| }
|
|
|
| @@ -13230,13 +13342,13 @@ class TypeProviderImpl implements TypeProvider {
|
|
|
| @override
|
| List<InterfaceType> get nonSubtypableTypes => <InterfaceType>[
|
| - nullType,
|
| - numType,
|
| - intType,
|
| - doubleType,
|
| - boolType,
|
| - stringType
|
| - ];
|
| + nullType,
|
| + numType,
|
| + intType,
|
| + doubleType,
|
| + boolType,
|
| + stringType
|
| + ];
|
|
|
| @override
|
| DartObjectImpl get nullObject {
|
| @@ -13367,7 +13479,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| TypeProvider typeProvider, AnalysisErrorListener errorListener,
|
| {Scope nameScope})
|
| : super(definingLibrary, source, typeProvider, errorListener,
|
| - nameScope: nameScope) {
|
| + nameScope: nameScope) {
|
| _dynamicType = typeProvider.dynamicType;
|
| _undefinedType = typeProvider.undefinedType;
|
| }
|
| @@ -13763,13 +13875,15 @@ 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,
|
| + reportErrorForNode(
|
| + StaticWarningCode.NEW_WITH_NON_TYPE,
|
| prefixedIdentifier.identifier,
|
| [prefixedIdentifier.identifier.name]);
|
| }
|
| @@ -13947,11 +14061,8 @@ 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;
|
| }
|
| @@ -14315,7 +14426,8 @@ 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);
|
| @@ -14327,7 +14439,8 @@ 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);
|
| @@ -14402,8 +14515,10 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| * @param dynamicTypeError the error to produce if the type name is "dynamic"
|
| * @return an array containing all of the types that were resolved.
|
| */
|
| - List<InterfaceType> _resolveTypes(NodeList<TypeName> typeNames,
|
| - ErrorCode nonTypeError, ErrorCode enumTypeError,
|
| + List<InterfaceType> _resolveTypes(
|
| + NodeList<TypeName> typeNames,
|
| + ErrorCode nonTypeError,
|
| + ErrorCode enumTypeError,
|
| ErrorCode dynamicTypeError) {
|
| List<InterfaceType> types = new List<InterfaceType>();
|
| for (TypeName typeName in typeNames) {
|
| @@ -14635,10 +14750,8 @@ class UnusedLocalElementsVerifier 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);
|
| }
|
| @@ -14655,10 +14768,8 @@ class UnusedLocalElementsVerifier 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);
|
| }
|
| @@ -14666,10 +14777,8 @@ class UnusedLocalElementsVerifier extends RecursiveElementVisitor {
|
| @override
|
| visitFunctionTypeAliasElement(FunctionTypeAliasElement 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.visitFunctionTypeAliasElement(element);
|
| }
|
| @@ -14692,10 +14801,8 @@ class UnusedLocalElementsVerifier extends RecursiveElementVisitor {
|
| @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);
|
| }
|
| @@ -14703,10 +14810,8 @@ class UnusedLocalElementsVerifier 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);
|
| }
|
| @@ -14766,8 +14871,11 @@ class UnusedLocalElementsVerifier extends RecursiveElementVisitor {
|
| void _reportErrorForElement(
|
| ErrorCode errorCode, Element element, List<Object> arguments) {
|
| if (element != null) {
|
| - _errorListener.onError(new AnalysisError(element.source,
|
| - element.nameOffset, element.displayName.length, errorCode,
|
| + _errorListener.onError(new AnalysisError(
|
| + element.source,
|
| + element.nameOffset,
|
| + element.displayName.length,
|
| + errorCode,
|
| arguments));
|
| }
|
| }
|
| @@ -14895,7 +15003,7 @@ class VariableResolverVisitor extends ScopedVisitor {
|
| TypeProvider typeProvider, AnalysisErrorListener errorListener,
|
| {Scope nameScope})
|
| : super(definingLibrary, source, typeProvider, errorListener,
|
| - nameScope: nameScope);
|
| + nameScope: nameScope);
|
|
|
| /**
|
| * Initialize a newly created visitor to resolve the nodes in a compilation unit.
|
| @@ -14910,8 +15018,8 @@ class VariableResolverVisitor extends ScopedVisitor {
|
| VariableResolverVisitor.con1(
|
| Library library, Source source, TypeProvider typeProvider)
|
| : this(
|
| - library.libraryElement, source, typeProvider, library.errorListener,
|
| - nameScope: library.libraryScope);
|
| + library.libraryElement, source, typeProvider, library.errorListener,
|
| + nameScope: library.libraryScope);
|
|
|
| @override
|
| Object visitExportDirective(ExportDirective node) => null;
|
| @@ -15020,11 +15128,14 @@ class _ConstantVerifier_validateInitializerExpression extends ConstantVisitor {
|
|
|
| List<ParameterElement> parameterElements;
|
|
|
| - _ConstantVerifier_validateInitializerExpression(TypeProvider typeProvider,
|
| - ErrorReporter errorReporter, this.verifier, this.parameterElements,
|
| + _ConstantVerifier_validateInitializerExpression(
|
| + TypeProvider typeProvider,
|
| + ErrorReporter errorReporter,
|
| + this.verifier,
|
| + this.parameterElements,
|
| DeclaredVariables declaredVariables)
|
| : super(new ConstantEvaluationEngine(typeProvider, declaredVariables),
|
| - errorReporter);
|
| + errorReporter);
|
|
|
| @override
|
| DartObjectImpl visitSimpleIdentifier(SimpleIdentifier node) {
|
|
|