Package com.bacoder.parser.java.api

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


    return returnStatement;
  }

  protected SwitchStatement processSwitchStatement(StatementContext context) {
    SwitchStatement switchStatement = createNode(context, SwitchStatement.class);

    ParExpressionContext parExpressionContext = getChild(context, ParExpressionContext.class);
    switchStatement.setExpression(processParExpression(parExpressionContext));

    List<SwitchBlock> switchBlocks = transform(context, SwitchBlockStatementGroupContext.class,
        new Function<SwitchBlockStatementGroupContext, SwitchBlock>() {
          @Override
          public SwitchBlock apply(SwitchBlockStatementGroupContext context) {
            SwitchBlock switchBlock = createNode(context, SwitchBlock.class);
            switchBlock.setLabels(getSwitchLabels(context));
            switchBlock.setStatements(transform(context, BlockStatementContext.class,
                new Function<BlockStatementContext, BlockStatement>() {
                  @Override
                  public BlockStatement apply(BlockStatementContext context) {
                    return getAdapter(BlockStatementAdapter.class).adapt(context);
                  }
                }));
            return switchBlock;
          }
        });

    List<SwitchLabel> extraSwitchLabels = getSwitchLabels(context);
    if (!extraSwitchLabels.isEmpty()) {
      List<SwitchLabelContext> switchLabelContexts = getChildren(context, SwitchLabelContext.class);
      SwitchBlock extraSwitchBlock =
          createNode(switchLabelContexts.get(0),
              switchLabelContexts.get(switchLabelContexts.size() - 1), SwitchBlock.class);
      extraSwitchBlock.setLabels(extraSwitchLabels);
      switchBlocks.add(extraSwitchBlock);
    }

    switchStatement.setSwitchBlocks(switchBlocks);

    return switchStatement;
  }
View Full Code Here

TOP

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

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.