+ assert(null != m_classes);
+ assert(null != m_methods);
+ assert(null != m_lines);
+
+ m_locations.clear();
+
+ /*
+ Somewhat unfortunate special case.
+ The primary "location" for a bug instance is split between tags.
+ Most bugs have a pattern like this:
+ <BugInstance>
+ ...
+ <Method>
+ <SourceLine .../>
+ </Method>
+ ...
+ <SourceLine .../>
+ </BugInstance>
+
+ The primary location for a bug is given by the <Method> with no role attribute,
+ but the <SourceLine/> inside that method describes the whole range of lines
+ covered by that Method, not the spot where the bug is located--that is given
+ by the <SourceLine/> that is a direct child fo the <BugInstance/>.
+ */
+
+ BugMethod primaryMethod = null;
+ SourceLine primaryLine = null;
+
+ for (BugMethod method : m_methods) {
+ if (null != method.getRole()) {
+ primaryMethod = method;
+ break;
+ }
+ }
+ if (m_lines.size() > 0) {
+ primaryLine = m_lines.get(0);
+ }
+
+ if ((null != primaryMethod) && (null != primaryLine)) {
+ m_locations.add(new Location(primaryMethod, primaryLine));
+ }
+
+ for (BugMethod method : m_methods) {
+ if (primaryMethod != method) {
+ m_locations.add(new Location(method));
+ }
+ }
+ for (SourceLine line : m_lines) {
+ if (primaryLine != line) {
+ m_locations.add(new Location(line));
+ }
+ }
+ for (BugClass clazz : m_classes) {
+ m_locations.add(new Location(clazz));