use of net.sourceforge.pmd.lang.java.ast.ASTNameList in project pmd by pmd.
the class SignatureDeclareThrowsExceptionRule method checkExceptions.
/**
* Search the list of thrown exceptions for Exception
*/
private void checkExceptions(Node method, Object o) {
List<ASTName> exceptionList = Collections.emptyList();
ASTNameList nameList = method.getFirstChildOfType(ASTNameList.class);
if (nameList != null) {
exceptionList = nameList.findDescendantsOfType(ASTName.class);
}
if (!exceptionList.isEmpty()) {
evaluateExceptions(exceptionList, o);
}
}
use of net.sourceforge.pmd.lang.java.ast.ASTNameList in project pmd by pmd.
the class UselessOverridingMethodRule method isMethodThrowingType.
// TODO: this method should be externalize into an utility class, shouldn't it ?
private boolean isMethodThrowingType(ASTMethodDeclaration node, List<String> exceptedExceptions) {
boolean result = false;
ASTNameList thrownsExceptions = node.getFirstChildOfType(ASTNameList.class);
if (thrownsExceptions != null) {
List<ASTName> names = thrownsExceptions.findChildrenOfType(ASTName.class);
for (ASTName name : names) {
for (String exceptedException : exceptedExceptions) {
if (exceptedException.equals(name.getImage())) {
result = true;
}
}
}
}
return result;
}
Aggregations