Search in sources :

Example 41 with Position

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

the class ASTParser method AnnotationTypeMemberDeclaration.

public final AnnotationMemberDeclaration AnnotationTypeMemberDeclaration(ModifierHolder modifier) {
    Type type;
    String name;
    Expression defaultVal = null;
    type = Type();
    jj_consume_token(IDENTIFIER);
    name = token.image;
    jj_consume_token(LPAREN);
    jj_consume_token(RPAREN);
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case _DEFAULT:
            {
                defaultVal = DefaultValue();
                break;
            }
        default:
            jj_la1[159] = jj_gen;
            ;
    }
    jj_consume_token(SEMICOLON);
    Position begin = modifier.begin.orIfInvalid(tokenBegin());
    return new AnnotationMemberDeclaration(range(begin, tokenEnd()), modifier.modifiers, modifier.annotations, type, name, defaultVal);
}
Also used : ArrayType(com.github.javaparser.ast.type.ArrayType) Position(com.github.javaparser.Position)

Example 42 with Position

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

the class ASTParser method MarkerAnnotation.

public final MarkerAnnotationExpr MarkerAnnotation() {
    NameExpr name;
    Position begin;
    jj_consume_token(AT);
    begin = tokenBegin();
    name = Name();
    return new MarkerAnnotationExpr(range(begin, tokenEnd()), name);
}
Also used : Position(com.github.javaparser.Position)

Example 43 with Position

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

the class ASTParser method EnumConstantDeclaration.

public final EnumConstantDeclaration EnumConstantDeclaration() {
    List<AnnotationExpr> annotations = null;
    AnnotationExpr ann;
    String name;
    List<Expression> args = null;
    List<BodyDeclaration<?>> classBody = null;
    Position begin = INVALID;
    label_8: while (true) {
        switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
            case AT:
                {
                    ;
                    break;
                }
            default:
                jj_la1[20] = jj_gen;
                break label_8;
        }
        ann = Annotation();
        annotations = add(annotations, ann);
        begin = begin.orIfInvalid(ann.getBegin());
    }
    jj_consume_token(IDENTIFIER);
    name = token.image;
    begin = begin.orIfInvalid(tokenBegin());
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case LPAREN:
            {
                args = Arguments();
                break;
            }
        default:
            jj_la1[21] = jj_gen;
            ;
    }
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case LBRACE:
            {
                classBody = ClassOrInterfaceBody(false);
                break;
            }
        default:
            jj_la1[22] = jj_gen;
            ;
    }
    return new EnumConstantDeclaration(range(begin, tokenEnd()), annotations, name, args, classBody);
}
Also used : Position(com.github.javaparser.Position)

Example 44 with Position

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

the class ASTParser method ImportDeclaration.

public final ImportDeclaration ImportDeclaration() {
    NameExpr name;
    boolean isStatic = false;
    boolean isAsterisk = false;
    Position begin;
    jj_consume_token(IMPORT);
    begin = tokenBegin();
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case STATIC:
            {
                jj_consume_token(STATIC);
                isStatic = true;
                break;
            }
        default:
            jj_la1[4] = jj_gen;
            ;
    }
    name = Name();
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case DOT:
            {
                jj_consume_token(DOT);
                jj_consume_token(STAR);
                isAsterisk = true;
                break;
            }
        default:
            jj_la1[5] = jj_gen;
            ;
    }
    jj_consume_token(SEMICOLON);
    return new ImportDeclaration(range(begin, tokenEnd()), name, isStatic, isAsterisk);
}
Also used : Position(com.github.javaparser.Position)

Example 45 with Position

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

the class ASTParser method Wildcard.

public final WildcardType Wildcard() {
    ReferenceType ext = null;
    ReferenceType sup = null;
    Position begin;
    List<AnnotationExpr> annotations = null;
    jj_consume_token(HOOK);
    begin = tokenBegin();
    switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
        case EXTENDS:
        case SUPER:
            {
                switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
                    case EXTENDS:
                        {
                            jj_consume_token(EXTENDS);
                            annotations = Annotations();
                            ext = ReferenceType();
                            ext.setAnnotations(annotations);
                            break;
                        }
                    case SUPER:
                        {
                            jj_consume_token(SUPER);
                            annotations = Annotations();
                            sup = ReferenceType();
                            sup.setAnnotations(annotations);
                            break;
                        }
                    default:
                        jj_la1[61] = jj_gen;
                        jj_consume_token(-1);
                        throw new ParseException();
                }
                break;
            }
        default:
            jj_la1[62] = jj_gen;
            ;
    }
    return new WildcardType(range(begin, tokenEnd()), ext, sup);
}
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