Package lombok.ast

Examples of lombok.ast.Block


  public StatementsActions(Source source) {
    super(source);
  }
 
  public Node createBlock(List<Node> statements) {
    Block block = new Block();
    if (statements != null) for (Node s : statements) {
      if (s != null) block.rawContents().addToEnd(s);
    }
   
    return posify(block);
  }
View Full Code Here


  public void unreachableAfterReturn(Return statement) {
    checkForUnreachables(statement);
  }
 
  private void checkForUnreachables(Statement n) {
    Block b = n.upToBlock();
    if (b == null) return;
   
    boolean found = false;
    for (Node s : b.rawContents()) {
      if (found) {
        s.addMessage(error(STATEMENT_UNREACHABLE, "Unreachable code"));
        return;
      }
      if (s == n) found = true;
View Full Code Here

  }
 
  private void checkChildOfSwitch(Statement node, String desc) {
    if (node.getParent() == null) return;
   
    Block p = node.upToBlock();
    Switch gp = p == null ? null : p.upToSwitch();
    boolean genError = false;
   
    genError = p == null;
    genError |= gp == null && p.getParent() != null;
   
    if (genError) {
      node.addMessage(error(STATEMENT_ONLY_LEGAL_IN_SWITCH, desc + " statements are only legal directly inside switch statements."));
    }
  }
View Full Code Here

      node.addMessage(error(STATEMENT_ONLY_LEGAL_IN_SWITCH, desc + " statements are only legal directly inside switch statements."));
    }
  }
 
  public void checkSwitchStartsWithDefaultOrCase(Switch node) {
    Block body = node.astBody();
    if (body != null) {
      Statement first = body.astContents().first();
      if (first != null && !(first instanceof Case) && !(first instanceof Default)) {
        node.addMessage(error(SWITCH_DOES_NOT_START_WITH_CASE, "switch statements should start with a default or case statement."));
      }
    }
  }
View Full Code Here

    constructorInvocationMustBeFirst(node, "this");
  }
 
  private void constructorInvocationMustBeFirst(Statement node, String desc) {
    if (node.getParent() == null) return;
    Block b = node.upToBlock();
    if (b == null || b.upToConstructorDeclaration() == null || b.astContents().first() != node) {
      node.addMessage(error(CONSTRUCTOR_INVOCATION_NOT_LEGAL_HERE, "Calling " + desc + " must be the first statement in a constructor."));
      return;
    }
  }
View Full Code Here

      set(node, m);
    }
   
    @Override public void visitBlock(JCBlock node) {
      Node n;
      Block b = new Block();
      fillList(node.stats, b.rawContents());
      setPos(node, b);
      if (hasFlag(FlagKey.BLOCKS_ARE_INITIALIZERS)) {
        if ((node.flags & Flags.STATIC) != 0) {
          n = setPos(node, new StaticInitializer().astBody(b));
        } else {
          // For some strange reason, solitary ; in a type body are represented not as JCSkips, but as JCBlocks with no endpos. Don't ask me why!
          if (b.rawContents().isEmpty() && node.endpos == -1) {
            n = setPos(node, new EmptyDeclaration());
          } else {
            n = setPos(node, new InstanceInitializer().astBody(b));
          }
        }
View Full Code Here

        f.rawUpdates().addToEnd(updateNode);
      }
      List<JCStatement> initializers = node.getInitializer();
      // Multiple vardefs in a row need to trigger the JCVD version AND be washed through fillList to be turned into 1 VD.
      if (!initializers.isEmpty() && initializers.get(0) instanceof JCVariableDecl) {
        Block tmp = new Block();
        fillList(initializers, tmp.rawContents(), FlagKey.VARDEF_IS_DEFINITION);
        Node varDecl = tmp.rawContents().first();
        if (varDecl != null) varDecl.unparent();
        f.rawVariableDeclaration(varDecl);
      } else {
        for (JCStatement init : initializers) {
          if (init instanceof JCExpressionStatement) {
View Full Code Here

    @Override public void visitSwitch(JCSwitch node) {
      Switch s = new Switch();
      JCExpression cond = node.getExpression();
      setConversionPositionInfo(s, "()", getPosition(cond));
      s.rawCondition(toTree(removeParens(cond)));
      Block b = new Block();
      s.astBody(b);
      for (JCCase c : node.getCases()) {
        JCExpression rawExpr = c.getExpression();
        if (rawExpr == null) b.rawContents().addToEnd(setPos(c, new Default()));
        else b.rawContents().addToEnd(setPos(c, new Case().rawCondition(toTree(rawExpr))));
        fillList(c.getStatements(), b.rawContents());
      }
      set(node, s);
    }
View Full Code Here

TOP

Related Classes of lombok.ast.Block

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.