1 package net.sourceforge.pmd.rules.strictexception; 2 3 import net.sourceforge.pmd.AbstractRule; 4 import net.sourceforge.pmd.ast.ASTCatchStatement; 5 import net.sourceforge.pmd.ast.ASTClassOrInterfaceType; 6 import net.sourceforge.pmd.ast.ASTType; 7 8 15 public class AvoidCatchingThrowable extends AbstractRule { 16 17 public Object visit(ASTCatchStatement node, Object data) { 18 ASTType type = (ASTType) node.findChildrenOfType(ASTType.class).get(0); 19 ASTClassOrInterfaceType name = (ASTClassOrInterfaceType) type.findChildrenOfType(ASTClassOrInterfaceType.class).get(0); 20 if (name.hasImageEqualTo("Throwable")) { 21 addViolation(data, name); 22 } 23 return super.visit(node, data); 24 } 25 } 26 | Popular Tags |