1 19 20 package edu.umd.cs.findbugs.workflow; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 import java.util.HashSet ; 25 26 import edu.umd.cs.findbugs.Project; 27 import edu.umd.cs.findbugs.SourceLineAnnotation; 28 import edu.umd.cs.findbugs.ba.SourceFinder; 29 30 33 public class SourceSearcher { 34 HashSet <String > sourceFound = new HashSet <String >(); 35 HashSet <String > sourceNotFound = new HashSet <String >(); 36 SourceFinder sourceFinder = new SourceFinder(); 37 38 public SourceSearcher(Project project) { 39 sourceFinder.setSourceBaseList(project.getSourceDirList()); 40 } 41 42 public boolean findSource(SourceLineAnnotation srcLine) { 43 if (srcLine == null) return false; 44 String sourceFile = srcLine.getSourceFile(); 45 if (sourceFile != null && !sourceFile.equals("<Unknown>")) { 46 47 String cName = srcLine.getClassName(); 48 if (sourceFound.contains(cName)) return true; 49 if (sourceNotFound.contains(cName)) return false; 50 try { 51 InputStream in = sourceFinder.openSource(srcLine.getPackageName(), sourceFile); 52 in.close(); 53 sourceFound.add(cName); 54 return true; 55 } catch (IOException e) { 56 assert true; sourceNotFound.add(cName); 58 } 59 } 60 return false; 61 } 62 63 } 64 | Popular Tags |