/** * Returns whether the variable is mentioned within the statement block or not. * * @param block ASTBlockStatement * @param varName String * @return boolean */ private static boolean hasReferencesIn(ASTBlockStatement block, String varName) { List<ASTName> names = block.findDescendantsOfType(ASTName.class); for (ASTName name : names) { if (isReference(varName, name.getImage())) return true; } return false; }
/** * Checks whether the given target is in the argument list. If this is the case, then the target * (root exception) is used as the cause. * * @param target * @param baseNode */ private boolean checkForTargetUsage(String target, Node baseNode) { boolean match = false; if (target != null && baseNode != null) { List<ASTName> nameNodes = baseNode.findDescendantsOfType(ASTName.class); for (ASTName nameNode : nameNodes) { if (target.equals(nameNode.getImage())) { match = true; break; } } } return match; }