Refine search
private static void collectConfigurationFilesFromClassPath(ClassPath cp, List<FileObject> configs, List<FileObject> configRoots) { for (ClassPath.Entry entry : cp.entries()) { FileObject roots[]; if (entry.isValid()) { roots = new FileObject[]{entry.getRoot()}; } else { // if classpath root does not exist then perhaps it is // a project which has not been built - use SourceForBinaryQuery // to use project sources instead: SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(entry.getURL()); roots = res.getRoots(); } for (FileObject root : roots) { configRoots.add(root); FileObject metaInf = root.getFileObject(META_INF); if (metaInf != null) { FileObject[] children = metaInf.getChildren(); for (FileObject fileObject : children) { String name = fileObject.getNameExt(); if (name.equals(FACES_CONFIG) || name.endsWith(FACES_CONFIG_SUFFIX)) { if(!configs.contains(fileObject)) { //do not duplicate configs.add( fileObject ); } } } } } } }
static FileObject getFileForClass(FileObject fileInProject, String className) { ClassPath cp = ClassPath.getClassPath(fileInProject, ClassPath.SOURCE); FileObject file = cp.findResource(className.replace('.', '/') + ".java"); // NOI18N if (file == null && !isApplicationProject(fileInProject)) { // specific case - may want user's application class source file // in another project this one depends on (makes no sense to look // into the other projects otherwise) for (ClassPath.Entry e : ClassPath.getClassPath(fileInProject, ClassPath.COMPILE).entries()) { SourceForBinaryQuery.Result2 sr = SourceForBinaryQuery.findSourceRoots2(e.getURL()); if (sr != null && sr.preferSources()) { FileObject[] sourceRoots = sr.getRoots(); if (sourceRoots != null && sourceRoots.length > 0) { cp = ClassPath.getClassPath(sourceRoots[0], ClassPath.SOURCE); file = cp.findResource(className.replace('.', '/') + ".java"); // NOI18N if (file != null) { break; } } } } } return file; }
public void actionPerformed(ActionEvent e) { DataObject dobj = getOriginal().getLookup().lookup(DataObject.class); if (dobj != null && (javadoc || !dobj.getPrimaryFile().isFolder())) { try { FileObject fil = dobj.getPrimaryFile(); JavadocForBinaryQuery.Result res = JavadocForBinaryQuery.findJavadoc(root.getURL()); if (fil.isFolder()) { rel = rel + "/package-summary.html"; //NOI18N SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(root.getURL()); for (FileObject srcRoot : res.getRoots()) { FileObject src = srcRoot.getFileObject(rel); if (src != null) {
String packageName = method.substring(0, index).replace('.', '/'); //NOI18N String resourceName = packageName + file + ".class"; //NOI18N FileObject resource = classPath.findResource(resourceName); if (resource != null) { FileObject root = classPath.findOwnerRoot(resource); URL url = URLMapper.findURL(root, URLMapper.INTERNAL); SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(url); FileObject[] rootz = res.getRoots(); for (int i = 0; i < rootz.length; i++) { String path = packageName + file + ".java"; //NOI18N FileObject javaFo = rootz[i].getFileObject(path); if (javaFo != null) { try {
StringTokenizer tk = new StringTokenizer(pkgName, "/"); // NOI18N for (int i = 0; fo != null && i <= tk.countTokens(); i++) { fo = fo.getParent(); final URL url = CachingArchiveProvider.getDefault().mapCtSymToJar(fo.toURL()); sourceRoot = JavaIndex.getSourceRootForClassFolder(url); if (sourceRoot == null) { FileObject sourceFo = URLMapper.findFileObject(sourceRoot); if (sourceFo != null) { ClassPath exec = ClassPath.getClassPath(sourceFo, ClassPath.EXECUTE); ClassPath compile = ClassPath.getClassPath(sourceFo, ClassPath.COMPILE); ClassPath source = ClassPath.getClassPath(sourceFo, ClassPath.SOURCE); if (exec == null) { exec = compile; out: for (URL e : roots) { FileObject[] res = SourceForBinaryQuery.findSourceRoots(e).getRoots(); for (FileObject r : res) { if (sourceRoots.contains(r)) {
private static FileObject getFileFromClasspath(ClassPath cp, String classRelativePath) { for (ClassPath.Entry entry : cp.entries()) { FileObject roots[]; if (entry.isValid()) { roots = new FileObject[]{entry.getRoot()}; } else { SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(entry.getURL()); roots = res.getRoots(); } for (FileObject root : roots) { FileObject metaInf = root.getFileObject(classRelativePath); if (metaInf != null) { return metaInf; } } } return null; }
private String classToSourceURL (FileObject fo, Log logger) { try { ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE); FileObject root = cp.findOwnerRoot (fo); String resourceName = cp.getResourceName (fo, '/', false); if (resourceName == null) { logger.info("Can not find classpath resource for "+fo+", skipping..."); return null; } int i = resourceName.indexOf ('$'); if (i > 0) resourceName = resourceName.substring (0, i); FileObject[] sRoots = SourceForBinaryQuery.findSourceRoots (root.getURL ()).getRoots (); ClassPath sourcePath = ClassPathSupport.createClassPath (sRoots); FileObject rfo = sourcePath.findResource (resourceName + ".java"); if (rfo == null) return null; return rfo.getURL ().toExternalForm (); } catch (FileStateInvalidException ex) { ex.printStackTrace (); return null; } }
projectSourceRoots = getSourceRoots(originalSourcePath); Set<FileObject> preferredRoots = new HashSet<FileObject>(); preferredRoots.addAll(Arrays.asList(originalSourcePath.getRoots())); Set<FileObject> globalRoots = new TreeSet<FileObject>(new FileObjectComparator()); globalRoots.addAll(GlobalPathRegistry.getDefault().getSourceRoots()); SourceGroup[] sgs = ProjectUtils.getSources(mainProject).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); for (SourceGroup sg : sgs) { ClassPath ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE); if (ecp == null) { ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE); FileObject[] roots = SourceForBinaryQuery.findSourceRoots(fo.getURL()).getRoots(); for (FileObject fr : roots) { if (!preferredRoots.contains(fr)) {
ClassPath scp = ClassPath.getClassPath(srcFile, ClassPath.SOURCE); if (scp != null) { FileObject resFO = scp.findResource(bundleFileResName); if (resFO != null) return resFO; ClassPath ecp = ClassPath.getClassPath(srcFile, ClassPath.EXECUTE); Iterator it = ecp.entries().iterator(); while (it.hasNext()) { ClassPath.Entry e = (ClassPath.Entry) it.next(); SourceForBinaryQuery.Result r = SourceForBinaryQuery.findSourceRoots(e.getURL()); FileObject[] sourceRoots = r.getRoots(); for (int i=0; i < sourceRoots.length; i++) {
Arrays.asList(smartSteppingSourcePath.getRoots())); for (FileObject fo : new HashSet<FileObject>(enabledSourcePath)) { if (disabledRoots.contains(getRoot(fo))) { boolean isSourcepath = false; if ("sourcepath".equalsIgnoreCase(listeningCP)) { listeningCP = ((ClassPath) properties.get ("sourcepath")).toString(ClassPath.PathConversionMode.SKIP); isSourcepath = true; for (FileObject src : SourceForBinaryQuery.findSourceRoots(entry).getRoots()) { srcRootsToListenForArtifactsUpdates.add(src); SourceGroup[] sgs = ProjectUtils.getSources(mainProject).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); for (SourceGroup sg : sgs) { ClassPath ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE); if (ecp == null) { ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE); FileObject[] roots = SourceForBinaryQuery.findSourceRoots(fo.toURL()).getRoots(); for (FileObject fr : roots) { if (!preferredRoots.contains(fr)) {
ClassPath cp = it.next(); try { for (ClassPath.Entry entry : cp.entries()) { roots.add (entry.getURL()); ClassPath cp = it.next(); try { for (Iterator<ClassPath.Entry> eit = cp.entries().iterator(); eit.hasNext();) { ClassPath.Entry entry = eit.next(); sroots.add (entry.getURL()); ClassPath cp = it.next (); try { for (Iterator<ClassPath.Entry> eit = cp.entries().iterator(); eit.hasNext();) { ClassPath.Entry entry = eit.next (); FileObject[] fos = SourceForBinaryQuery.findSourceRoots(entry.getURL()).getRoots(); for (int i=0; i< fos.length; i++) { try { if (sroots.contains(fos[i].getURL())) { roots.add (entry.getURL());
FileObject[] rootsCP = cp.getRoots(); for(FileObject fo: rootsCP){ try{ FileObject[] aaa = SourceForBinaryQuery.findSourceRoots(fo.getURL()).getRoots(); roots.addAll(Arrays.asList(aaa)); }catch(Exception e){} roots.addAll(Arrays.asList(platform.getSourceFolders().getRoots()));
private static boolean isTest(final @NonNull FileObject root, final @NonNull Project project) { assert root != null; assert project != null; final ClassPath cp = ClassPath.getClassPath(root, ClassPath.COMPILE); for (ClassPath.Entry entry : cp.entries()) { final FileObject[] srcRoots = SourceForBinaryQuery.findSourceRoots(entry.getURL()).getRoots(); for (FileObject srcRoot : srcRoots) { if (project.equals(FileOwnerQuery.getOwner(srcRoot))) { return true; } } } return false; }
FileObject root = pair.second().findOwnerRoot(pair.first()); if (root == null) { continue; FileObject[] sourceRoots = SourceForBinaryQuery.findSourceRoots(root.toURL()).getRoots(); ClassPath sourcePath = ClassPathSupport.createClassPath(sourceRoots); LinkedList<FileObject> folders = new LinkedList<>(sourcePath.findAllResources(pkgName)); if (pkg) { return folders.isEmpty() ? pair.first() : folders.get(0); FileObject match = findMatchingChild(candidate, folders, caseSensitive); if (match != null) { FileObject ownerRoot = sourcePath.entries().isEmpty() ? root : sourcePath.findOwnerRoot(match); FQN2Files fQN2Files = ownerRoot != null ? FQN2Files.forRoot(ownerRoot.toURL()) : null; if (fQN2Files == null || !fQN2Files.check(signature[0], match.toURL())) { return match;
private static void addSourceRoots(ClassPath ecp, List<FileObject> allSourceRoots, Set<FileObject> addedBinaryRoots, Set<FileObject> preferredRoots) { FileObject[] binaryRoots = ecp.getRoots(); for (FileObject fo : binaryRoots) { if (addedBinaryRoots.contains(fo)) { continue; } addedBinaryRoots.add(fo); FileObject[] roots = SourceForBinaryQuery.findSourceRoots(fo.toURL()).getRoots(); for (FileObject fr : roots) { if (!preferredRoots.contains(fr)) { allSourceRoots.add(fr); preferredRoots.add(fr); } } } }
URL url = Utils.fileToURL(fs[i]); try { FileObject[] srcfos = SourceForBinaryQuery.findSourceRoots(url).getRoots(); for (int j = 0; j < srcfos.length; j++) { if (FileUtil.isArchiveFile(srcfos[j])) { url = srcfos[j].getURL(); if (!url.toExternalForm().endsWith("/")) { url = new URL(url.toExternalForm() + "/");
continue; FileObject[] someRoots = SourceForBinaryQuery.findSourceRoots(binroot).getRoots(); result.addAll(Arrays.asList(someRoots)); result.addAll(Arrays.asList(data.platformSources.getRoots())); } else { result.addAll(Arrays.asList(plat.getSourceFolders().getRoots()));
private static void sources(File targetFolder, FileObject[][] sources) throws MalformedURLException { if (sources[0] == null) { URL targetFolderURL = FileUtil.urlForArchiveOrDir(targetFolder); sources[0] = SourceForBinaryQuery.findSourceRoots(targetFolderURL).getRoots(); } }
private static boolean hasSourceCache(@NonNull final URL root) { return SourceForBinaryQuery.findSourceRoots2(root).preferSources(); }
String relPath = qualifiedName.replace('.', '/') + ".class"; //NOI18N ClassPath classPath = js.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE); for (ClassPath.Entry entry : classPath.entries()) { FileObject[] roots; if (entry.isValid()) { roots = new FileObject[]{entry.getRoot()}; } else { SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(entry.getURL()); roots = res.getRoots(); file = root.getFileObject(relPath); if (file != null) { return file;