当前位置: 首页>>代码示例>>Java>>正文


Java InstanceOfTree类代码示例

本文整理汇总了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;
}
 
开发者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


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