public String getSourcePath() { String classname = getClassName(); String packageName = ""; if (classname.indexOf('.') > 0) { packageName = classname.substring(0, 1 + classname.lastIndexOf('.')); } String sourcePath = packageName.replace('.', CANONICAL_PACKAGE_SEPARATOR) + sourceFile; return sourcePath; }
public boolean findSource(SourceLineAnnotation srcLine) { if (srcLine == null) { return false; } String cName = srcLine.getClassName(); if (sourceFound.contains(cName)) { return true; } if (sourceNotFound.contains(cName)) { return false; } boolean result = sourceFinder.hasSourceFile(srcLine); return result; }
public static String getOrGuessSourceFile(SourceLineAnnotation source) { if (source.isSourceFileKnown()) { return source.getSourceFile(); } String baseClassName = source.getClassName(); int i = baseClassName.lastIndexOf('.'); baseClassName = baseClassName.substring(i + 1); int j = baseClassName.indexOf('$'); if (j >= 0) { baseClassName = baseClassName.substring(0, j); } return baseClassName + ".java"; }
public boolean findSource0(SourceLineAnnotation srcLine) { if (srcLine == null) { return false; } String cName = srcLine.getClassName(); if (sourceFound.contains(cName)) { return true; } if (sourceNotFound.contains(cName)) { return false; } try { InputStream in = sourceFinder.openSource(srcLine); in.close(); sourceFound.add(cName); return true; } catch (IOException e1) { sourceNotFound.add(cName); return false; } }
/** * Compare source line annotations. * * @param rhsCollection * lhs BugCollection * @param lhsCollection * rhs BugCollection * @param lhs * a SourceLineAnnotation * @param rhs * another SourceLineAnnotation * @return comparison of lhs and rhs */ public int compareSourceLines(BugCollection lhsCollection, BugCollection rhsCollection, SourceLineAnnotation lhs, SourceLineAnnotation rhs) { if (lhs == null || rhs == null) { return compareNullElements(lhs, rhs); } // Classes must match fuzzily. int cmp = compareClassesByName(lhsCollection, rhsCollection, lhs.getClassName(), rhs.getClassName()); if (cmp != 0) { return cmp; } return 0; }
@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); }
@Override public void writeXML(XMLOutput xmlOutput, boolean addMessages, boolean isPrimary) throws IOException { String classname = getClassName(); String sourcePath = getSourcePath();
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()); if (paths == null) {
static SourceLineAnnotation obfuscate(SourceLineAnnotation m) { SourceLineAnnotation result = new SourceLineAnnotation(hashClass(m.getClassName()), hashFilename(m.getSourceFile()), m.getStartLine(), m.getEndLine(), m.getStartBytecode(), m.getEndBytecode()); result.setDescription(m.getDescription()); return result; }
public String getSourcePath() { String classname = getClassName(); String packageName = ""; if (classname.indexOf('.') > 0) { packageName = classname.substring(0, 1 + classname.lastIndexOf('.')); } String sourcePath = packageName.replace('.', CANONICAL_PACKAGE_SEPARATOR) + sourceFile; return sourcePath; }
@Override public String getFrom(BugInstance bug) { return bug.getPrimarySourceLineAnnotation().getClassName(); }
public boolean findSource(SourceLineAnnotation srcLine) { if (srcLine == null) { return false; } String cName = srcLine.getClassName(); if (sourceFound.contains(cName)) { return true; } if (sourceNotFound.contains(cName)) { return false; } boolean result = sourceFinder.hasSourceFile(srcLine); return result; }
public static String getOrGuessSourceFile(SourceLineAnnotation source) { if (source.isSourceFileKnown()) { return source.getSourceFile(); } String baseClassName = source.getClassName(); int i = baseClassName.lastIndexOf('.'); baseClassName = baseClassName.substring(i + 1); int j = baseClassName.indexOf('$'); if (j >= 0) { baseClassName = baseClassName.substring(0, j); } return baseClassName + ".java"; }
public boolean findSource0(SourceLineAnnotation srcLine) { if (srcLine == null) { return false; } String cName = srcLine.getClassName(); if (sourceFound.contains(cName)) { return true; } if (sourceNotFound.contains(cName)) { return false; } try { InputStream in = sourceFinder.openSource(srcLine); in.close(); sourceFound.add(cName); return true; } catch (IOException e1) { sourceNotFound.add(cName); return false; } }
/** * Compare source line annotations. * * @param rhsCollection * lhs BugCollection * @param lhsCollection * rhs BugCollection * @param lhs * a SourceLineAnnotation * @param rhs * another SourceLineAnnotation * @return comparison of lhs and rhs */ public int compareSourceLines(BugCollection lhsCollection, BugCollection rhsCollection, SourceLineAnnotation lhs, SourceLineAnnotation rhs) { if (lhs == null || rhs == null) { return compareNullElements(lhs, rhs); } // Classes must match fuzzily. int cmp = compareClassesByName(lhsCollection, rhsCollection, lhs.getClassName(), rhs.getClassName()); if (cmp != 0) { return cmp; } return 0; }
public ReportedBug(BugInstance bugInstance) { this.type = bugInstance.getType(); this.message = bugInstance.getMessageWithoutPrefix(); this.className = bugInstance.getPrimarySourceLineAnnotation().getClassName(); this.startLine = bugInstance.getPrimarySourceLineAnnotation().getStartLine(); this.sourceFile = bugInstance.getPrimarySourceLineAnnotation().getSourcePath(); Matcher m = SOURCE_FILE_PATTERN.matcher(sourceFile); if (m.find()) { this.classFile = m.group(1).replaceAll("/","."); } else { this.classFile = className; } }
@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); }
@Nonnull private JavaSourceDocument getDocument(SourceLineAnnotation source) { try { SourceFile sourceFile = frame.getProject().getSourceFinder().findSourceFile(source); String fullFileName = sourceFile.getFullFileName(); SoftReference<JavaSourceDocument> resultReference = map.get(fullFileName); JavaSourceDocument result = null; if (resultReference != null) { result = resultReference.get(); } if (result != null) { return result; } try { InputStream in = sourceFile.getInputStream(); result = new JavaSourceDocument(source.getClassName(), SourceCharset.bufferedReader(in), sourceFile); } catch (Exception e) { result = JavaSourceDocument.UNKNOWNSOURCE; Debug.println(e); // e.printStackTrace(); } map.put(fullFileName, new SoftReference<JavaSourceDocument>(result)); return result; } catch (Exception e) { Debug.println(e); // e.printStackTrace(); return JavaSourceDocument.UNKNOWNSOURCE; } }
static SourceLineAnnotation obfuscate(SourceLineAnnotation m) { SourceLineAnnotation result = new SourceLineAnnotation(hashClass(m.getClassName()), hashFilename(m.getSourceFile()), m.getStartLine(), m.getEndLine(), m.getStartBytecode(), m.getEndBytecode()); result.setDescription(m.getDescription()); return result; }
result = oneSource.getClassName().compareTo(twoSource.getClassName()); if (result != 0) { return result;