01: /*
02: * Created on 27.02.2004
03: *
04: * To change the template for this generated file go to
05: * Window - Preferences - Java - Code Generation - Code and Comments
06: */
07: package org.hammurapi.inspectors;
08:
09: import java.util.LinkedList;
10: import java.util.List;
11:
12: import org.hammurapi.InspectorBase;
13: import org.hammurapi.HammurapiException;
14:
15: import com.pavelvlasov.jsel.Constructor;
16: import com.pavelvlasov.jsel.statements.SuperConstructorCall;
17: import com.pavelvlasov.review.SourceMarker;
18: import com.pavelvlasov.util.AccumulatingVisitorExceptionSink;
19: import com.pavelvlasov.util.DispatchingVisitor;
20:
21: /**
22: * @author Johannes
23: *
24: * To change the template for this generated type comment go to
25: * Window - Preferences - Java - Code Generation - Code and Comments
26: */
27: public class ConstructorWithoutSuperRule extends InspectorBase {
28:
29: public static class SuperSnooper {
30: List returns = new LinkedList();
31:
32: public void visit(SuperConstructorCall super Call) {
33: returns.add(super Call);
34: }
35: }
36:
37: public void visit(Constructor construct) throws HammurapiException {
38: {
39: if (construct != null) {
40: AccumulatingVisitorExceptionSink es = new AccumulatingVisitorExceptionSink();
41: SuperSnooper rs = new SuperSnooper();
42: construct.accept(new DispatchingVisitor(rs, es));
43:
44: if (rs.returns.isEmpty()) {
45: context.reportViolation((SourceMarker) construct);
46: }
47: if (!es.getExceptions().isEmpty()) {
48: es.dump();
49: throw new HammurapiException(
50: "There have been exceptions (see above)");
51: }
52: }
53: }
54: }
55:
56: }
|