Package com.google.dart.engine.ast

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


    if (!isDebugConstant(conditionExpression)) {
      ValidResult result = getConstantBooleanValue(conditionExpression);
      if (result != null) {
        if (result.isTrue()) {
          // report error on else block: if(true) {} else {!}
          Statement elseStatement = node.getElseStatement();
          if (elseStatement != null) {
            errorReporter.reportErrorForNode(HintCode.DEAD_CODE, elseStatement);
            safelyVisit(node.getThenStatement());
            return null;
          }
View Full Code Here


   * @param statements some ordered list of statements in a {@link Block} or {@link SwitchMember}
   */
  private void checkForDeadStatementsInNodeList(NodeList<Statement> statements) {
    int size = statements.size();
    for (int i = 0; i < size; i++) {
      Statement currentStatement = statements.get(i);
      safelyVisit(currentStatement);
      boolean returnOrBreakingStatement = currentStatement instanceof ReturnStatement
          || (currentStatement instanceof BreakStatement && ((BreakStatement) currentStatement).getLabel() == null)
          || (currentStatement instanceof ContinueStatement && ((ContinueStatement) currentStatement).getLabel() == null);
      if (returnOrBreakingStatement && i != size - 1) {
        Statement nextStatement = statements.get(i + 1);
        Statement lastStatement = statements.get(size - 1);
        int offset = nextStatement.getOffset();
        int length = lastStatement.getEnd() - offset;
        errorReporter.reportErrorForOffset(HintCode.DEAD_CODE, offset, length);
        return;
      }
    }
  }
View Full Code Here

  }

  @Override
  public Boolean visitIfStatement(IfStatement node) {
    Expression conditionExpression = node.getCondition();
    Statement thenStatement = node.getThenStatement();
    Statement elseStatement = node.getElseStatement();
    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 false;
        }
      }
      // no other switch member after this one
    } else {
      Statement statement = statements.get(statements.size() - 1);
      // terminated with statement
      if (statement instanceof BreakStatement || statement instanceof ContinueStatement
          || statement instanceof ReturnStatement) {
        return false;
      }
View Full Code Here

    // has type arguments
    if (node.getTypeArguments() != null) {
      return false;
    }
    // prepare statement
    Statement statement = node.getAncestor(ExpressionStatement.class);
    if (statement == null) {
      return false;
    }
    // OK, statement does not start with map
    if (statement.getBeginToken() != node.getBeginToken()) {
      return false;
    }
    // report problem
    errorReporter.reportErrorForNode(
        CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT,
View Full Code Here

  @Override
  public Void visitIfStatement(IfStatement node) {
    Expression condition = node.getCondition();
    safelyVisit(condition);
    Map<Element, Type> thenOverrides = null;
    Statement thenStatement = node.getThenStatement();
    if (thenStatement != null) {
      overrideManager.enterScope();
      try {
        promoteManager.enterScope();
        try {
          propagateTrueState(condition);
          // Type promotion.
          promoteTypes(condition);
          clearTypePromotionsIfPotentiallyMutatedIn(thenStatement);
          clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenStatement);
          // Visit "then".
          visitStatementInScope(thenStatement);
        } finally {
          promoteManager.exitScope();
        }
      } finally {
        thenOverrides = overrideManager.captureLocalOverrides();
        overrideManager.exitScope();
      }
    }
    Map<Element, Type> elseOverrides = null;
    Statement elseStatement = node.getElseStatement();
    if (elseStatement != null) {
      overrideManager.enterScope();
      try {
        propagateFalseState(condition);
        visitStatementInScope(elseStatement);
View Full Code Here

  @Override
  public Void visitWhileStatement(WhileStatement node) {
    Expression condition = node.getCondition();
    safelyVisit(condition);
    Statement body = node.getBody();
    if (body != null) {
      overrideManager.enterScope();
      try {
        propagateTrueState(condition);
        visitStatementInScope(body);
View Full Code Here

    safelyVisit(iterator);
    DeclaredIdentifier loopVariable = node.getLoopVariable();
    SimpleIdentifier identifier = node.getIdentifier();
    safelyVisit(loopVariable);
    safelyVisit(identifier);
    Statement body = node.getBody();
    if (body != null) {
      overrideManager.enterScope();
      try {
        if (loopVariable != null && iterator != null) {
          LocalVariableElement loopElement = loopVariable.getElement();
View Full Code Here

   */
  private void hideNamesDefinedInBlock(EnclosedScope scope, Block block) {
    NodeList<Statement> statements = block.getStatements();
    int statementCount = statements.size();
    for (int i = 0; i < statementCount; i++) {
      Statement statement = statements.get(i);
      if (statement instanceof VariableDeclarationStatement) {
        VariableDeclarationStatement vds = (VariableDeclarationStatement) statement;
        NodeList<VariableDeclaration> variables = vds.getVariables().getVariables();
        int variableCount = variables.size();
        for (int j = 0; j < variableCount; j++) {
View Full Code Here

TOP

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

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.