Package com.bacoder.parser.java.api

Examples of com.bacoder.parser.java.api.ForStatement


    return doWhileStatement;
  }

  protected ForStatement processForStatement(StatementContext context) {
    ForStatement forStatement = createNode(context, ForStatement.class);

    ForControlContext forControlContext = getChild(context, ForControlContext.class);
    if (forControlContext != null) {
      EnhancedForControlContext enhancedForControlContext =
          getChild(forControlContext, EnhancedForControlContext.class);
      if (enhancedForControlContext == null) {
        LoopControl loopControl = createNode(forControlContext, LoopControl.class);

        ForInitContext forInitContext = getChild(forControlContext, ForInitContext.class);
        if (forInitContext != null) {
          LocalVariableDeclarationContext localVariableDeclarationContext =
              getChild(forInitContext, LocalVariableDeclarationContext.class);
          if (localVariableDeclarationContext != null) {
            loopControl.setVariableDeclaration(
                getAdapter(LocalVariableDeclarationAdapter.class).adapt(
                    localVariableDeclarationContext));
          }

          ExpressionListContext expressionListContext =
              getChild(forControlContext, ExpressionListContext.class);
          if (expressionListContext != null) {
            loopControl.setInitExpressions(
                getAdapter(ExpressionListAdapter.class).adapt(expressionListContext));
          }
        }

        ExpressionContext expressionContext = getChild(forControlContext, ExpressionContext.class);
        if (expressionContext != null) {
          loopControl.setCondition(getAdapter(ExpressionAdapter.class).adapt(expressionContext));
        }

        ForUpdateContext forUpdateContext = getChild(forControlContext, ForUpdateContext.class);
        if (forUpdateContext != null) {
          ExpressionListContext expressionListContext =
              getChild(forUpdateContext, ExpressionListContext.class);
          if (expressionListContext != null) {
            loopControl.setUpdateExpressions(
                getAdapter(ExpressionListAdapter.class).adapt(expressionListContext));
          }
        }

        forStatement.setControl(loopControl);

      } else {
        ForEachControl forEachControl =
            createNode(enhancedForControlContext, ForEachControl.class);
        setModifiers(enhancedForControlContext, forEachControl);

        TypeContext typeContext = getChild(enhancedForControlContext, TypeContext.class);
        if (typeContext != null) {
          forEachControl.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
        }

        TerminalNode identifierNode =
            getTerminalNode(enhancedForControlContext, JavaParser.Identifier);
        if (identifierNode != null) {
          forEachControl.setVariable(getAdapter(IdentifierAdapter.class).adapt(identifierNode));
        }

        ExpressionContext expressionContext =
            getChild(enhancedForControlContext, ExpressionContext.class);
        if (expressionContext != null) {
          forEachControl.setIterable(
              getAdapter(ExpressionAdapter.class).adapt(expressionContext));
        }

        forStatement.setControl(forEachControl);
      }
    }

    StatementContext statementContext = getChild(context, StatementContext.class);
    if (statementContext != null) {
      forStatement.setStatement(getAdapter(StatementAdapter.class).adapt(statementContext));
    }

    return forStatement;
  }
View Full Code Here

TOP

Related Classes of com.bacoder.parser.java.api.ForStatement

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.