1 7 package org.hammurapi.inspectors; 8 9 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 27 public class ConstructorWithoutSuperRule extends InspectorBase { 28 29 public static class SuperSnooper { 30 List returns=new LinkedList (); 31 32 public void visit(SuperConstructorCall superCall) { 33 returns.add(superCall); 34 } 35 } 36 37 public void visit(Constructor construct )throws HammurapiException { { 38 if (construct!=null) { 39 AccumulatingVisitorExceptionSink es=new AccumulatingVisitorExceptionSink(); 40 SuperSnooper rs=new SuperSnooper(); 41 construct.accept(new DispatchingVisitor(rs, es)); 42 43 if( rs.returns.isEmpty()) { 44 context.reportViolation((SourceMarker)construct); 45 } 46 if (!es.getExceptions().isEmpty()) { 47 es.dump(); 48 throw new HammurapiException("There have been exceptions (see above)"); 49 } 50 } 51 } 52 } 53 54 } 55 | Popular Tags |