more changes.
[IRC.git] / Robust / src / Analysis / SSJava / MethodAnnotationCheck.java
index f8145c56a3607c697decace0796dafd76a79cce2..f05fcff0fad2396e47046a74029e713eb1c46a86 100644 (file)
@@ -90,29 +90,19 @@ public class MethodAnnotationCheck {
           if (!visited.contains(p)) {
             visited.add(p);
 
-            if (calleeMD.getClassDesc().isInterface()) {
-              calleeMD.getClassDesc();
-
-            }
-
             tovisit.add(calleeMD);
 
-            if (calleeMD.isAbstract()) {
-              Set<MethodDescriptor> possibleCalleeSet =
-                  (Set<MethodDescriptor>) ssjava.getCallGraph().getMethods(calleeMD);
-
-              for (Iterator iterator2 = possibleCalleeSet.iterator(); iterator2.hasNext();) {
-                MethodDescriptor possibleCallee = (MethodDescriptor) iterator2.next();
+            Set<MethodDescriptor> possibleCalleeSet =
+                (Set<MethodDescriptor>) ssjava.getCallGraph().getMethods(calleeMD);
 
-                if (!possibleCallee.isAbstract()) {
-                  ssjava.addAnnotationRequire(possibleCallee);
-                  tovisit.add(possibleCallee);
-                }
+            for (Iterator iterator2 = possibleCalleeSet.iterator(); iterator2.hasNext();) {
+              MethodDescriptor possibleCallee = (MethodDescriptor) iterator2.next();
 
+              if (!possibleCallee.isAbstract()) {
+                ssjava.addAnnotationRequire(possibleCallee);
+                tovisit.add(possibleCallee);
               }
 
-            } else {
-              ssjava.addAnnotationRequire(calleeMD);
             }
 
           }
@@ -150,6 +140,35 @@ public class MethodAnnotationCheck {
           }
         }
       }
+
+      // need to check super classess if the current method is inherited from
+      // them, all of ancestor method should be annoated
+      ClassDescriptor currentCd = cd;
+      ClassDescriptor superCd = tu.getSuper(currentCd);
+      while (!superCd.getSymbol().equals("Object")) {
+        Set possiblematches = superCd.getMethodTable().getSet(md.getSymbol());
+        for (Iterator methodit = possiblematches.iterator(); methodit.hasNext();) {
+          MethodDescriptor matchmd = (MethodDescriptor) methodit.next();
+          if (md.matches(matchmd)) {
+            ssjava.addAnnotationRequire(matchmd);
+          }
+        }
+        currentCd = superCd;
+        superCd = tu.getSuper(currentCd);
+      }
+
+      Set<ClassDescriptor> superIFSet = tu.getSuperIFs(cd);
+      for (Iterator iterator = superIFSet.iterator(); iterator.hasNext();) {
+        ClassDescriptor parentInterface = (ClassDescriptor) iterator.next();
+        Set possiblematches = parentInterface.getMethodTable().getSet(md.getSymbol());
+        for (Iterator methodit = possiblematches.iterator(); methodit.hasNext();) {
+          MethodDescriptor matchmd = (MethodDescriptor) methodit.next();
+          if (md.matches(matchmd)) {
+            ssjava.addAnnotationRequire(matchmd);
+          }
+        }
+      }
+
     }
 
   }