Search in sources :

Example 1 with LongLiteral

use of org.eclipse.jdt.internal.compiler.ast.LongLiteral in project lombok by rzwitserloot.

the class EclipseHandlerUtil method copyAnnotationMemberValue0.

private static Expression copyAnnotationMemberValue0(Expression in) {
    int s = in.sourceStart, e = in.sourceEnd;
    if (in instanceof FalseLiteral)
        return new FalseLiteral(s, e);
    if (in instanceof TrueLiteral)
        return new TrueLiteral(s, e);
    if (in instanceof NullLiteral)
        return new NullLiteral(s, e);
    if (in instanceof CharLiteral)
        return new CharLiteral(((Literal) in).source(), s, e);
    if (in instanceof DoubleLiteral)
        return new DoubleLiteral(((Literal) in).source(), s, e);
    if (in instanceof FloatLiteral)
        return new FloatLiteral(((Literal) in).source(), s, e);
    if (in instanceof IntLiteral)
        return IntLiteral.buildIntLiteral(((Literal) in).source(), s, e);
    if (in instanceof LongLiteral)
        return LongLiteral.buildLongLiteral(((Literal) in).source(), s, e);
    if (in instanceof StringLiteral)
        return new StringLiteral(((Literal) in).source(), s, e, reflectInt(STRING_LITERAL__LINE_NUMBER, in) + 1);
    if (in instanceof ExtendedStringLiteral) {
        StringLiteral str = new StringLiteral(((Literal) in).source(), s, e, reflectInt(STRING_LITERAL__LINE_NUMBER, in) + 1);
        StringLiteral empty = new StringLiteral(new char[0], s, e, reflectInt(STRING_LITERAL__LINE_NUMBER, in) + 1);
        return new ExtendedStringLiteral(str, empty);
    }
    if (in instanceof StringLiteralConcatenation) {
        Expression[] literals = ((StringLiteralConcatenation) in).literals;
        // 0 and 1 len shouldn't happen.
        if (literals.length == 0)
            return new StringLiteral(new char[0], s, e, 0);
        if (literals.length == 1)
            return copyAnnotationMemberValue0(literals[0]);
        StringLiteralConcatenation c = new StringLiteralConcatenation((StringLiteral) literals[0], (StringLiteral) literals[1]);
        for (int i = 2; i < literals.length; i++) c = c.extendsWith((StringLiteral) literals[i]);
        return c;
    }
    if (in instanceof SingleNameReference) {
        SingleNameReference snr = (SingleNameReference) in;
        return new SingleNameReference(snr.token, pos(in));
    }
    if (in instanceof QualifiedNameReference) {
        QualifiedNameReference qnr = (QualifiedNameReference) in;
        return new QualifiedNameReference(qnr.tokens, poss(in, qnr.tokens.length), s, e);
    }
    // class refs
    if (in instanceof ClassLiteralAccess)
        return new ClassLiteralAccess(e, copyType(((ClassLiteralAccess) in).type));
    // arrays
    if (in instanceof ArrayInitializer) {
        ArrayInitializer out = new ArrayInitializer();
        out.sourceStart = s;
        out.sourceEnd = e;
        out.bits = in.bits;
        out.implicitConversion = in.implicitConversion;
        out.statementEnd = e;
        Expression[] exprs = ((ArrayInitializer) in).expressions;
        if (exprs != null) {
            Expression[] copy = new Expression[exprs.length];
            for (int i = 0; i < exprs.length; i++) copy[i] = copyAnnotationMemberValue(exprs[i]);
            out.expressions = copy;
        }
        return out;
    }
    if (in instanceof BinaryExpression) {
        BinaryExpression be = (BinaryExpression) in;
        BinaryExpression out = new BinaryExpression(be);
        out.left = copyAnnotationMemberValue(be.left);
        out.right = copyAnnotationMemberValue(be.right);
        out.sourceStart = s;
        out.sourceEnd = e;
        out.statementEnd = e;
        return out;
    }
    return in;
}
Also used : CharLiteral(org.eclipse.jdt.internal.compiler.ast.CharLiteral) LongLiteral(org.eclipse.jdt.internal.compiler.ast.LongLiteral) FloatLiteral(org.eclipse.jdt.internal.compiler.ast.FloatLiteral) ExtendedStringLiteral(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) SingleNameReference(org.eclipse.jdt.internal.compiler.ast.SingleNameReference) FalseLiteral(org.eclipse.jdt.internal.compiler.ast.FalseLiteral) TrueLiteral(org.eclipse.jdt.internal.compiler.ast.TrueLiteral) StringLiteral(org.eclipse.jdt.internal.compiler.ast.StringLiteral) ExtendedStringLiteral(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) BinaryExpression(org.eclipse.jdt.internal.compiler.ast.BinaryExpression) BinaryExpression(org.eclipse.jdt.internal.compiler.ast.BinaryExpression) AllocationExpression(org.eclipse.jdt.internal.compiler.ast.AllocationExpression) EqualExpression(org.eclipse.jdt.internal.compiler.ast.EqualExpression) CastExpression(org.eclipse.jdt.internal.compiler.ast.CastExpression) Expression(org.eclipse.jdt.internal.compiler.ast.Expression) FalseLiteral(org.eclipse.jdt.internal.compiler.ast.FalseLiteral) IntLiteral(org.eclipse.jdt.internal.compiler.ast.IntLiteral) CharLiteral(org.eclipse.jdt.internal.compiler.ast.CharLiteral) StringLiteral(org.eclipse.jdt.internal.compiler.ast.StringLiteral) LongLiteral(org.eclipse.jdt.internal.compiler.ast.LongLiteral) ExtendedStringLiteral(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) TrueLiteral(org.eclipse.jdt.internal.compiler.ast.TrueLiteral) FloatLiteral(org.eclipse.jdt.internal.compiler.ast.FloatLiteral) NullLiteral(org.eclipse.jdt.internal.compiler.ast.NullLiteral) Literal(org.eclipse.jdt.internal.compiler.ast.Literal) DoubleLiteral(org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) IntLiteral(org.eclipse.jdt.internal.compiler.ast.IntLiteral) DoubleLiteral(org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) NullLiteral(org.eclipse.jdt.internal.compiler.ast.NullLiteral) StringLiteralConcatenation(org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation) QualifiedNameReference(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) ClassLiteralAccess(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) ArrayInitializer(org.eclipse.jdt.internal.compiler.ast.ArrayInitializer)

Example 2 with LongLiteral

use of org.eclipse.jdt.internal.compiler.ast.LongLiteral in project lombok by projectlombok.

the class EclipseHandlerUtil method copyAnnotationMemberValue0.

private static Expression copyAnnotationMemberValue0(Expression in) {
    int s = in.sourceStart, e = in.sourceEnd;
    if (in instanceof FalseLiteral)
        return new FalseLiteral(s, e);
    if (in instanceof TrueLiteral)
        return new TrueLiteral(s, e);
    if (in instanceof NullLiteral)
        return new NullLiteral(s, e);
    if (in instanceof CharLiteral)
        return new CharLiteral(((Literal) in).source(), s, e);
    if (in instanceof DoubleLiteral)
        return new DoubleLiteral(((Literal) in).source(), s, e);
    if (in instanceof FloatLiteral)
        return new FloatLiteral(((Literal) in).source(), s, e);
    if (in instanceof IntLiteral)
        return IntLiteral.buildIntLiteral(((Literal) in).source(), s, e);
    if (in instanceof LongLiteral)
        return LongLiteral.buildLongLiteral(((Literal) in).source(), s, e);
    if (in instanceof StringLiteral)
        return new StringLiteral(((Literal) in).source(), s, e, reflectInt(STRING_LITERAL__LINE_NUMBER, in) + 1);
    if (in instanceof ExtendedStringLiteral) {
        StringLiteral str = new StringLiteral(((Literal) in).source(), s, e, reflectInt(STRING_LITERAL__LINE_NUMBER, in) + 1);
        StringLiteral empty = new StringLiteral(new char[0], s, e, reflectInt(STRING_LITERAL__LINE_NUMBER, in) + 1);
        return new ExtendedStringLiteral(str, empty);
    }
    if (in instanceof StringLiteralConcatenation) {
        Expression[] literals = ((StringLiteralConcatenation) in).literals;
        // 0 and 1 len shouldn't happen.
        if (literals.length == 0)
            return new StringLiteral(new char[0], s, e, 0);
        if (literals.length == 1)
            return copyAnnotationMemberValue0(literals[0]);
        StringLiteralConcatenation c = new StringLiteralConcatenation((StringLiteral) literals[0], (StringLiteral) literals[1]);
        for (int i = 2; i < literals.length; i++) c = c.extendsWith((StringLiteral) literals[i]);
        return c;
    }
    if (in instanceof SingleNameReference) {
        SingleNameReference snr = (SingleNameReference) in;
        return new SingleNameReference(snr.token, pos(in));
    }
    if (in instanceof QualifiedNameReference) {
        QualifiedNameReference qnr = (QualifiedNameReference) in;
        return new QualifiedNameReference(qnr.tokens, poss(in, qnr.tokens.length), s, e);
    }
    // class refs
    if (in instanceof ClassLiteralAccess)
        return new ClassLiteralAccess(e, copyType(((ClassLiteralAccess) in).type));
    // arrays
    if (in instanceof ArrayInitializer) {
        ArrayInitializer out = new ArrayInitializer();
        out.sourceStart = s;
        out.sourceEnd = e;
        out.bits = in.bits;
        out.implicitConversion = in.implicitConversion;
        out.statementEnd = e;
        Expression[] exprs = ((ArrayInitializer) in).expressions;
        if (exprs != null) {
            Expression[] copy = new Expression[exprs.length];
            for (int i = 0; i < exprs.length; i++) copy[i] = copyAnnotationMemberValue(exprs[i]);
            out.expressions = copy;
        }
        return out;
    }
    if (in instanceof BinaryExpression) {
        BinaryExpression be = (BinaryExpression) in;
        BinaryExpression out = new BinaryExpression(be);
        out.left = copyAnnotationMemberValue(be.left);
        out.right = copyAnnotationMemberValue(be.right);
        out.sourceStart = s;
        out.sourceEnd = e;
        out.statementEnd = e;
        return out;
    }
    return in;
}
Also used : CharLiteral(org.eclipse.jdt.internal.compiler.ast.CharLiteral) LongLiteral(org.eclipse.jdt.internal.compiler.ast.LongLiteral) FloatLiteral(org.eclipse.jdt.internal.compiler.ast.FloatLiteral) ExtendedStringLiteral(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) SingleNameReference(org.eclipse.jdt.internal.compiler.ast.SingleNameReference) FalseLiteral(org.eclipse.jdt.internal.compiler.ast.FalseLiteral) TrueLiteral(org.eclipse.jdt.internal.compiler.ast.TrueLiteral) StringLiteral(org.eclipse.jdt.internal.compiler.ast.StringLiteral) ExtendedStringLiteral(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) BinaryExpression(org.eclipse.jdt.internal.compiler.ast.BinaryExpression) BinaryExpression(org.eclipse.jdt.internal.compiler.ast.BinaryExpression) AllocationExpression(org.eclipse.jdt.internal.compiler.ast.AllocationExpression) EqualExpression(org.eclipse.jdt.internal.compiler.ast.EqualExpression) CastExpression(org.eclipse.jdt.internal.compiler.ast.CastExpression) Expression(org.eclipse.jdt.internal.compiler.ast.Expression) FalseLiteral(org.eclipse.jdt.internal.compiler.ast.FalseLiteral) IntLiteral(org.eclipse.jdt.internal.compiler.ast.IntLiteral) CharLiteral(org.eclipse.jdt.internal.compiler.ast.CharLiteral) StringLiteral(org.eclipse.jdt.internal.compiler.ast.StringLiteral) LongLiteral(org.eclipse.jdt.internal.compiler.ast.LongLiteral) ExtendedStringLiteral(org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral) TrueLiteral(org.eclipse.jdt.internal.compiler.ast.TrueLiteral) FloatLiteral(org.eclipse.jdt.internal.compiler.ast.FloatLiteral) NullLiteral(org.eclipse.jdt.internal.compiler.ast.NullLiteral) Literal(org.eclipse.jdt.internal.compiler.ast.Literal) DoubleLiteral(org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) IntLiteral(org.eclipse.jdt.internal.compiler.ast.IntLiteral) DoubleLiteral(org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) NullLiteral(org.eclipse.jdt.internal.compiler.ast.NullLiteral) StringLiteralConcatenation(org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation) QualifiedNameReference(org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference) ClassLiteralAccess(org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess) ArrayInitializer(org.eclipse.jdt.internal.compiler.ast.ArrayInitializer)

Aggregations

AllocationExpression (org.eclipse.jdt.internal.compiler.ast.AllocationExpression)2 ArrayInitializer (org.eclipse.jdt.internal.compiler.ast.ArrayInitializer)2 BinaryExpression (org.eclipse.jdt.internal.compiler.ast.BinaryExpression)2 CastExpression (org.eclipse.jdt.internal.compiler.ast.CastExpression)2 CharLiteral (org.eclipse.jdt.internal.compiler.ast.CharLiteral)2 ClassLiteralAccess (org.eclipse.jdt.internal.compiler.ast.ClassLiteralAccess)2 DoubleLiteral (org.eclipse.jdt.internal.compiler.ast.DoubleLiteral)2 EqualExpression (org.eclipse.jdt.internal.compiler.ast.EqualExpression)2 Expression (org.eclipse.jdt.internal.compiler.ast.Expression)2 ExtendedStringLiteral (org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral)2 FalseLiteral (org.eclipse.jdt.internal.compiler.ast.FalseLiteral)2 FloatLiteral (org.eclipse.jdt.internal.compiler.ast.FloatLiteral)2 IntLiteral (org.eclipse.jdt.internal.compiler.ast.IntLiteral)2 Literal (org.eclipse.jdt.internal.compiler.ast.Literal)2 LongLiteral (org.eclipse.jdt.internal.compiler.ast.LongLiteral)2 NullLiteral (org.eclipse.jdt.internal.compiler.ast.NullLiteral)2 QualifiedNameReference (org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference)2 SingleNameReference (org.eclipse.jdt.internal.compiler.ast.SingleNameReference)2 StringLiteral (org.eclipse.jdt.internal.compiler.ast.StringLiteral)2 StringLiteralConcatenation (org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation)2