• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InstanceOfTree类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.source.tree.InstanceOfTree的典型用法代码示例。如果您正苦于以下问题:Java InstanceOfTree类的具体用法?Java InstanceOfTree怎么用?Java InstanceOfTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InstanceOfTree类属于com.sun.source.tree包,在下文中一共展示了InstanceOfTree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:SemanticHighlighterBase.java


示例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));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EvaluatorVisitor.java


示例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;
}
 
开发者ID:google,项目名称:error-prone,代码行数:24,代码来源:NestedInstanceOfConditions.java


示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TreeDuplicator.java


示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CopyFinder.java


示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:TreeNode.java


示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:EqualsMethodHint.java


示例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
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ExpectedTypeResolver.java


示例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;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:15,代码来源:JavaInputAstVisitor.java


示例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);
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:11,代码来源:InstanceOfScanner.java


示例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);
}
 
开发者ID:google,项目名称:error-prone,代码行数:15,代码来源:ErrorProneScanner.java


示例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()));
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:UInstanceOf.java


示例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()));
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:PlaceholderUnificationVisitor.java


示例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;
}
 
开发者ID:google,项目名称:error-prone,代码行数:34,代码来源:NestedInstanceOfConditions.java


示例15: getRelevantTree

import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Nullable
InstanceOfTree getRelevantTree() {
  if (notApplicable) {
    return null;
  }
  return relevantTree;
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:InstanceOfAndCastMatchWrongType.java


示例16: visitInstanceOf

import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree tree, ExpressionTree expr) {
  if (expressionsEqual(tree.getExpression(), expr)) {
    relevantTree = tree;
  }
  return super.visitInstanceOf(tree, expr);
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:InstanceOfAndCastMatchWrongType.java


示例17: visitInstanceOf

import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Node visitInstanceOf(InstanceOfTree tree, Void p) {
    Node operand = scan(tree.getExpression(), p);
    TypeMirror refType = InternalUtils.typeOf(tree.getType());
    InstanceOfNode node = new InstanceOfNode(tree, operand, refType,
            types);
    extendWithNode(node);
    return node;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:10,代码来源:CFGBuilder.java


示例18: visitInstanceOf

import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Node visitInstanceOf(InstanceOfTree tree, Void p) {
    Node operand = scan(tree.getExpression(), p);
    TypeMirror refType = InternalUtils.typeOf(tree.getType());
    InstanceOfNode node = new InstanceOfNode(tree, operand, refType, types);
    extendWithNode(node);
    return node;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:9,代码来源:CFGBuilder.java


示例19: visitInstanceOf

import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
@Override
public Void visitInstanceOf(InstanceOfTree expected, Tree actual) {
  Optional<InstanceOfTree> other = checkTypeAndCast(expected, actual);
  if (!other.isPresent()) {
    addTypeMismatch(expected, actual);
    return null;
  }

  scan(expected.getExpression(), other.get().getExpression());
  scan(expected.getType(), other.get().getType());
  return null;
}
 
开发者ID:google,项目名称:compile-testing,代码行数:13,代码来源:TreeDiffer.java


示例20: visitInstanceOf

import com.sun.source.tree.InstanceOfTree; //导入依赖的package包/类
/**
 * instanceof adds dependency on the literal type
 */
@Override
public Object visitInstanceOf(InstanceOfTree node, Object p) {
    addDependency(node.getType());
    return super.visitInstanceOf(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DependencyCollector.java



注:本文中的com.sun.source.tree.InstanceOfTree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResultLogConfig类代码示例发布时间:2022-05-21
下一篇:
Java TemporalQuery类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap