Object literalValue = literal.getValue(); switch (literal.getKind()) { case DOUBLE_LITERAL:
String customDiagnosticMessage; if (byteMatch) { String replacement = Byte.toString(((Number) literal.getValue()).byteValue()); fix = SuggestedFix.replace(literal, replacement); customDiagnosticMessage =
@Override public void visitApply(JCMethodInvocation tree) { JCExpression select = tree.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitCommentBefore")) { String commentLiteral = (String) ((JCLiteral) tree.getArguments().get(0)).getValue(); JCExpression expr = tree.getArguments().get(1); try { print("/* " + commentLiteral + " */ "); } catch (IOException e) { throw new RuntimeException(e); } expr.accept(this); } else { super.visitApply(tree); } }
Object literalValue = literal.getValue(); switch (literal.getKind()) { case DOUBLE_LITERAL:
String customDiagnosticMessage; if (byteMatch) { String replacement = Byte.toString(((Number) literal.getValue()).byteValue()); fix = SuggestedFix.replace(literal, replacement); customDiagnosticMessage =
@Override public void visitLiteral(JCLiteral node) { Object val = node.getValue(); boolean negative = false; Expression literal = null;
break; case BOOLEAN: print(tree.getValue().toString()); break; case BOT:
@Override public void visitLiteral(JCLiteral node) { Object val = node.getValue(); boolean negative = false; Expression literal = null;
@Override public void visitLiteral(JCLiteral node) { Object val = node.getValue(); boolean negative = false; Expression literal = null;
Object value; if( argExpr instanceof JCTree.JCLiteral && (value = ((JCTree.JCLiteral)argExpr).getValue()) instanceof Boolean )
@Override public void visitLiteral( JCTree.JCLiteral jcLiteral ) { super.visitLiteral( jcLiteral ); Object value = jcLiteral.getValue(); if( !(value instanceof String) ) { return; } if( isDisabled() ) { return; } TreeMaker maker = TreeMaker.instance( _javacTask.getContext() ); String stringValue = (String)value; List<JCTree.JCExpression> exprs = parse( stringValue, jcLiteral.getPreferredPosition() ); JCTree.JCBinary concat = null; while( !exprs.isEmpty() ) { if( concat == null ) { concat = maker.Binary( JCTree.Tag.PLUS, exprs.remove( 0 ), exprs.remove( 0 ) ); } else { concat = maker.Binary( JCTree.Tag.PLUS, concat, exprs.remove( 0 ) ); } } result = concat == null ? result : concat; }
private static void analyzeLiteral( SourceContext context, JCTree.JCLiteral literal, int preferredPos, int endPos) { Source src = context.source; Tree.Kind kind = literal.getKind(); Object value = literal.getValue(); Range range = Range.create(src, preferredPos, endPos); Variable variable = new Variable(kind.toString(), preferredPos, range); if (nonNull(value)) { variable.fqcn = value.getClass().getCanonicalName(); variable.argumentIndex = context.argumentIndex; context.setArgumentFQCN(variable.fqcn); } else { variable.fqcn = "<null>"; variable.argumentIndex = context.argumentIndex; context.setArgumentFQCN(variable.fqcn); } src.getCurrentScope() .ifPresent( scope -> { scope.addVariable(variable); addSymbolIndex(src, scope, variable); }); }
boolean merge(ListBuffer<JCLiteral> litBuf, ListBuffer<JCExpression> opStack) { if (litBuf.isEmpty()) { return false; } else if (litBuf.size() == 1) { opStack.prepend(litBuf.first()); return false; } else { StringBuilder sb = new StringBuilder(); for (JCLiteral lit : litBuf) { sb.append(lit.getValue()); } JCExpression t = F.at(litBuf.first().getStartPosition()).Literal(TypeTag.CLASS, sb.toString()); storeEnd(t, litBuf.last().getEndPosition(endPosTable)); opStack.prepend(t); return true; } }
@Override public void printStat(JCTree tree) throws IOException { if (tree instanceof JCExpressionStatement && ((JCExpressionStatement) tree).getExpression() instanceof JCMethodInvocation) { JCMethodInvocation invocation = (JCMethodInvocation) ((JCExpressionStatement) tree).getExpression(); JCExpression select = invocation.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitComment")) { String commentLiteral = (String) ((JCLiteral) invocation.getArguments().get(0)).getValue(); print("// " + commentLiteral); return; } } super.printStat(tree); }
@Override public void visitApply(JCMethodInvocation tree) { JCExpression select = tree.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitCommentBefore")) { String commentLiteral = (String) ((JCLiteral) tree.getArguments().get(0)).getValue(); JCExpression expr = tree.getArguments().get(1); try { print("/* " + commentLiteral + " */ "); } catch (IOException e) { throw new RuntimeException(e); } expr.accept(this); } else { super.visitApply(tree); } }
public Object getValue() { return getTree().getValue(); }
/** * Tells if that tree is the null literal. */ public static boolean isNullLiteral(JCTree tree) { return tree instanceof JCLiteral && ((JCLiteral) tree).getValue() == null; }
@Override public void printStat(JCTree tree) throws IOException { if (tree instanceof JCExpressionStatement && ((JCExpressionStatement) tree).getExpression() instanceof JCMethodInvocation) { JCMethodInvocation invocation = (JCMethodInvocation) ((JCExpressionStatement) tree).getExpression(); JCExpression select = invocation.getMethodSelect(); if (select != null && select.toString().equals("Refaster.emitComment")) { String commentLiteral = (String) ((JCLiteral) invocation.getArguments().get(0)).getValue(); print("// " + commentLiteral); return; } } super.printStat(tree); }