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


Java ThrowTree类代码示例

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


ThrowTree类属于com.sun.source.tree包,在下文中一共展示了ThrowTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree node, Collection<TreePath> trees) {
    if (!analyzeThrows) {
        return null;
    }
    TypeMirror type = info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
    boolean isCaught = false;

    OUTER: for (Set<TypeMirror> caught : caughtExceptions) {
        for (TypeMirror c : caught) {
            if (info.getTypes().isSubtype(type, c)) {
                isCaught = true;
                break OUTER;
            }
        }
    }

    super.visitThrow(node, trees);
    if (!isCaught) {
        trees.add(getCurrentPath());
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:TryCatchFinally.java

示例2: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Boolean visitThrow(ThrowTree node, Void p) {
    TypeMirror type = info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));
    boolean isCaught = false;

    OUTER: for (Pair<Set<TypeMirror>, Tree> pair : caughtExceptions) {
        Set<TypeMirror> caught = pair.first();
        for (TypeMirror c : caught) {
            if (info.getTypes().isSubtype(type, c)) {
                isCaught = true;
                targetTrees.add(pair.second());
                break OUTER;
            }
        }
    }

    return super.visitThrow(node, p) == Boolean.TRUE || !isCaught;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Utilities.java

示例3: isTerminating

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
private boolean isTerminating(StatementTree tree) {
    StatementTree first = firstStatement(tree);
    if (first instanceof ThrowTree)
        return true;
    if (first instanceof ReturnTree)
        return true;

    if (first instanceof IfTree) {
        IfTree ifTree = (IfTree)first;
        if (ifTree.getElseStatement() != null
            && isTerminating(ifTree.getThenStatement())
            && isTerminating(ifTree.getElseStatement()))
            return true;
    }

    return false;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:18,代码来源:MapGetHeuristics.java

示例4: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Tree visitThrow(ThrowTree tree, Void p) {
    ThrowTree n = make.Throw(tree.getExpression());
    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: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
public Boolean visitThrow(ThrowTree node, TreePath p) {
    if (p == null) {
        super.visitThrow(node, p);
        return false;
    }

    ThrowTree at = (ThrowTree) p.getLeaf();

    return scan(node.getExpression(), at.getExpression(), p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:CopyFinder.java

示例6: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Boolean visitThrow(ThrowTree tree, Stack<Tree> d) {
    addToExceptionsMap(info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), tree.getExpression())), tree);
    
    super.visitThrow(tree, d);
    
    return Boolean.TRUE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:MethodExitDetector.java

示例7: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree tree, EnumSet<UseTypes> p) {
    if (tree.getExpression() != null && tree.getExpression().getKind() == Kind.IDENTIFIER) {
        handlePossibleIdentifier(new TreePath(getCurrentPath(), tree.getExpression()), EnumSet.of(UseTypes.READ));
    }
    
    return super.visitThrow(tree, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:SemanticHighlighterBase.java

示例8: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingType(below);
    addCorrespondingComments(below);
    super.visitThrow(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:TreeNode.java

示例9: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
public Boolean visitThrow(ThrowTree node, ConstructorData p) {
    super.visitThrow(node, p);

    if (node.getExpression() != null) {
        TypeMirror thrown = info.getTrees().getTypeMirror(new TreePath(getCurrentPath(), node.getExpression()));

        recordResumeOnExceptionHandler(thrown);
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Flow.java

示例10: createRethrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
private static StatementTree createRethrow(WorkingCopy info, TreeMaker make, String name) {
    if (!ErrorFixesFakeHint.isRethrow(ErrorFixesFakeHint.getPreferences(info.getFileObject(), FixKind.SURROUND_WITH_TRY_CATCH))) {
        return null;
    }

    ThrowTree result = make.Throw(make.Identifier(name));

    info.tag(result.getExpression(), Utilities.TAG_SELECT);

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:MagicSurroundWithTryCatchFix.java

示例11: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public List<Tree> visitThrow(ThrowTree node, ExpressionScanner.ExpressionsInfo p) {
    List<Tree> result = null;
    if (acceptsTree(node)) {
        result = scan(node.getExpression(), p);
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ExpressionScanner.java

示例12: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree node, Void unused) {
    sync(node);
    token("throw");
    builder.space();
    scan(node.getExpression(), null);
    token(";");
    return null;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:10,代码来源:JavaInputAstVisitor.java

示例13: matches

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public boolean matches(StatementTree expressionTree, VisitorState state) {
  if (!(expressionTree instanceof ThrowTree)) {
    return false;
  }

  return thrownMatcher.matches(((ThrowTree) expressionTree).getExpression(), state);
}
 
开发者ID:google,项目名称:error-prone,代码行数:9,代码来源:Throws.java

示例14: visitThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Void visitThrow(ThrowTree tree, VisitorState visitorState) {
  VisitorState state = visitorState.withPath(getCurrentPath());
  for (ThrowTreeMatcher matcher : throwMatchers) {
    if (!isSuppressed(matcher, state)) {
      try {
        reportMatch(matcher.matchThrow(tree, state), tree, state);
      } catch (Throwable t) {
        handleError(matcher, t);
      }
    }
  }
  return super.visitThrow(tree, state);
}
 
开发者ID:google,项目名称:error-prone,代码行数:15,代码来源:ErrorProneScanner.java

示例15: matchThrow

import com.sun.source.tree.ThrowTree; //导入依赖的package包/类
@Override
public Description matchThrow(ThrowTree tree, VisitorState state) {
  return (tree.getExpression().getKind() == NULL_LITERAL)
      ? describeMatch(
          tree, SuggestedFix.replace(tree.getExpression(), "new NullPointerException()"))
      : NO_MATCH;
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:ThrowNull.java


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