本文整理汇总了Java中com.sun.source.tree.InstanceOfTree类的典型用法代码示例。如果您正苦于以下问题:Java InstanceOfTree类的具体用法?Java InstanceOfTree怎么用?Java InstanceOfTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstanceOfTree类属于com.sun.source.tree包,在下文中一共展示了InstanceOfTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree tree, EnumSet<UseTypes> d) {
Tree expr = tree.getExpression();
if (expr instanceof IdentifierTree) {
handlePossibleIdentifier(new TreePath(getCurrentPath(), expr), EnumSet.of(UseTypes.READ));
}
TreePath tp = new TreePath(getCurrentPath(), tree.getType());
handlePossibleIdentifier(tp, EnumSet.of(UseTypes.CLASS_USE));
super.visitInstanceOf(tree, null);
//TODO: should be considered
return null;
}
示例2: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Mirror visitInstanceOf(InstanceOfTree arg0, EvaluationContext evaluationContext) {
Mirror expr = arg0.getExpression().accept(this, evaluationContext);
VirtualMachine vm = evaluationContext.getDebugger().getVirtualMachine();
if (vm == null) {
return null;
}
if (expr == null) {
return mirrorOf(vm, false);
}
Assert.assertAssignable(expr, ObjectReference.class, arg0, "instanceOfLeftOperandNotAReference", expr);
ReferenceType expressionType = ((ObjectReference) expr).referenceType();
Type type = (Type) arg0.getType().accept(this, evaluationContext);
return mirrorOf(vm, instanceOf(expressionType, type));
}
示例3: matches
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public boolean matches(Tree tree, VisitorState state) {
if (tree instanceof IfTree) {
ExpressionTree conditionTree = ASTHelpers.stripParentheses(((IfTree) tree).getCondition());
if (conditionTree instanceof InstanceOfTree) {
InstanceOfTree instanceOfTree = (InstanceOfTree) conditionTree;
Types types = state.getTypes();
boolean isCastable =
types.isCastable(
types.erasure(ASTHelpers.getType(instanceOfTree.getType())),
types.erasure(ASTHelpers.getType(typeTree)));
boolean isSameExpression =
instanceOfTree.getExpression().toString().equals(expressionTree.toString());
return isSameExpression && !isCastable;
}
}
return false;
}
示例4: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Tree visitInstanceOf(InstanceOfTree tree, Void p) {
InstanceOfTree n = make.InstanceOf(tree.getExpression(), tree.getType());
model.setType(n, model.getType(tree));
comments.copyComments(tree, n);
model.setPos(n, model.getPos(tree));
return n;
}
示例5: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
public Boolean visitInstanceOf(InstanceOfTree node, TreePath p) {
if (p == null)
return super.visitInstanceOf(node, p);
InstanceOfTree t = (InstanceOfTree) p.getLeaf();
if (!scan(node.getExpression(), t.getExpression(), p))
return false;
return scan(node.getType(), t.getType(), p);
}
示例6: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree tree, List<Node> d) {
List<Node> below = new ArrayList<Node>();
addCorrespondingType(below);
addCorrespondingComments(below);
super.visitInstanceOf(tree, below);
d.add(new TreeNode(info, getCurrentPath(), below));
return null;
}
示例7: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree node, Void p) {
Element e = info.getTrees().getElement(new TreePath(getCurrentPath(), node.getExpression()));
if (parameter.equals(e)) {
throw new Found();
}
return super.visitInstanceOf(node, p);
}
示例8: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
/**
* Anything object-typed could be in the instance-of
*
* @param node
* @param p
* @return
*/
@Override
public List<? extends TypeMirror> visitInstanceOf(InstanceOfTree node, Object p) {
if (theExpression == null) {
initExpression(new TreePath(getCurrentPath(), node.getExpression()));
}
TypeElement tel = info.getElements().getTypeElement("java.lang.Object");
if (tel == null) {
return null;
}
return Collections.singletonList(tel.asType()); // NOI18N
}
示例9: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree node, Void unused) {
sync(node);
builder.open(plusFour);
scan(node.getExpression(), null);
builder.breakOp(" ");
builder.open(ZERO);
token("instanceof");
builder.breakOp(" ");
scan(node.getType(), null);
builder.close();
builder.close();
return null;
}
示例10: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree node, Void p) {
if (!done) {
index++;
}
if (tree == node) {
done = true;
}
return super.visitInstanceOf(node, p);
}
示例11: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree tree, VisitorState visitorState) {
VisitorState state = visitorState.withPath(getCurrentPath());
for (InstanceOfTreeMatcher matcher : instanceOfMatchers) {
if (!isSuppressed(matcher, state)) {
try {
reportMatch(matcher.matchInstanceOf(tree, state), tree, state);
} catch (Throwable t) {
handleError(matcher, t);
}
}
}
return super.visitInstanceOf(tree, state);
}
示例12: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
@Nullable
public Choice<Unifier> visitInstanceOf(InstanceOfTree instanceOf, @Nullable Unifier unifier) {
return getExpression()
.unify(instanceOf.getExpression(), unifier)
.thenChoose(unifications(getType(), instanceOf.getType()));
}
示例13: visitInstanceOf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@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()));
}
示例14: matchIf
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Description matchIf(IfTree ifTree, VisitorState visitorState) {
ExpressionTree expressionTree = stripParentheses(ifTree.getCondition());
if (expressionTree instanceof InstanceOfTree) {
InstanceOfTree instanceOfTree = (InstanceOfTree) expressionTree;
if (!(instanceOfTree.getExpression() instanceof IdentifierTree)) {
return Description.NO_MATCH;
}
Matcher<Tree> assignmentTreeMatcher =
new AssignmentTreeMatcher(instanceOfTree.getExpression());
Matcher<Tree> containsAssignmentTreeMatcher = contains(assignmentTreeMatcher);
if (containsAssignmentTreeMatcher.matches(ifTree, visitorState)) {
return Description.NO_MATCH;
}
// set expression and type to look for in matcher
Matcher<Tree> nestedInstanceOfMatcher =
new NestedInstanceOfMatcher(instanceOfTree.getExpression(), instanceOfTree.getType());
Matcher<Tree> containsNestedInstanceOfMatcher = contains(nestedInstanceOfMatcher);
if (containsNestedInstanceOfMatcher.matches(ifTree.getThenStatement(), visitorState)) {
return describeMatch(ifTree);
}
}
return Description.NO_MATCH;
}
示例15: getRelevantTree
import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Nullable
InstanceOfTree getRelevantTree() {
if (notApplicable) {
return null;
}
return relevantTree;
}