Java 类com.sun.tools.javac.tree.JCTree.JCParens 实例源码

项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitDoLoop(JCDoWhileLoop tree) {
    aPrint("do ");
    if (tree.body instanceof JCBlock) {
        println("{");
        indent++;
        print(((JCBlock) tree.body).stats, "");
        indent--;
        aPrint("}");

    } else print(tree.body);
    print(" while ");
    if (tree.cond instanceof JCParens) {
        print(tree.cond);
    } else {
        print("(");
        print(tree.cond);
        print(")");
    }
    println(";", tree);
}
项目:jmlok    文件:Examinator.java   
/**
 * This function walks into a tree with nodes of type JCBinary to search for 
 * a string as one of the elements of the tree.
 * @param toTest The String searched as Element in the tree.
 * @param expression The bifurcation tree searched.
 * @return True if the string was found, or False.
 */
private boolean isThereInMiniTree(String toTest, JCTree expression) {
    if(expression instanceof JCParens){
        if(isThereInMiniTree(toTest, ((JCParens) expression).expr))
            return true;
    } else if(expression instanceof JCIdent){
        if(((JCIdent) expression).name.toString().equals(toTest))
            return true;
    } else if(expression instanceof JCBinary){
        if(isThereInMiniTree(toTest, ((JCBinary) expression).rhs))
            return true;
        if(isThereInMiniTree(toTest, ((JCBinary) expression).lhs))
            return true;
    }
    return false;
}
项目:jmlok    文件:Examinator.java   
/**
 * Verify if the boolean expression have a true value despite of any variable values. 
 * @param expression The boolean expression examined.
 * @return 1 When the expression is always true.
 */
private int hasTrueValue(JCTree expression) {
    if(expression instanceof JCParens){
        if(hasTrueValue(((JCParens)expression).expr) != 0)
            return 1;
    }else if(expression instanceof JCLiteral){
        if(((JCLiteral) expression).value == null)
            return VAR_FALSE_VALUE;
        return (int) ((JCLiteral) expression).value;
    }else if(expression instanceof JmlSingleton){
        return 1;
    }else if(expression instanceof JCBinary){
        return resolveBooleanOperations(expression);
    }
    return VAR_FALSE_VALUE;
}
项目:error-prone-aspirator    文件:ElementsCountedInLoop.java   
@Override
public Description matchWhileLoop(WhileLoopTree tree, VisitorState state) {
  JCWhileLoop whileLoop = (JCWhileLoop) tree;
  JCExpression whileExpression = ((JCParens) whileLoop.getCondition()).getExpression();
  if (whileExpression instanceof MethodInvocationTree) {
    MethodInvocationTree methodInvocation = (MethodInvocationTree) whileExpression;
    if (methodSelect(isDescendantOfMethod("java.util.Iterator", "hasNext()")).matches(
        methodInvocation, state)) {
      IdentifierTree identifier = getIncrementedIdentifer(extractSingleStatement(whileLoop.body));
      if (identifier != null) {
        return describeMatch(tree, new SuggestedFix());
      }
    }
  }
  return Description.NO_MATCH;
}
项目:incubator-netbeans    文件:CasualDiff.java   
protected int diffParens(JCParens oldT, JCParens newT, int[] bounds) {
    int localPointer = bounds[0];
    copyTo(localPointer, getCommentCorrectedOldPos(oldT.expr));
    localPointer = diffTree(oldT.expr, newT.expr, getBounds(oldT.expr));
    copyTo(localPointer, bounds[1]);
    return bounds[1];
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitWhileLoop(JCWhileLoop tree) {
    aPrint("while ");
    if (tree.cond instanceof JCParens) {
        print(tree.cond);
    } else {
        print("(");
        print(tree.cond);
        print(")");
    }
    print(" ");
    print(tree.body);
    // make sure to test while (true) ; and while(true){} and while(true) x = 5;
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitIf(JCIf tree) {
    aPrint("if ");
    if (tree.cond instanceof JCParens) {
        print(tree.cond);
    } else {
        print("(");
        print(tree.cond);
        print(")");
    }
    print(" ");
    if (tree.thenpart instanceof JCBlock) {
        println("{");
        indent++;
        print(((JCBlock) tree.thenpart).stats, "");
        indent--;
        if (tree.elsepart == null) {
            aPrintln("}", tree);
        } else {
            aPrint("}");
        }
    } else {
        print(tree.thenpart);
    }
    if (tree.elsepart != null) {
        aPrint(" else ");
        print(tree.elsepart);
    }
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitSynchronized(JCSynchronized tree) {
    aPrint("synchronized ");
    if (tree.lock instanceof JCParens) {
        print(tree.lock);
    } else {
        print("(");
        print(tree.lock);
        print(")");
    }
    print(" ");
    print(tree.body);
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitSwitch(JCSwitch tree) {
    aPrint("switch ");
    if (tree.selector instanceof JCParens) {
        print(tree.selector);
    } else {
        print("(");
        print(tree.selector);
        print(")");
    }
    println(" {");
    print(tree.cases, "\n");
    aPrintln("}", tree);
}
项目:lombok-ianchiu    文件:HandleNonNull.java   
/**
 * Checks if the statement is of the form 'if (x == null) {throw WHATEVER;},
 * where the block braces are optional. If it is of this form, returns "x".
 * If it is not of this form, returns null.
 */
public String returnVarNameIfNullCheck(JCStatement stat) {
    if (!(stat instanceof JCIf)) return null;

    /* Check that the if's statement is a throw statement, possibly in a block. */ {
        JCStatement then = ((JCIf) stat).thenpart;
        if (then instanceof JCBlock) {
            List<JCStatement> stats = ((JCBlock) then).stats;
            if (stats.length() == 0) return null;
            then = stats.get(0);
        }
        if (!(then instanceof JCThrow)) return null;
    }

    /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate
       a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ {
        JCExpression cond = ((JCIf) stat).cond;
        while (cond instanceof JCParens) cond = ((JCParens) cond).expr;
        if (!(cond instanceof JCBinary)) return null;
        JCBinary bin = (JCBinary) cond;
        if (!CTC_EQUAL.equals(treeTag(bin))) return null;
        if (!(bin.lhs instanceof JCIdent)) return null;
        if (!(bin.rhs instanceof JCLiteral)) return null;
        if (!CTC_BOT.equals(typeTag(bin.rhs))) return null;
        return ((JCIdent) bin.lhs).name.toString();
    }
}
项目:javaparser2jctree    文件:PrintAstVisitor.java   
public void visitParens(JCParens that) {
    try {
        print("JCParens:");
    } catch (Exception e) {
    }
    super.visitParens(that);
}
项目:EasyMPermission    文件:PrettyCommentsPrinter.java   
public void visitParens(JCParens tree) {
    try {
        print("(");
        printExpr(tree.expr);
        print(")");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:EasyMPermission    文件:HandleNonNull.java   
/**
 * Checks if the statement is of the form 'if (x == null) {throw WHATEVER;},
 * where the block braces are optional. If it is of this form, returns "x".
 * If it is not of this form, returns null.
 */
public String returnVarNameIfNullCheck(JCStatement stat) {
    if (!(stat instanceof JCIf)) return null;

    /* Check that the if's statement is a throw statement, possibly in a block. */ {
        JCStatement then = ((JCIf) stat).thenpart;
        if (then instanceof JCBlock) {
            List<JCStatement> stats = ((JCBlock) then).stats;
            if (stats.length() == 0) return null;
            then = stats.get(0);
        }
        if (!(then instanceof JCThrow)) return null;
    }

    /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate
       a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ {
        JCExpression cond = ((JCIf) stat).cond;
        while (cond instanceof JCParens) cond = ((JCParens) cond).expr;
        if (!(cond instanceof JCBinary)) return null;
        JCBinary bin = (JCBinary) cond;
        if (!CTC_EQUAL.equals(treeTag(bin))) return null;
        if (!(bin.lhs instanceof JCIdent)) return null;
        if (!(bin.rhs instanceof JCLiteral)) return null;
        if (!CTC_BOT.equals(typeTag(bin.rhs))) return null;
        return ((JCIdent) bin.lhs).name.toString();
    }
}
项目:s4j    文件:Pretty.java   
public void visitParens(JCParens tree) {
    try {
        print("(");
        printExpr(tree.expr);
        print(")");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:s4j    文件:Attr.java   
public void visitParens(JCParens tree) {
    Type owntype = attribTree(tree.expr, env, pkind, pt);
    result = check(tree, owntype, pkind, pkind, pt);
    Symbol sym = TreeInfo.symbol(tree);
    if (sym != null && (sym.kind&(TYP|PCK)) != 0)
        log.error(tree.pos(), "illegal.start.of.type");
}
项目:lombok    文件:PrettyCommentsPrinter.java   
public void visitParens(JCParens tree) {
    try {
        print("(");
        printExpr(tree.expr);
        print(")");
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:openjdk-jdk10    文件:ArgumentAttr.java   
@Override
public void visitParens(JCParens that) {
    processArg(that, speculativeTree -> new ParensType(that, env, speculativeTree));
}
项目:openjdk-jdk10    文件:ArgumentAttr.java   
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens) {
    this(tree, env, speculativeParens, new HashMap<>());
}
项目:openjdk-jdk10    文件:ArgumentAttr.java   
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens, Map<ResultInfo, Type> speculativeTypes) {
   super(tree, env, speculativeParens, speculativeTypes);
}
项目:openjdk-jdk10    文件:ArgumentAttr.java   
@Override
ArgumentType<JCParens> dup(JCParens tree, Env<AttrContext> env) {
    return new ParensType(tree, env, speculativeTree, speculativeTypes);
}
项目:openjdk9    文件:ArgumentAttr.java   
@Override
public void visitParens(JCParens that) {
    processArg(that, speculativeTree -> new ParensType(that, env, speculativeTree));
}
项目:openjdk9    文件:ArgumentAttr.java   
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens) {
    this(tree, env, speculativeParens, new HashMap<>());
}
项目:openjdk9    文件:ArgumentAttr.java   
ParensType(JCExpression tree, Env<AttrContext> env, JCParens speculativeParens, Map<ResultInfo, Type> speculativeTypes) {
   super(tree, env, speculativeParens, speculativeTypes);
}
项目:openjdk9    文件:ArgumentAttr.java   
@Override
ArgumentType<JCParens> dup(JCParens tree, Env<AttrContext> env) {
    return new ParensType(tree, env, speculativeTree, speculativeTypes);
}
项目:lombok-ianchiu    文件:JavacTreeMaker.java   
public JCParens Parens(JCExpression expr) {
    return invoke(Parens, expr);
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitParens(JCParens tree) {
    print("(");
    print(tree.expr);
    print(")");
}
项目:javaparser2jctree    文件:AJCParens.java   
public AJCParens(JCParens ltree) {
    super(ltree.expr);
}
项目:javaparser2jctree    文件:AJCParens.java   
public AJCParens(JCParens ltree, String lcomment) {
    this(ltree);
    setComment(lcomment);
}
项目:EasyMPermission    文件:JavacTreeMaker.java   
public JCParens Parens(JCExpression expr) {
    return invoke(Parens, expr);
}
项目:refactor-faster    文件:UParens.java   
@Override
public JCParens inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().Parens(getExpression().inline(inliner));
}
项目:android-retrolambda-lombok    文件:JcTreePrinter.java   
@Override public void visitParens(JCParens tree) {
    printNode(tree);
    child("expr", tree.expr);
    indent--;
}
项目:android-retrolambda-lombok    文件:JcTreeConverter.java   
private static JCTree removeParens(JCTree node) {
    if (!(node instanceof JCParens)) return node;
    return ((JCParens) node).getExpression();
}
项目:android-retrolambda-lombok    文件:JcTreeConverter.java   
@Override public void visitParens(JCParens node) {
    Expression expr = (Expression) toTree(node.getExpression());
    expr.astParensPositions().add(getPosition(node));
    set(node, expr);
}
项目:error-prone    文件:PlaceholderUnificationVisitor.java   
@Override
public Choice<State<JCParens>> visitParenthesized(ParenthesizedTree node, State<?> state) {
  return chooseSubtrees(state, s -> unifyExpression(node.getExpression(), s), maker()::Parens);
}
项目:error-prone    文件:UParens.java   
@Override
public JCParens inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().Parens(getExpression().inline(inliner));
}
项目:Refaster    文件:UParens.java   
@Override
public JCParens inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().Parens(getExpression().inline(inliner));
}