Package lombok.ast

Examples of lombok.ast.Node


      List<org.parboiled.Node<Node>> operators,
      List<String> operatorTexts) {
   
    if (operators == null || operators.isEmpty()) return operand.getValue();
   
    Node current = operand.getValue();
    for (int i = operators.size() - 1; i >= 0; i--) {
      org.parboiled.Node<Node> operator = operators.get(i);
      Node prev = current;
      if (operator == null) continue;
      if (!operator.getChildren().isEmpty() && "cast".equals(operator.getChildren().get(0).getLabel())) {
        current = new Cast().rawOperand(current).rawTypeReference(operator.getValue());
      } else {
        String symbol = operatorTexts.get(i);
        if (symbol == null) continue;
        symbol = symbol.trim();
        if (symbol.isEmpty()) continue;
       
        UnaryOperator op = UnaryOperator.fromSymbol(symbol, false);
        UnaryExpression expr = new UnaryExpression().rawOperand(current);
        if (op != null) expr.astOperator(op);
        current = expr;
      }
     
      if (prev != null && !prev.getPosition().isUnplaced() && prev != current && current != null) {
        positionSpan(current, operator, operand);
      }
    }
   
    return current;
View Full Code Here


  }
 
  public Node createUnaryPostfixExpression(Node operand, List<org.parboiled.Node<Node>> nodes, List<String> operators) {
    if (operators == null) return operand;
   
    Node current = operand;
    for (int i = 0; i < operators.size(); i++) {
      String op = operators.get(i);
      if (op == null) continue;
      op = op.trim();
      Node prev = current;
      if (op.equals("++")) current = new UnaryExpression().rawOperand(current).astOperator(UnaryOperator.POSTFIX_INCREMENT);
      else if (op.equals("--")) current = new UnaryExpression().rawOperand(current).astOperator(UnaryOperator.POSTFIX_DECREMENT);
      org.parboiled.Node<Node> p = nodes.get(i);
      if (prev != null && !prev.getPosition().isUnplaced() && p != null) {
        current.setPosition(new Position(prev.getPosition().getStart(), p.getEndIndex()));
      }
    }
    return current;
  }
View Full Code Here

      org.parboiled.Node<Node> identifier, org.parboiled.Node<Node> classTypeArgs,
      Node methodArguments, Node classBody) {
   
    TypeReferencePart classTypeArgs0;
    boolean classTypeArgsCorrect = false;
    Node identifierNode = identifier == null ? null : identifier.getValue();
    if (classTypeArgs != null && classTypeArgs.getValue() instanceof TypeReferencePart) {
      classTypeArgs0 = (TypeReferencePart)classTypeArgs.getValue();
      classTypeArgsCorrect = true;
    } else {
      classTypeArgs0 = new TypeReferencePart();
      if (identifierNode != null) {
        classTypeArgs0.setPosition(identifierNode.getPosition());
      }
    }
   
    TypeReference typeReference = new TypeReference().astParts().addToEnd(
        classTypeArgs0.astIdentifier(createIdentifierIfNeeded(identifierNode, currentPos())));
View Full Code Here

  }
 
  public Node createChainOfQualifiedConstructorInvocations(
      org.parboiled.Node<Node> qualifier,
      List<org.parboiled.Node<Node>> constructorInvocations) {
    Node current = qualifier.getValue();
   
    if (constructorInvocations == null) return current;
   
    for (org.parboiled.Node<Node> pNode : constructorInvocations) {
      Node n = pNode.getValue();
      if (n instanceof ConstructorInvocation) {
        current = ((ConstructorInvocation)n).rawQualifier(current);
        positionSpan(current, qualifier, pNode);
      } else DanglingNodes.addDanglingNode(current, n);
    }
View Full Code Here

  public Node createArrayAccessOperation(Node indexExpression) {
    return posify(new ArrayAccess().rawIndexExpression(indexExpression));
  }
 
  public Node createLevel1Expression(org.parboiled.Node<Node> operand, List<org.parboiled.Node<Node>> operations) {
    Node current = operand.getValue();
    if (operations == null) return current;
   
    for (org.parboiled.Node<Node> pNode : operations) {
      Node o = pNode.getValue();
     
      if (o instanceof ArrayAccess) {
        current = ((ArrayAccess)o).rawOperand(current);
      } else if (o instanceof MethodInvocation) {
        current = ((MethodInvocation)o).rawOperand(current);
View Full Code Here

    }
    return v;
  }
 
  public Node createThisOrSuperOrClass(org.parboiled.Node<Node> dot, String text, Node qualifier) {
    Node result;
    if ("super".equals(text)) result = new Super().rawQualifier(qualifier);
    else if ("class".equals(text)) result = new ClassLiteral().rawTypeReference(qualifier);
    else result = new This().rawQualifier(qualifier);
    if (dot != null) source.registerStructure(result, dot);
    return posify(result);
View Full Code Here

        Object nativeNode = node.getNativeNode();
        if (nativeNode != null) {
            return nativeNode;
        }

        Node parent = node.getParent();
        // The ECJ native nodes are sometimes spotty; for example, for a
        // MethodInvocation node we can have a null native node, but its
        // parent expression statement will point to the real MessageSend node
        if (parent != null) {
            nativeNode = parent.getNativeNode();
            if (nativeNode != null) {
                return nativeNode;
            }
        }
View Full Code Here

        Object nativeNode = node.getNativeNode();
        if (nativeNode != null) {
            return nativeNode;
        }

        Node parent = node.getParent();
        // The ECJ native nodes are sometimes spotty; for example, for a
        // MethodInvocation node we can have a null native node, but its
        // parent expression statement will point to the real MessageSend node
        if (parent != null) {
            nativeNode = parent.getNativeNode();
            if (nativeNode != null) {
                return nativeNode;
            }
        }
View Full Code Here

   
    if (!source.getProblems().isEmpty()) {
      fail(source.getProblems().get(0).toString());
    }
   
    Node node = source.getNodes().get(0);
    PositionCheckingFormatter formatter = new PositionCheckingFormatter(source);
    node.accept(new SourcePrinter(formatter));
    List<AstException> problems = formatter.getProblems();
    try {
      if (!problems.isEmpty()) fail("position error: " + problems.get(0));
    } catch (AssertionError e) {
      System.out.println("-------PARSED-PRINTED:");
      StructureFormatter formatter2 = StructureFormatter.formatterWithPositions();
      node.accept(new SourcePrinter(formatter2));
      System.out.println(formatter2.finish());
      System.out.println("--------------PRINTED:");
      System.out.println(formatter.finish());
      System.out.println("----------------------");
      throw e;
View Full Code Here

    super.closeInline();
    checkNodeClose();
  }
 
  private void checkNodeClose() {
    Node node = nodeStack.pop();
    if (node == null) return;
    Position p = node.getPosition();
    if (p.isUnplaced()) return//opener already generated error.
    if (p.getStart() > p.getEnd()) problems.add(new AstException(node, "Node ends before it starts."));
    int delta = p.getEnd() - Math.max(getCurrentPosition(false), p.getStart());
    if (delta != 0) {
      int actualPos = getCurrentPosition(false);
View Full Code Here

TOP

Related Classes of lombok.ast.Node

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.