1 19 package org.netbeans.modules.java.editor.overridden; 20 21 import java.util.HashSet ; 22 import java.util.Set ; 23 import java.util.logging.Level ; 24 import java.util.logging.Logger ; 25 import org.netbeans.api.java.classpath.ClassPath; 26 import org.netbeans.api.java.classpath.ClassPath.Entry; 27 import org.netbeans.api.java.classpath.GlobalPathRegistry; 28 import org.netbeans.api.java.queries.SourceForBinaryQuery; 29 import org.openide.filesystems.FileObject; 30 import org.openide.filesystems.FileStateInvalidException; 31 import org.openide.filesystems.FileUtil; 32 33 37 public class ReverseSourceRootsLookup { 38 39 40 private ReverseSourceRootsLookup() { 41 } 42 43 public static Set <FileObject> reverseSourceRootsLookup(FileObject baseSourceRoot) { 44 Set <FileObject> result = new HashSet <FileObject>(); 46 47 MAIN_LOOP: for (FileObject sourceRoot : GlobalPathRegistry.getDefault().getSourceRoots()) { 48 for (Entry compileClassPathElement : ClassPath.getClassPath(sourceRoot, ClassPath.COMPILE).entries()) { 51 for (FileObject proposedSourceRoot : SourceForBinaryQuery.findSourceRoots(compileClassPathElement.getURL()).getRoots()) { 53 if (baseSourceRoot.equals(proposedSourceRoot)) { 55 result.add(sourceRoot); 56 continue MAIN_LOOP; 57 } 58 } 59 } 60 } 61 62 return result; 63 } 64 65 } 66 | Popular Tags |