Package com.google.dart.engine.ast

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


  public Void visitBinaryExpression(BinaryExpression node) {
    Token operator = node.getOperator();
    boolean isAmpAmp = operator.getType() == TokenType.AMPERSAND_AMPERSAND;
    boolean isBarBar = operator.getType() == TokenType.BAR_BAR;
    if (isAmpAmp || isBarBar) {
      Expression lhsCondition = node.getLeftOperand();
      if (!isDebugConstant(lhsCondition)) {
        ValidResult lhsResult = getConstantBooleanValue(lhsCondition);
        if (lhsResult != null) {
          if (lhsResult.isTrue() && isBarBar) {
            // report error on else block: true || !e!
View Full Code Here


    return null;
  }

  @Override
  public Void visitConditionalExpression(ConditionalExpression node) {
    Expression conditionExpression = node.getCondition();
    safelyVisit(conditionExpression);
    if (!isDebugConstant(conditionExpression)) {
      ValidResult result = getConstantBooleanValue(conditionExpression);
      if (result != null) {
        if (result.isTrue()) {
View Full Code Here

    return super.visitConditionalExpression(node);
  }

  @Override
  public Void visitIfStatement(IfStatement node) {
    Expression conditionExpression = node.getCondition();
    safelyVisit(conditionExpression);
    if (!isDebugConstant(conditionExpression)) {
      ValidResult result = getConstantBooleanValue(conditionExpression);
      if (result != null) {
        if (result.isTrue()) {
View Full Code Here

    return null;
  }

  @Override
  public Void visitWhileStatement(WhileStatement node) {
    Expression conditionExpression = node.getCondition();
    safelyVisit(conditionExpression);
    if (!isDebugConstant(conditionExpression)) {
      ValidResult result = getConstantBooleanValue(conditionExpression);
      if (result != null) {
        if (result.isFalse()) {
View Full Code Here

    return parseAngularExpressionInToken(token);
  }

  AngularExpression parseAngularExpressionInToken(Token token) {
    List<Token> tokens = splitAtBar(token);
    Expression mainExpression = parseDartExpressionInToken(tokens.get(0));
    // parse formatters
    List<AngularFormatterNode> formatters = Lists.newArrayList();
    for (int i = 1; i < tokens.size(); i++) {
      Token formatterToken = tokens.get(i);
      Token barToken = formatterToken;
      formatterToken = formatterToken.getNext();
      // parse name
      Expression nameExpression = parseDartExpressionInToken(formatterToken);
      if (!(nameExpression instanceof SimpleIdentifier)) {
        reportErrorForNode(AngularCode.INVALID_FORMATTER_NAME, nameExpression);
        continue;
      }
      SimpleIdentifier name = (SimpleIdentifier) nameExpression;
      formatterToken = name.getEndToken().getNext();
      // parse arguments
      List<AngularFormatterArgument> arguments = Lists.newArrayList();
      while (formatterToken.getType() != TokenType.EOF) {
        // skip ":"
        Token colonToken = formatterToken;
        if (colonToken.getType() == TokenType.COLON) {
          formatterToken = formatterToken.getNext();
        } else {
          reportErrorForToken(AngularCode.MISSING_FORMATTER_COLON, colonToken);
        }
        // parse argument
        Expression argument = parseDartExpressionInToken(formatterToken);
        arguments.add(new AngularFormatterArgument(colonToken, argument));
        // next token
        formatterToken = argument.getEndToken().getNext();
      }
      formatters.add(new AngularFormatterNode(barToken, name, arguments));
    }
    // done
    return new AngularExpression(mainExpression, formatters);
View Full Code Here

    parameter.setConst(node.isConst());
    parameter.setFinal(node.isFinal());
    parameter.setParameterKind(node.getKind());

    // set initializer, default value range
    Expression defaultValue = node.getDefaultValue();
    if (defaultValue != null) {
      visit(holder, defaultValue);

      FunctionElementImpl initializer = new FunctionElementImpl(
          defaultValue.getBeginToken().getOffset());
      initializer.setFunctions(holder.getFunctions());
      initializer.setLabels(holder.getLabels());
      initializer.setLocalVariables(holder.getLocalVariables());
      initializer.setParameters(holder.getParameters());
      initializer.setSynthetic(true);

      parameter.setInitializer(initializer);
      parameter.setDefaultValueCode(defaultValue.toSource());
    }

    // visible range
    setParameterVisibleRange(node, parameter);
View Full Code Here

    return nodeExits(node.getLeftHandSide()) || nodeExits(node.getRightHandSide());
  }

  @Override
  public Boolean visitBinaryExpression(BinaryExpression node) {
    Expression lhsExpression = node.getLeftOperand();
    TokenType operatorType = node.getOperator().getType();
    // If the operator is || and the left hand side is false literal, don't consider the RHS of the
    // binary expression.
    // TODO(jwren) Do we want to take constant expressions into account, evaluate if(false) {}
    // differently than if(<condition>), when <condition> evaluates to a constant false value?
    if (operatorType == TokenType.BAR_BAR) {
      if (lhsExpression instanceof BooleanLiteral) {
        BooleanLiteral booleanLiteral = (BooleanLiteral) lhsExpression;
        if (!booleanLiteral.getValue()) {
          return false;
        }
      }
    }
    // If the operator is && and the left hand side is true literal, don't consider the RHS of the
    // binary expression.
    if (operatorType == TokenType.AMPERSAND_AMPERSAND) {
      if (lhsExpression instanceof BooleanLiteral) {
        BooleanLiteral booleanLiteral = (BooleanLiteral) lhsExpression;
        if (booleanLiteral.getValue()) {
          return false;
        }
      }
    }
    Expression rhsExpression = node.getRightOperand();
    return nodeExits(lhsExpression) || nodeExits(rhsExpression);
  }
View Full Code Here

    return nodeExits(node.getTarget()) || visitExpressions(node.getCascadeSections());
  }

  @Override
  public Boolean visitConditionalExpression(ConditionalExpression node) {
    Expression conditionExpression = node.getCondition();
    Expression thenStatement = node.getThenExpression();
    Expression elseStatement = node.getElseExpression();
    // TODO(jwren) Do we want to take constant expressions into account, evaluate if(false) {}
    // differently than if(<condition>), when <condition> evaluates to a constant false value?
    if (nodeExits(conditionExpression)) {
      return true;
    }
    if (thenStatement == null || elseStatement == null) {
      return false;
    }
    return thenStatement.accept(this) && elseStatement.accept(this);
  }
View Full Code Here

  @Override
  public Boolean visitDoStatement(DoStatement node) {
    boolean outerBreakValue = enclosingBlockContainsBreak;
    enclosingBlockContainsBreak = false;
    try {
      Expression conditionExpression = node.getCondition();
      if (nodeExits(conditionExpression)) {
        return true;
      }
      // TODO(jwren) Do we want to take all constant expressions into account?
      if (conditionExpression instanceof BooleanLiteral) {
View Full Code Here

        return true;
      }
      if (node.getInitialization() != null && nodeExits(node.getInitialization())) {
        return true;
      }
      Expression conditionExpression = node.getCondition();
      if (conditionExpression != null && nodeExits(conditionExpression)) {
        return true;
      }
      if (visitExpressions(node.getUpdaters())) {
        return true;
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.