X-Git-Url: http://jaekl.net/gitweb/?a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fxml%2FBugInstance.java;h=b805096c67551c7f3a35847b12f6660bc35acca0;hb=7ac6be132ecd6872971a1de56f033b4434d3173a;hp=96a815e5aaa41089beafd6599878a83d0e922e3a;hpb=8e5bdf0294e85b4419ee1e582d5677cccd3f736e;p=cfb.git diff --git a/prod/net/jaekl/cfb/xml/BugInstance.java b/prod/net/jaekl/cfb/xml/BugInstance.java index 96a815e..b805096 100644 --- a/prod/net/jaekl/cfb/xml/BugInstance.java +++ b/prod/net/jaekl/cfb/xml/BugInstance.java @@ -57,9 +57,11 @@ public class BugInstance extends ParseResult { m_id = id; m_category = category; m_type = type; - m_classes = null; - m_methods = null; - m_lines = null; + + m_classes = new ArrayList(); + m_methods = new ArrayList(); + m_lines = new ArrayList(); + m_locations = new ArrayList(Arrays.asList(locations)); m_locals = new ArrayList(Arrays.asList(variables)); } @@ -138,11 +140,18 @@ public class BugInstance extends ParseResult { bm.dump(pw, childIndent); } for (LocalVariable lv : m_locals) { - lv.dump(pw, childIndent); + if (null != lv) { + lv.dump(pw, childIndent); + } } for (SourceLine sl : m_lines) { sl.dump(pw, childIndent); } + for (Location loc : m_locations) { + if (null != loc) { + loc.dump(pw, childIndent); + } + } } // Note that this is a heuristic, "fuzzy", equals. @@ -180,16 +189,9 @@ public class BugInstance extends ParseResult { } } else { - if (! Util.objsAreEqual(thisLoc.getClassName(), thatLoc.getClassName())) { + if (! thisLoc.fuzzyEquals(thatLoc)) { return false; } - if (! Util.objsAreEqual(thisLoc.getMethodName(), thatLoc.getMethodName())) { - return false; - } - } - - if (! Util.objsAreEqual(this.getVariables(), that.getVariables())) { - return false; } return true; @@ -201,9 +203,8 @@ public class BugInstance extends ParseResult { public int hashCode() { int code = Util.objHashCode(m_type) - * Util.objHashCode(m_category) - * Util.objHashCode(getPrincipalLocation()) - * Util.objHashCode(getVariables()); + ^ Util.objHashCode(m_category) + ^ Util.objHashCode(getPrincipalLocation()); return code; } @@ -211,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; }