Package com.google.dart.engine.error

Examples of com.google.dart.engine.error.ErrorCode


      this.listener = listener;
    }

    @Override
    public void onError(AnalysisError error) {
      ErrorCode errorCode = error.getErrorCode();
      if (errorCode == StaticWarningCode.UNDEFINED_GETTER
          || errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER
          || errorCode == StaticTypeWarningCode.UNDEFINED_GETTER) {
        return;
      }
View Full Code Here


    int highlightingEnd = message.getOffset() + message.getLength();
    if (highlightingEnd > fileTextLength) highlightingEnd = fileTextLength;
    if (highlightingStart >= highlightingEnd) highlightingStart = highlightingEnd - 1;

    final TextRange textRange = new TextRange(highlightingStart, highlightingEnd);
    final ErrorCode errorCode = message.getErrorCode();

    switch (errorCode.getErrorSeverity()) {
      case NONE:
        return null;
      case INFO:
        final Annotation annotation = holder.createWeakWarningAnnotation(textRange, message.getMessage());
        if (errorCode == HintCode.UNUSED_IMPORT || errorCode == HintCode.DUPLICATE_IMPORT) {
View Full Code Here

   * @param errorCode the error code to be used if the result represents an error
   */
  private void reportErrors(EvaluationResultImpl result, ErrorCode errorCode) {
    if (result instanceof ErrorResult) {
      for (ErrorResult.ErrorData data : ((ErrorResult) result).getErrorData()) {
        ErrorCode dataErrorCode = data.getErrorCode();
        if (dataErrorCode == CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION
            || dataErrorCode == CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE
            || dataErrorCode == CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING
            || dataErrorCode == CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL
            || dataErrorCode == CompileTimeErrorCode.CONST_EVAL_TYPE_INT
View Full Code Here

        //
        String constructorStrName = constructorTypeName.getName().getName();
        if (redirectedConstructor.getName() != null) {
          constructorStrName += '.' + redirectedConstructor.getName().getName();
        }
        ErrorCode errorCode = node.getConstKeyword() != null
            ? CompileTimeErrorCode.REDIRECT_TO_MISSING_CONSTRUCTOR
            : StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUCTOR;
        errorReporter.reportErrorForNode(
            errorCode,
            redirectedConstructor,
View Full Code Here

    if (typeNames.size() < 1) {
      return false;
    }
    Type listElementType = typeNames.get(0).getType();
    // Prepare problem to report.
    ErrorCode errorCode;
    if (node.getConstKeyword() != null) {
      errorCode = CompileTimeErrorCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE;
    } else {
      errorCode = StaticWarningCode.LIST_ELEMENT_TYPE_NOT_ASSIGNABLE;
    }
View Full Code Here

      return false;
    }
    Type keyType = typeNames.get(0).getType();
    Type valueType = typeNames.get(1).getType();
    // Prepare problem to report.
    ErrorCode keyErrorCode;
    ErrorCode valueErrorCode;
    if (node.getConstKeyword() != null) {
      keyErrorCode = CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE;
      valueErrorCode = CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE;
    } else {
      keyErrorCode = StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE;
View Full Code Here

      if (argType != null && boundType != null) {
        if (typeArguments.length != 0 && typeArguments.length == typeParameters.length) {
          boundType = boundType.substitute(typeArguments, typeParameters);
        }
        if (!argType.isSubtypeOf(boundType)) {
          ErrorCode errorCode;
          if (isInConstInstanceCreation) {
            errorCode = CompileTimeErrorCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS;
          } else {
            errorCode = StaticTypeWarningCode.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS;
          }
View Full Code Here

      }
    }
    //
    // Then check for error conditions.
    //
    ErrorCode errorCode = checkForInvocationError(target, true, staticElement);
    boolean generatedWithTypePropagation = false;
    if (enableHints && errorCode == null && staticElement == null) {
      // The method lookup may have failed because there were multiple
      // incompatible choices. In this case we don't want to generate a hint.
      if (propagatedElement == null && propagatedType instanceof UnionType) {
        // TODO(collinsn): an improvement here is to make the propagated type of the method call
        // the union of the propagated types of all possible calls.
        if (lookupMethods(target, (UnionType) propagatedType, methodName.getName()).size() > 1) {
          return null;
        }
      }

      errorCode = checkForInvocationError(target, false, propagatedElement);
      if (errorCode == StaticTypeWarningCode.UNDEFINED_METHOD) {
        ClassElement classElementContext = null;
        if (target == null) {
          classElementContext = resolver.getEnclosingClass();
        } else {
          Type type = target.getBestType();
          if (type != null) {
            if (type.getElement() instanceof ClassElement) {
              classElementContext = (ClassElement) type.getElement();
            }
          }
        }
        if (classElementContext != null) {
          subtypeManager.ensureLibraryVisited(definingLibrary);
          HashSet<ClassElement> subtypeElements = subtypeManager.computeAllSubtypes(classElementContext);
          for (ClassElement subtypeElement : subtypeElements) {
            if (subtypeElement.getMethod(methodName.getName()) != null) {
              errorCode = null;
            }
          }
        }
      }
      generatedWithTypePropagation = true;
    }
    if (errorCode == null) {
      return null;
    }
    if (errorCode == StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION) {
      resolver.reportErrorForNode(
          StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION,
          methodName,
          methodName.getName());
    } else if (errorCode == StaticTypeWarningCode.UNDEFINED_FUNCTION) {
      resolver.reportErrorForNode(
          StaticTypeWarningCode.UNDEFINED_FUNCTION,
          methodName,
          methodName.getName());
    } else if (errorCode == StaticTypeWarningCode.UNDEFINED_METHOD) {
      String targetTypeName;
      if (target == null) {
        ClassElement enclosingClass = resolver.getEnclosingClass();
        targetTypeName = enclosingClass.getDisplayName();
        ErrorCode proxyErrorCode = generatedWithTypePropagation ? HintCode.UNDEFINED_METHOD
            : StaticTypeWarningCode.UNDEFINED_METHOD;
        if (doesntHaveProxy(resolver.getEnclosingClass())) {
          resolver.reportErrorForNode(
              proxyErrorCode,
              methodName,
              methodName.getName(),
              targetTypeName);
        }

      } else {
        // ignore Function "call"
        // (if we are about to create a hint using type propagation, then we can use type
        // propagation here as well)
        Type targetType = null;
        if (!generatedWithTypePropagation) {
          targetType = getStaticType(target);
        } else {
          // choose the best type
          targetType = getPropagatedType(target);
          if (targetType == null) {
            targetType = getStaticType(target);
          }
        }
        if (targetType != null && targetType.isDartCoreFunction()
            && methodName.getName().equals(FunctionElement.CALL_METHOD_NAME)) {
          // TODO(brianwilkerson) Can we ever resolve the function being invoked?
          //resolveArgumentsToParameters(node.getArgumentList(), invokedFunction);
          return null;
        }
        targetTypeName = targetType == null ? null : targetType.getDisplayName();
        ErrorCode proxyErrorCode = generatedWithTypePropagation ? HintCode.UNDEFINED_METHOD
            : StaticTypeWarningCode.UNDEFINED_METHOD;
        if (doesntHaveProxy(targetType.getElement())) {
          resolver.reportErrorForNode(
              proxyErrorCode,
              methodName,
View Full Code Here

        && !memberFoundInSubclass(propagatedType.getElement(), methodName, true, false);

    if (shouldReportMissingMember_static || shouldReportMissingMember_propagated) {
      Token leftBracket = node.getLeftBracket();
      Token rightBracket = node.getRightBracket();
      ErrorCode errorCode = shouldReportMissingMember_static
          ? StaticTypeWarningCode.UNDEFINED_OPERATOR : HintCode.UNDEFINED_OPERATOR;
      if (leftBracket == null || rightBracket == null) {
        if (doesntHaveProxy(shouldReportMissingMember_static ? staticType.getElement()
            : propagatedType.getElement())) {
          resolver.reportErrorForNode(errorCode, node, methodName, shouldReportMissingMember_static
View Full Code Here

      if (argument instanceof NamedExpression) {
        SimpleIdentifier nameNode = ((NamedExpression) argument).getName().getLabel();
        String name = nameNode.getName();
        ParameterElement element = namedParameters.get(name);
        if (element == null) {
          ErrorCode errorCode = reportError ? CompileTimeErrorCode.UNDEFINED_NAMED_PARAMETER
              : StaticWarningCode.UNDEFINED_NAMED_PARAMETER;
          resolver.reportErrorForNode(errorCode, nameNode, name);
        } else {
          resolvedParameters[i] = element;
          nameNode.setStaticElement(element);
        }
        if (!usedNames.add(name)) {
          resolver.reportErrorForNode(CompileTimeErrorCode.DUPLICATE_NAMED_ARGUMENT, nameNode, name);
        }
      } else {
        if (argument instanceof SimpleIdentifier
            && ((SimpleIdentifier) argument).getName().isEmpty()) {
          noBlankArguments = false;
        }
        positionalArgumentCount++;
        if (unnamedIndex < unnamedParameterCount) {
          resolvedParameters[i] = unnamedParameters.get(unnamedIndex++);
        }
      }
    }
    if (positionalArgumentCount < requiredParameters.size() && noBlankArguments) {
      ErrorCode errorCode = reportError ? CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS
          : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS;
      resolver.reportErrorForNode(
          errorCode,
          argumentList,
          requiredParameters.size(),
          positionalArgumentCount);
    } else if (positionalArgumentCount > unnamedParameterCount && noBlankArguments) {
      ErrorCode errorCode = reportError ? CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS
          : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS;
      resolver.reportErrorForNode(
          errorCode,
          argumentList,
          unnamedParameterCount,
View Full Code Here

TOP

Related Classes of com.google.dart.engine.error.ErrorCode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.