Package com.google.dart.engine.ast

Examples of com.google.dart.engine.ast.Expression


      }
    }
    // OK, remember the type
    if (parent instanceof AssignmentExpression) {
      AssignmentExpression assignment = (AssignmentExpression) parent;
      Expression rhs = assignment.getRightHandSide();
      location = getLocationWithExpressionType(location, rhs);
    }
    // done
    return location;
  }
View Full Code Here


    boolean isConst = node.getConstKeyword() != null;
    boolean reportEqualKeys = true;
    HashSet<DartObject> keys = new HashSet<DartObject>();
    ArrayList<Expression> invalidKeys = new ArrayList<Expression>();
    for (MapLiteralEntry entry : node.getEntries()) {
      Expression key = entry.getKey();
      if (isConst) {
        EvaluationResultImpl keyResult = validate(key, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY);
        Expression valueExpression = entry.getValue();
        EvaluationResultImpl valueResult = validate(
            valueExpression,
            CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE);
        if (valueResult instanceof ValidResult) {
          reportErrorIfFromDeferredLibrary(
View Full Code Here

    boolean foundError = false;
    Type firstType = null;
    for (SwitchMember switchMember : switchMembers) {
      if (switchMember instanceof SwitchCase) {
        SwitchCase switchCase = (SwitchCase) switchMember;
        Expression expression = switchCase.getExpression();
        EvaluationResultImpl caseResult = validate(
            expression,
            CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION);
        if (caseResult instanceof ValidResult) {
          reportErrorIfFromDeferredLibrary(
              expression,
              CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY);
          DartObject value = ((ValidResult) caseResult).getValue();
          if (firstType == null) {
            firstType = value.getType();
          } else {
            Type nType = value.getType();
            if (!firstType.equals(nType)) {
              errorReporter.reportErrorForNode(
                  CompileTimeErrorCode.INCONSISTENT_CASE_EXPRESSION_TYPES,
                  expression,
                  expression.toSource(),
                  firstType.getDisplayName());
              foundError = true;
            }
          }
        }
View Full Code Here

  }

  @Override
  public Void visitVariableDeclaration(VariableDeclaration node) {
    super.visitVariableDeclaration(node);
    Expression initializer = node.getInitializer();
    if (initializer != null && node.isConst()) {
      VariableElementImpl element = (VariableElementImpl) node.getElement();
      EvaluationResultImpl result = element.getEvaluationResult();
      if (result == null) {
        //
View Full Code Here

      return;
    }
    for (FormalParameter parameter : parameters.getParameters()) {
      if (parameter instanceof DefaultFormalParameter) {
        DefaultFormalParameter defaultParameter = (DefaultFormalParameter) parameter;
        Expression defaultValue = defaultParameter.getDefaultValue();
        if (defaultValue != null) {
          EvaluationResultImpl result = validate(
              defaultValue,
              CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE);
          VariableElementImpl element = (VariableElementImpl) parameter.getElement();
View Full Code Here

    for (ClassMember member : members) {
      if (member instanceof FieldDeclaration) {
        FieldDeclaration fieldDeclaration = (FieldDeclaration) member;
        if (!fieldDeclaration.isStatic()) {
          for (VariableDeclaration variableDeclaration : fieldDeclaration.getFields().getVariables()) {
            Expression initializer = variableDeclaration.getInitializer();
            if (initializer != null) {
              EvaluationResultImpl result = initializer.accept(new ConstantVisitor(typeProvider));
              if (!(result instanceof ValidResult)) {
                errorReporter.reportErrorForNode(
                    CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_FIELD_INITIALIZED_BY_NON_CONST,
                    errorSite,
                    variableDeclaration.getName().getName());
View Full Code Here

  }

  @Override
  public Void visitAssignmentExpression(AssignmentExpression node) {
    TokenType operatorType = node.getOperator().getType();
    Expression lhs = node.getLeftHandSide();
    Expression rhs = node.getRightHandSide();
    if (operatorType == TokenType.EQ) {
      checkForInvalidAssignment(lhs, rhs);
    } else {
      checkForInvalidCompoundAssignment(node, lhs, rhs);
      checkForArgumentTypeNotAssignableForArgument(rhs);
View Full Code Here

    }
  }

  @Override
  public Void visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
    Expression functionExpression = node.getFunction();
    Type expressionType = functionExpression.getStaticType();
    if (!isFunctionType(expressionType)) {
      errorReporter.reportErrorForNode(
          StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION,
          functionExpression);
    }
View Full Code Here

    }
  }

  @Override
  public Void visitMethodInvocation(MethodInvocation node) {
    Expression target = node.getRealTarget();
    SimpleIdentifier methodName = node.getMethodName();
    if (target != null) {
      ClassElement typeReference = ElementResolver.getTypeReference(target);
      checkForStaticAccessToInstanceMember(typeReference, methodName);
      checkForInstanceAccessToStaticMember(typeReference, methodName);
View Full Code Here

  }

  @Override
  public Void visitPrefixExpression(PrefixExpression node) {
    TokenType operatorType = node.getOperator().getType();
    Expression operand = node.getOperand();
    if (operatorType == TokenType.BANG) {
      checkForNonBoolNegationExpression(operand);
    } else if (operatorType.isIncrementOperator()) {
      checkForAssignmentToFinal(operand);
    }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.ast.Expression

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.