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

项目:incubator-netbeans    文件:CasualDiff.java   
protected int diffTypeTest(JCInstanceOf oldT, JCInstanceOf newT, int[] bounds) {
    int localPointer = bounds[0];
    // expr
    int[] exprBounds = getBounds(oldT.expr);
    copyTo(localPointer, exprBounds[0]);
    localPointer = diffTree(oldT.expr, newT.expr, exprBounds);
    // clazz
    int[] clazzBounds = getBounds(oldT.clazz);
    clazzBounds[0] = copyUpTo(localPointer, clazzBounds[0]);
    localPointer = diffTree(oldT.clazz, newT.clazz, clazzBounds);
    localPointer = copyUpTo(localPointer, bounds[1]);

    return localPointer;
}
项目:javaparser2jctree    文件:PrintAstVisitor.java   
public void visitTypeTest(JCInstanceOf that) {
    try {
        print("JCInstanceOf:");
    } catch (Exception e) {
    }
    super.visitTypeTest(that);
}
项目:EasyMPermission    文件:PrettyCommentsPrinter.java   
public void visitTypeTest(JCInstanceOf tree) {
    try {
        open(prec, TreeInfo.ordPrec);
        printExpr(tree.expr, TreeInfo.ordPrec);
        print(" instanceof ");
        printExpr(tree.clazz, TreeInfo.ordPrec + 1);
        close(prec, TreeInfo.ordPrec);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:error-prone    文件:PlaceholderUnificationVisitor.java   
@Override
public Choice<State<JCInstanceOf>> visitInstanceOf(final InstanceOfTree node, State<?> state) {
  return chooseSubtrees(
      state,
      s -> unifyExpression(node.getExpression(), s),
      expr -> maker().TypeTest(expr, (JCTree) node.getType()));
}
项目:s4j    文件:Pretty.java   
public void visitTypeTest(JCInstanceOf tree) {
    try {
        open(prec, TreeInfo.ordPrec);
        printExpr(tree.expr, TreeInfo.ordPrec);
        print(" instanceof ");
        printExpr(tree.clazz, TreeInfo.ordPrec + 1);
        close(prec, TreeInfo.ordPrec);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:s4j    文件:Attr.java   
public void visitTypeTest(JCInstanceOf tree) {
    Type exprtype = chk.checkNullOrRefType(
        tree.expr.pos(), attribExpr(tree.expr, env));
    Type clazztype = chk.checkReifiableReferenceType(
        tree.clazz.pos(), attribType(tree.clazz, env));
    chk.validate(tree.clazz, env, false);
    chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
    result = check(tree, syms.booleanType, VAL, pkind, pt);
}
项目:lombok    文件:PrettyCommentsPrinter.java   
public void visitTypeTest(JCInstanceOf tree) {
    try {
        open(prec, TreeInfo.ordPrec);
        printExpr(tree.expr, TreeInfo.ordPrec);
        print(" instanceof ");
        printExpr(tree.clazz, TreeInfo.ordPrec + 1);
        close(prec, TreeInfo.ordPrec);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
项目:incubator-netbeans    文件:CasualDiff.java   
private boolean matchTypeTest(JCInstanceOf t1, JCInstanceOf t2) {
    return treesMatch(t1.clazz, t2.clazz) && treesMatch(t1.expr, t2.expr);
}
项目:lombok-ianchiu    文件:JavacTreeMaker.java   
public JCInstanceOf TypeTest(JCExpression expr, JCTree clazz) {
    return invoke(TypeTest, expr, clazz);
}
项目:lombok-ianchiu    文件:PrettyPrinter.java   
@Override public void visitTypeTest(JCInstanceOf tree) {
    print(tree.expr);
    print(" instanceof ");
    print(tree.clazz);
}
项目:javaparser2jctree    文件:AJCInstanceOf.java   
public AJCInstanceOf(JCInstanceOf ltree) {
    super(ltree.expr, ltree.clazz);
}
项目:javaparser2jctree    文件:AJCInstanceOf.java   
public AJCInstanceOf(JCInstanceOf ltree, String lcomment) {
    this(ltree);
    setComment(lcomment);
}
项目:EasyMPermission    文件:JavacTreeMaker.java   
public JCInstanceOf TypeTest(JCExpression expr, JCTree clazz) {
    return invoke(TypeTest, expr, clazz);
}
项目:refactor-faster    文件:UInstanceOf.java   
@Override
public JCInstanceOf inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().TypeTest(getExpression().inline(inliner), getType().inline(inliner));
}
项目:refactor-faster    文件:ExpressionTemplate.java   
/**
 * Returns the precedence level appropriate for unambiguously printing
 * leaf as a subexpression of its parent.
 */
private static int getPrecedence(JCTree leaf, Context context) {
  JCCompilationUnit comp = context.get(JCCompilationUnit.class);
  JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);

  // In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
  //
  // TODO(mdempsky): There are probably cases where we could omit parentheses
  // by tweaking the returned precedence, but they need careful review.
  // For example, consider a template to replace "add(a, b)" with "a + b",
  // which applied to "x + add(y, z)" would result in "x + (y + z)".
  // In most cases, we'd likely prefer "x + y + z" instead, but those aren't
  // always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
  // a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
  // to integer promotion rules.

  if (parent instanceof JCConditional) {
    // This intentionally differs from Pretty, because Pretty appears buggy:
    // http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
    JCConditional conditional = (JCConditional) parent;
    return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssign) {
    JCAssign assign = (JCAssign) parent;
    return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssignOp) {
    JCAssignOp assignOp = (JCAssignOp) parent;
    return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCUnary) {
    return TreeInfo.opPrec(parent.getTag());
  } else if (parent instanceof JCBinary) {
    JCBinary binary = (JCBinary) parent;
    return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCTypeCast) {
    JCTypeCast typeCast = (JCTypeCast) parent;
    return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCInstanceOf) {
    JCInstanceOf instanceOf = (JCInstanceOf) parent;
    return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
  } else if (parent instanceof JCArrayAccess) {
    JCArrayAccess arrayAccess = (JCArrayAccess) parent;
    return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCFieldAccess) {
    JCFieldAccess fieldAccess = (JCFieldAccess) parent;
    return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else {
    return TreeInfo.noPrec;
  }
}
项目:android-retrolambda-lombok    文件:JcTreePrinter.java   
@Override public void visitTypeTest(JCInstanceOf tree) {
    printNode(tree);
    child("expr", tree.expr);
    child("clazz", tree.clazz);
    indent--;
}
项目:android-retrolambda-lombok    文件:JcTreeConverter.java   
@Override public void visitTypeTest(JCInstanceOf node) {
    InstanceOf io = new InstanceOf();
    io.rawTypeReference(toTree(node.getType(), FlagKey.TYPE_REFERENCE));
    io.rawObjectReference(toTree(node.getExpression()));
    set(node, io);
}
项目:error-prone    文件:UInstanceOf.java   
@Override
public JCInstanceOf inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().TypeTest(getExpression().inline(inliner), getType().inline(inliner));
}
项目:error-prone    文件:ExpressionTemplate.java   
/**
 * Returns the precedence level appropriate for unambiguously printing leaf as a subexpression of
 * its parent.
 */
private static int getPrecedence(JCTree leaf, Context context) {
  JCCompilationUnit comp = context.get(JCCompilationUnit.class);
  JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);

  // In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
  //
  // TODO(mdempsky): There are probably cases where we could omit parentheses
  // by tweaking the returned precedence, but they need careful review.
  // For example, consider a template to replace "add(a, b)" with "a + b",
  // which applied to "x + add(y, z)" would result in "x + (y + z)".
  // In most cases, we'd likely prefer "x + y + z" instead, but those aren't
  // always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
  // a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
  // to integer promotion rules.

  if (parent instanceof JCConditional) {
    // This intentionally differs from Pretty, because Pretty appears buggy:
    // http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
    JCConditional conditional = (JCConditional) parent;
    return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssign) {
    JCAssign assign = (JCAssign) parent;
    return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssignOp) {
    JCAssignOp assignOp = (JCAssignOp) parent;
    return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCUnary) {
    return TreeInfo.opPrec(parent.getTag());
  } else if (parent instanceof JCBinary) {
    JCBinary binary = (JCBinary) parent;
    return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCTypeCast) {
    JCTypeCast typeCast = (JCTypeCast) parent;
    return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCInstanceOf) {
    JCInstanceOf instanceOf = (JCInstanceOf) parent;
    return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
  } else if (parent instanceof JCArrayAccess) {
    JCArrayAccess arrayAccess = (JCArrayAccess) parent;
    return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCFieldAccess) {
    JCFieldAccess fieldAccess = (JCFieldAccess) parent;
    return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else {
    return TreeInfo.noPrec;
  }
}
项目:Refaster    文件:UInstanceOf.java   
@Override
public JCInstanceOf inline(Inliner inliner) throws CouldNotResolveImportException {
  return inliner.maker().TypeTest(getExpression().inline(inliner), getType().inline(inliner));
}
项目:Refaster    文件:ExpressionTemplate.java   
/**
 * Returns the precedence level appropriate for unambiguously printing
 * leaf as a subexpression of its parent.
 */
private static int getPrecedence(JCTree leaf, Context context) {
  JCCompilationUnit comp = context.get(JCCompilationUnit.class);
  JCTree parent = TreeInfo.pathFor(leaf, comp).get(1);

  // In general, this should match the logic in com.sun.tools.javac.tree.Pretty.
  //
  // TODO(mdempsky): There are probably cases where we could omit parentheses
  // by tweaking the returned precedence, but they need careful review.
  // For example, consider a template to replace "add(a, b)" with "a + b",
  // which applied to "x + add(y, z)" would result in "x + (y + z)".
  // In most cases, we'd likely prefer "x + y + z" instead, but those aren't
  // always equivalent: "0L + (Integer.MIN_VALUE + Integer.MIN_VALUE)" yields
  // a different value than "0L + Integer.MIN_VALUE + Integer.MIN_VALUE" due
  // to integer promotion rules.

  if (parent instanceof JCConditional) {
    // This intentionally differs from Pretty, because Pretty appears buggy:
    // http://mail.openjdk.java.net/pipermail/compiler-dev/2013-September/007303.html
    JCConditional conditional = (JCConditional) parent;
    return TreeInfo.condPrec + ((conditional.cond == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssign) {
    JCAssign assign = (JCAssign) parent;
    return TreeInfo.assignPrec + ((assign.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCAssignOp) {
    JCAssignOp assignOp = (JCAssignOp) parent;
    return TreeInfo.assignopPrec + ((assignOp.lhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCUnary) {
    return TreeInfo.opPrec(parent.getTag());
  } else if (parent instanceof JCBinary) {
    JCBinary binary = (JCBinary) parent;
    return TreeInfo.opPrec(parent.getTag()) + ((binary.rhs == leaf) ? 1 : 0);
  } else if (parent instanceof JCTypeCast) {
    JCTypeCast typeCast = (JCTypeCast) parent;
    return (typeCast.expr == leaf) ? TreeInfo.prefixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCInstanceOf) {
    JCInstanceOf instanceOf = (JCInstanceOf) parent;
    return TreeInfo.ordPrec + ((instanceOf.clazz == leaf) ? 1 : 0);
  } else if (parent instanceof JCArrayAccess) {
    JCArrayAccess arrayAccess = (JCArrayAccess) parent;
    return (arrayAccess.indexed == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else if (parent instanceof JCFieldAccess) {
    JCFieldAccess fieldAccess = (JCFieldAccess) parent;
    return (fieldAccess.selected == leaf) ? TreeInfo.postfixPrec : TreeInfo.noPrec;
  } else {
    return TreeInfo.noPrec;
  }
}