本文整理汇总了Java中com.sun.tools.javac.tree.JCTree.JCParens类的典型用法代码示例。如果您正苦于以下问题:Java JCParens类的具体用法?Java JCParens怎么用?Java JCParens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JCParens类属于com.sun.tools.javac.tree.JCTree包,在下文中一共展示了JCParens类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitDoLoop
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
@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);
}
示例2: isThereInMiniTree
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
/**
* 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;
}
示例3: hasTrueValue
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
/**
* 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;
}
示例4: matchWhileLoop
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
@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;
}
示例5: diffParens
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
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];
}
示例6: visitWhileLoop
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
@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;
}
示例7: visitIf
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
@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);
}
}
示例8: visitSynchronized
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
@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);
}
示例9: visitSwitch
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
@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);
}
示例10: returnVarNameIfNullCheck
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
/**
* 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();
}
}
示例11: visitParens
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
public void visitParens(JCParens that) {
try {
print("JCParens:");
} catch (Exception e) {
}
super.visitParens(that);
}
示例12: visitParens
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
public void visitParens(JCParens tree) {
try {
print("(");
printExpr(tree.expr);
print(")");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例13: visitParens
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
public void visitParens(JCParens tree) {
try {
print("(");
printExpr(tree.expr);
print(")");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
示例14: visitParens
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
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");
}
示例15: visitParens
import com.sun.tools.javac.tree.JCTree.JCParens; //导入依赖的package包/类
@Override
public void visitParens(JCParens that) {
processArg(that, speculativeTree -> new ParensType(that, env, speculativeTree));
}