Example JeSSVisitor Ð Unhandled Exception Finder
/*
* @author Russell Spitler
* Created on Dec 26, 2004
* ExceptionFinder.java
*
*/
package
edu.colby.JeSS.visitors;
import
java.util.List;
import
org.eclipse.jdt.core.dom.*;
import
edu.colby.JeSS.scanner.*;
import
edu.colby.JeSS.util.JeSSVisitor;
public
class ExceptionFinder extends JeSSVisitor {
private String errorMessage
= "Unhandled Exception Found";
public
ExceptionFinder(VisitorManager vManager){
super(vManager);
}
public
boolean visit(CatchClause node) {
//retrieve the block contained in this catch clause
Block
body = node.getBody();
//retrieve the statements contained in this block
List
l = body.statements();
//if there are no statements in the block report error
if(l.isEmpty()){
reportProblem(node,
errorMessage);
}
return
true;
}
}