예제 #1
0
 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";
 }
예제 #2
0
 private static void addSourceLines(Collection<TaintLocation> locations, BugInstance bugInstance) {
   List<SourceLineAnnotation> annotations = new LinkedList<SourceLineAnnotation>();
   for (TaintLocation location : locations) {
     SourceLineAnnotation taintSource =
         SourceLineAnnotation.fromVisitedInstruction(
             location.getMethodDescriptor(), location.getPosition());
     annotations.add(taintSource);
   }
   Collections.sort(annotations);
   SourceLineAnnotation annotation = null;
   for (Iterator<SourceLineAnnotation> it = annotations.iterator(); it.hasNext(); ) {
     SourceLineAnnotation prev = annotation;
     annotation = it.next();
     if (prev != null
         && prev.getClassName().equals(annotation.getClassName())
         && prev.getStartLine() == annotation.getStartLine()) {
       // keep only one annotation per line
       it.remove();
     }
   }
   for (SourceLineAnnotation sourceLine : annotations) {
     bugInstance.addSourceLine(sourceLine);
   }
 }