Search in sources :

Example 1 with CharLiteral

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

the class HandleConstructor method getDefaultExpr.

private static Expression getDefaultExpr(TypeReference type, int s, int e) {
    boolean array = type instanceof ArrayTypeReference;
    if (array)
        return new NullLiteral(s, e);
    char[] lastToken = type.getLastToken();
    if (Arrays.equals(TypeConstants.BOOLEAN, lastToken))
        return new FalseLiteral(s, e);
    if (Arrays.equals(TypeConstants.CHAR, lastToken))
        return new CharLiteral(new char[] { '\'', '\\', '0', '\'' }, s, e);
    if (Arrays.equals(TypeConstants.BYTE, lastToken) || Arrays.equals(TypeConstants.SHORT, lastToken) || Arrays.equals(TypeConstants.INT, lastToken))
        return IntLiteral.buildIntLiteral(new char[] { '0' }, s, e);
    if (Arrays.equals(TypeConstants.LONG, lastToken))
        return LongLiteral.buildLongLiteral(new char[] { '0', 'L' }, s, e);
    if (Arrays.equals(TypeConstants.FLOAT, lastToken))
        return new FloatLiteral(new char[] { '0', 'F' }, s, e);
    if (Arrays.equals(TypeConstants.DOUBLE, lastToken))
        return new DoubleLiteral(new char[] { '0', 'D' }, s, e);
    return new NullLiteral(s, e);
}
Also used : CharLiteral(org.eclipse.jdt.internal.compiler.ast.CharLiteral) FloatLiteral(org.eclipse.jdt.internal.compiler.ast.FloatLiteral) DoubleLiteral(org.eclipse.jdt.internal.compiler.ast.DoubleLiteral) NullLiteral(org.eclipse.jdt.internal.compiler.ast.NullLiteral) ArrayTypeReference(org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference) FalseLiteral(org.eclipse.jdt.internal.compiler.ast.FalseLiteral)

Aggregations

ArrayTypeReference (org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference)1 CharLiteral (org.eclipse.jdt.internal.compiler.ast.CharLiteral)1 DoubleLiteral (org.eclipse.jdt.internal.compiler.ast.DoubleLiteral)1 FalseLiteral (org.eclipse.jdt.internal.compiler.ast.FalseLiteral)1 FloatLiteral (org.eclipse.jdt.internal.compiler.ast.FloatLiteral)1 NullLiteral (org.eclipse.jdt.internal.compiler.ast.NullLiteral)1