Java Code Examples for com.sun.source.tree.Tree.Kind#LONG_LITERAL

The following examples show how to use com.sun.source.tree.Tree.Kind#LONG_LITERAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeTag.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 2
Source File: TypeTag.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 3
Source File: TypeTag.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 4
Source File: TypeTag.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 5
Source File: TypeTag.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 6
Source File: TypeTag.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 7
Source File: TypeTag.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 8
Source File: TypeTag.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 9
Source File: TypeTag.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Kind getKindLiteral() {
    switch (this) {
    case INT:
        return Kind.INT_LITERAL;
    case LONG:
        return Kind.LONG_LITERAL;
    case FLOAT:
        return Kind.FLOAT_LITERAL;
    case DOUBLE:
        return Kind.DOUBLE_LITERAL;
    case BOOLEAN:
        return Kind.BOOLEAN_LITERAL;
    case CHAR:
        return Kind.CHAR_LITERAL;
    case CLASS:
        return Kind.STRING_LITERAL;
    case BOT:
        return Kind.NULL_LITERAL;
    default:
        throw new AssertionError("unknown literal kind " + this);
    }
}
 
Example 10
Source File: AddUnderscores.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@TriggerTreeKind({Kind.INT_LITERAL, Kind.LONG_LITERAL})
public static ErrorDescription hint(HintContext ctx) {
    TreePath tp = ctx.getPath();
    int end = (int) ctx.getInfo().getTrees().getSourcePositions().getEndPosition(tp.getCompilationUnit(), tp.getLeaf());
    int start = (int) ctx.getInfo().getTrees().getSourcePositions().getStartPosition(tp.getCompilationUnit(), tp.getLeaf());
    TokenSequence<?> ts = ctx.getInfo().getTokenHierarchy().tokenSequence();
    ts.move(end);
    if (!ts.movePrevious()) return null;
    String literal = ts.token().text().toString();
    StringBuilder tokenPrefix = new StringBuilder();
    
    while (ts.offset() > start) {
        if (!ts.movePrevious()) {
            break;
        }
        if (ts.offset() == start) {
            tokenPrefix.append(ts.token().text().toString());
            break;
        }
    }
    if (!isReplaceLiteralsWithUnderscores(ctx.getPreferences()) && literal.contains("_")) return null;
    RadixInfo info = radixInfo(literal);
    if (info.radix == 8) return null;//octals ignored for now
    String normalized = info.constant.replaceAll(Pattern.quote("_"), "");
    int separateCount = getSizeForRadix(ctx.getPreferences(), info.radix);
    StringBuilder split = new StringBuilder();
    int count = separateCount + 1;

    for (int i = normalized.length(); i > 0; i--) {
        if (--count == 0) {
            split.append("_");
            count = separateCount;
        }
        split.append(normalized.charAt(i - 1));
    }

    split.reverse();

    String result = info.prefix + split.toString() + info.suffix;

    if (result.equals(literal)) return null;

    String displayName = NbBundle.getMessage(AddUnderscores.class, "ERR_" + ID);
    Fix f = new FixImpl(ctx.getInfo(), tp, tokenPrefix.toString() + result).toEditorFix();

    return ErrorDescriptionFactory.forTree(ctx, tp, displayName, f);
}