Exclude "METHOD_CALLED" references from consideration as a bug's principal location.
[cfb.git] / prod / net / jaekl / cfb / xml / BugInstance.java
index 0683a7d23c83dd1437b08ebe77bd545d01a830f4..b805096c67551c7f3a35847b12f6660bc35acca0 100644 (file)
@@ -212,9 +212,21 @@ public class BugInstance extends ParseResult {
        // This should be the place where the bug is reported.
        Location getPrincipalLocation()
        {
-               if (null != m_locations && m_locations.size() > 0) {
-                       return m_locations.get(0);
+               if (null == m_locations) {
+                       return null;
                }
+               
+               for (int idx = 0; idx < m_locations.size(); ++idx) {
+                       Location loc = m_locations.get(idx);
+                       if (Location.METHOD_CALLED.equals(loc.getMethodRole())) {
+                               // METHOD_CALLED locations describe the method that is being called,
+                               // but the bug is located in the caller, not in the callee.
+                               // Thus, ignore this information about the callee.
+                               continue;
+                       }
+                       return loc;
+               }
+               
                return null;
        }