@Override public void sawBranchTo(int target) { Iterator<BugInstance> i = pendingBugs.iterator(); while (i.hasNext()) { BugInstance bug = i.next(); if (bug.getPrimarySourceLineAnnotation().getStartBytecode() >= target) { i.remove(); } } }
@Override public BugInstance findBug(String instanceHash, String bugType, int lineNumber) { for (BugInstance bug : bugSet) { if (bug.getInstanceHash().equals(instanceHash) && bug.getBugPattern().getType().equals(bugType) && bug.getPrimarySourceLineAnnotation().getStartLine() == lineNumber) { return bug; } } return null; }
/** * Called when a bug is reported. */ public void addBug(BugInstance bug) { SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation(); PackageStats stat = getPackageStats(source.getPackageName()); stat.addError(bug); ++totalErrors[0]; int priority = bug.getPriority(); if (priority >= 1) { ++totalErrors[Math.min(priority, totalErrors.length - 1)]; } }
SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation();
matching.add(warning.getPrimarySourceLineAnnotation()); matching.addAll(warning.getAnotherInstanceSourceLineAnnotations()); continue; matching.add(warning.getPrimarySourceLineAnnotation()); matching.addAll(warning.getAnotherInstanceSourceLineAnnotations());
outputStream.print(" "); SourceLineAnnotation line = bugInstance.getPrimarySourceLineAnnotation(); outputStream.println(bugInstance.getMessage().replace('\n', ' ') + " " + line.toString());
/** * Returns a printable String concatenating bug locations. */ private static String getBugsLocations(List<BugInstance> unexpectedBugs) { StringBuilder message = new StringBuilder(); for (BugInstance bugInstance : unexpectedBugs) { message.append("\n"); if (bugInstance.getBugPattern().getType().equals(FB_MISSING_EXPECTED_WARNING)) { message.append("missing "); } else { message.append("unexpected "); } StringAnnotation pattern = (StringAnnotation) bugInstance.getAnnotations().get(2); message.append(pattern.getValue()); message.append(" "); message.append(bugInstance.getPrimarySourceLineAnnotation()); } return message.toString(); }
@Override public void addError(BugInstance bug) { super.addError(bug); SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation(); // see bug https://sourceforge.net/tracker/index.php?func=detail&aid=3322583&group_id=96405&atid=614693 // always add class stats to see useful details in package stats fancy.xsl output getClassStats(source.getClassName(), source.getSourceFile()).addError(bug); }
String fullPath = "???"; SourceLineAnnotation line = bugInstance.getPrimarySourceLineAnnotation();
ClassAnnotation primeClass = getPrimaryClass(); SourceLineAnnotation primarySourceLineAnnotation = getPrimarySourceLineAnnotation(); optionalAdd(primaryAnnotations, primarySourceLineAnnotation); optionalAdd(primaryAnnotations, primeMethod);
@After public void checkForUnexpectedBugs() { List<BugInstance> unexpectedBugs = new ArrayList<>(); for (BugInstance bug : bugReporter.getBugCollection()) { if (isUnexpectedBug(bug) && bug.getPriority() == Priorities.HIGH_PRIORITY) { unexpectedBugs.add(bug); System.out.println(bug.getMessageWithPriorityTypeAbbreviation()); System.out.println(" " + bug.getPrimarySourceLineAnnotation()); } } if (!unexpectedBugs.isEmpty()) { Assert.fail("Unexpected bugs (" + unexpectedBugs.size() + "):" + getBugsLocations(unexpectedBugs)); } }
sourceSearcher = new SourceSearcher(project); for (BugInstance bug : origCollection.getCollection()) { SourceLineAnnotation src = bug.getPrimarySourceLineAnnotation(); if (!sourceSearcher.sourceNotFound.contains(src.getClassName()) && !sourceSearcher.findSource(src)) { Set<String> paths = missingFiles.get(src.getSourceFile());
primaryAnnotations.put(getPrimarySourceLineAnnotation(), null); primaryAnnotations.put(getPrimaryClass(), null); primaryAnnotations.put(getPrimaryField(), null); SourceLineAnnotation synth = getPrimarySourceLineAnnotation(); synth.setSynthetic(true); synth.writeXML(xmlOutput, addMessages, false);
return false; SourceLineAnnotation primarySourceLineAnnotation = bug.getPrimarySourceLineAnnotation();
public void toElement(BugInstance bugInstance) { String className = bugInstance.getPrimaryClass().getClassName(); Element element = (Element) root.selectSingleNode(FILE_ELEMENT_NAME + "[@classname='" + className + "']"); if (element == null) { element = root.addElement(FILE_ELEMENT_NAME); element.addAttribute("classname", className); } element = element.addElement(ELEMENT_NAME); element.addAttribute("type", bugInstance.getType()); switch (bugInstance.getPriority()) { case Priorities.EXP_PRIORITY: element.addAttribute("priority", "Experimental"); break; case Priorities.LOW_PRIORITY: element.addAttribute("priority", "Low"); break; case Priorities.NORMAL_PRIORITY: element.addAttribute("priority", "Normal"); break; case Priorities.HIGH_PRIORITY: element.addAttribute("priority", "High"); break; default: assert false; } element.addAttribute("message", xmlEscape(bugInstance.getMessage())); SourceLineAnnotation line = bugInstance.getPrimarySourceLineAnnotation(); element.addAttribute("line", Integer.toString(line.getStartLine())); }
@Override public void sawBranchTo(int target) { Iterator<BugInstance> i = pendingBugs.iterator(); while (i.hasNext()) { BugInstance bug = i.next(); if (bug.getPrimarySourceLineAnnotation().getStartBytecode() >= target) { i.remove(); } } }
@Override public BugInstance findBug(String instanceHash, String bugType, int lineNumber) { for (BugInstance bug : bugSet) { if (bug.getInstanceHash().equals(instanceHash) && bug.getBugPattern().getType().equals(bugType) && bug.getPrimarySourceLineAnnotation().getStartLine() == lineNumber) { return bug; } } return null; }
private String printBug(BugInstance bug, List<AnalyzerConfig.Path> sources) { final int rank = BugRanker.findRank(bug); final SourceLineAnnotation line = bug.getPrimarySourceLineAnnotation(); final int startLine = line.getStartLine() <= 0 ? 0 : line.getStartLine(); final String msg = bug.getMessage(); final int pos = msg.indexOf(':'); final String message = msg.substring(pos + 2).replace('\n', ' '); return String.format("%2d %-8s %-45s %s:%d %s", rank, priority(bug), bug.getType(), sourcePath(line.getSourcePath(), sources), startLine, message); }
@Override public String getFrom(BugInstance bug) { int count = GUISaveState.getInstance().getPackagePrefixSegments(); if (count < 1) { count = 1; } String packageName = bug.getPrimarySourceLineAnnotation().getPackageName(); return ClassName.extractPackagePrefix(packageName, count); }
@Override public void addError(BugInstance bug) { super.addError(bug); SourceLineAnnotation source = bug.getPrimarySourceLineAnnotation(); // see bug https://sourceforge.net/tracker/index.php?func=detail&aid=3322583&group_id=96405&atid=614693 // always add class stats to see useful details in package stats fancy.xsl output getClassStats(source.getClassName(), source.getSourceFile()).addError(bug); }