Search in sources :

Example 26 with Position

use of com.github.javaparser.Position in project javaparser by javaparser.

the class ASTParser method NormalAnnotation.

public final NormalAnnotationExpr NormalAnnotation() {
    NameExpr name;
    List<MemberValuePair> pairs = null;
    Position begin;
    jj_consume_token(AT);
    begin = tokenBegin();
    name = Name();
    jj_consume_token(LPAREN);
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case IDENTIFIER:
            {
                pairs = MemberValuePairs();
                break;
            }
        default:
            jj_la1[151] = jj_gen;
            ;
    }
    jj_consume_token(RPAREN);
    return new NormalAnnotationExpr(range(begin, tokenEnd()), name, pairs);
}
Also used : Position(com.github.javaparser.Position)

Example 27 with Position

use of com.github.javaparser.Position in project javaparser by javaparser.

the class ASTParser method ContinueStatement.

public final ContinueStmt ContinueStatement() {
    String id = null;
    Position begin;
    jj_consume_token(CONTINUE);
    begin = tokenBegin();
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case IDENTIFIER:
            {
                jj_consume_token(IDENTIFIER);
                id = token.image;
                break;
            }
        default:
            jj_la1[143] = jj_gen;
            ;
    }
    jj_consume_token(SEMICOLON);
    return new ContinueStmt(range(begin, tokenEnd()), id);
}
Also used : Position(com.github.javaparser.Position)

Example 28 with Position

use of com.github.javaparser.Position in project javaparser by javaparser.

the class PrettyPrintVisitor method printArguments.

private void printArguments(final NodeList<Expression> args, final Void arg) {
    printer.print("(");
    Position cursorRef = printer.getCursor();
    if (!isNullOrEmpty(args)) {
        for (final Iterator<Expression> i = args.iterator(); i.hasNext(); ) {
            final Expression e = i.next();
            e.accept(this, arg);
            if (i.hasNext()) {
                printer.print(",");
                if (configuration.isColumnAlignParameters()) {
                    printer.wrapToColumn(cursorRef.column);
                } else {
                    printer.print(" ");
                }
            }
        }
    }
    printer.print(")");
}
Also used : PositionUtils.sortByBeginPosition(com.github.javaparser.utils.PositionUtils.sortByBeginPosition) Position(com.github.javaparser.Position)

Example 29 with Position

use of com.github.javaparser.Position in project javaparser by javaparser.

the class ASTParser method WhileStatement.

public final WhileStmt WhileStatement() {
    Expression condition;
    Statement body;
    Position begin;
    jj_consume_token(WHILE);
    begin = tokenBegin();
    jj_consume_token(LPAREN);
    condition = Expression();
    jj_consume_token(RPAREN);
    body = Statement();
    return new WhileStmt(range(begin, tokenEnd()), condition, body);
}
Also used : Position(com.github.javaparser.Position)

Example 30 with Position

use of com.github.javaparser.Position in project javaparser by javaparser.

the class ASTParser method PreDecrementExpression.

public final Expression PreDecrementExpression() {
    Expression ret;
    Position begin;
    jj_consume_token(DECR);
    begin = tokenBegin();
    ret = UnaryExpression();
    ret = new UnaryExpr(range(begin, tokenEnd()), ret, UnaryExpr.Operator.preDecrement);
    return ret;
}
Also used : Position(com.github.javaparser.Position)

Aggregations

Position (com.github.javaparser.Position)56 ArrayType (com.github.javaparser.ast.type.ArrayType)10 SimpleName (com.github.javaparser.ast.expr.SimpleName)2 CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 BodyDeclaration (com.github.javaparser.ast.body.BodyDeclaration)1 ConstructorDeclaration (com.github.javaparser.ast.body.ConstructorDeclaration)1 FieldDeclaration (com.github.javaparser.ast.body.FieldDeclaration)1 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 Parameter (com.github.javaparser.ast.body.Parameter)1 TypeDeclaration (com.github.javaparser.ast.body.TypeDeclaration)1 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)1 PositionUtils.sortByBeginPosition (com.github.javaparser.utils.PositionUtils.sortByBeginPosition)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1