Refine search
void setSources (ClassPath sources) { String srcPath = null; if (sources.entries().size()>0) { URL folderRoot = ((ClassPath.Entry)sources.entries().get(0)).getURL(); if ("jar".equals(folderRoot.getProtocol())) { //NOI18N folderRoot = FileUtil.getArchiveFile (folderRoot); } srcPath = new File(URI.create(folderRoot.toExternalForm())).getAbsolutePath(); } setSources (srcPath); }
@Override public JavaFileObject getJavaFileForInput (Location l, final String className, JavaFileObject.Kind kind) { String[] namePair = FileObjects.getParentRelativePathAndName (className); String ext = kind == JavaFileObject.Kind.CLASS ? FileObjects.SIG : kind.extension.substring(1); //tzezula: Clearly wrong in compile on save, but "class" is also wrong for (ClassPath.Entry entry : this.sourceRoots.entries()) { FileObject root = entry.getRoot(); if (root != null) { FileObject parent = root.getFileObject(namePair[0]); if (parent != null) { FileObject[] children = parent.getChildren(); for (FileObject child : children) { if (namePair[1].equals(child.getName()) && ext.equalsIgnoreCase(child.getExt()) && (ignoreExcludes || entry.includes(child))) { return FileObjects.sourceFileObject(child, root); } } } } } return null; }
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 ); } } } } } } }
@NonNull private static List<TextStream> findJavadoc( @NonNull final URL classFile, @NonNull final String pkgName, 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) { roots.add(e.getURL()); roots.remove(e.getURL()); URL[] result = javadocResult.getRoots(); for (URL root : result) { if (!root.toExternalForm().endsWith("/")) { // NOI18N LOG.log(Level.WARNING, "JavadocForBinaryQuery.Result: {0} returned non-folder URL: {1}, ignoring", new Object[] {javadocResult.getClass(), root.toExternalForm()}); continue; URL url = new URL(root, pkgName + "/" + pageName + ".html");
for (ClassPath.Entry entry : platform.getBootstrapLibraries().entries()) { if (entry.getURL().equals (binaryRoot)) { res = new Result(platform); this.cache.put (binaryRoot, res); for (ClassPath.Entry entry : platform.getStandardLibraries().entries()) { if (entry.getURL().equals (binaryRoot)) { res = new Result(platform); this.cache.put (binaryRoot, res); String binaryRootS = binaryRoot.toExternalForm(); if (binaryRootS.startsWith(JAR_FILE)) { String srcZipS = null; URL srcZip = FileUtil.getArchiveRoot(new URL(srcZipS)); FileObject fo = URLMapper.findFileObject(srcZip); if (fo != null) {
@NonNull public synchronized URL[] ctSymRootsFor(@NonNull final ClassPath cp) { final List<URL> res = new ArrayList<>(); for (ClassPath.Entry entry : cp.entries()) { final URL root = entry.getURL(); if (!root.getPath().endsWith(NAME_INNER_RT_JAR)) { continue; } try { for (Map.Entry<URI,URI> e : ctSymToJar.entrySet()) { if (e.getValue().equals(root.toURI())) { res.add(e.getKey().toURL()); break; } } } catch (URISyntaxException | MalformedURLException e) { Exceptions.printStackTrace(e); } } return res.toArray(new URL[res.size()]); }
for (ClassPath.Entry entry : cpInfo.getClassPath(PathKind.SOURCE).entries()) { final Iterable<? extends URL> mainClasses = ExecutableFilesIndex.DEFAULT.getMainClasses(entry.getURL()); try { final URI root = entry.getURL().toURI(); for (URL mainClass : mainClasses) { try { URI relative = root.relativize(mainClass.toURI()); final String resourceNameNoExt = FileObjects.stripExtension(relative.getPath()); final String ffqn = FileObjects.convertFolder2Package(resourceNameNoExt,'/'); //NOI18N if (qualifiedName.equals(ffqn)) { final ClassPath bootCp = cpInfo.getClassPath(PathKind.BOOT); if (bootCp.findResource(resourceNameNoExt + '.' + FileObjects.CLASS)!=null) { LOG.log(Level.INFO, "Ignoring fast check for file: {0} due to: {1}", new Object[]{mainClass.toString(), e.getMessage()}); //NOI18N LOG.log(Level.INFO, "Ignoring fast check for root: {0} due to: {1}", new Object[]{entry.getURL().toString(), e.getMessage()}); //NOI18N
private File getClassFolderForSourceImpl (final URL sibling) throws IOException { List<ClassPath.Entry> entries = this.scp.entries(); int eSize = entries.size(); if ( eSize == 1) { return getClassFolder(entries.get(0).getURL()); } if (eSize == 0) { return null; } try { for (ClassPath.Entry entry : entries) { URL rootUrl = entry.getURL(); if (FileObjects.isParentOf(rootUrl, sibling)) { return getClassFolder(rootUrl); } } } catch (IllegalArgumentException e) { //Logging for issue #151416 String message = String.format("uri: %s", sibling.toString()); throw Exceptions.attachMessage(e, message); } return null; }
private static boolean equals(ClassPath cp1, ClassPath cp2) { if (cp1.entries().size() != cp2.entries().size()) { return false; } for (int i = 0; i < cp1.entries().size(); i++) { try { if (!cp1.entries().get(i).getURL().toURI() .equals(cp2.entries().get(i).getURL().toURI())) { return false; } } catch (URISyntaxException e) { if ( !cp1.entries().get(i).equals(cp2.entries().get(i)) ){ return false; } } } return true; }
private File getClassFolderForApt(final String baseName) { String[] parentName = splitParentName(baseName); for (ClassPath.Entry entry : this.apt.entries()) { FileObject root = entry.getRoot(); if (root != null) { FileObject parentFile = root.getFileObject(parentName[0]); if (parentFile != null) { if (parentFile.getFileObject(parentName[1], FileObjects.JAVA) != null) { final URL classFolder = AptCacheForSourceQuery.getClassFolder(entry.getURL()); if (classFolder != null) { try { return BaseUtilities.toFile(classFolder.toURI()); } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); } } } } } } return null; }
private File getClassFolderForApt(final @NonNull URL surl) { for (ClassPath.Entry entry : apt.entries()) { if (FileObjects.isParentOf(entry.getURL(), surl)) { final URL classFolder = AptCacheForSourceQuery.getClassFolder(entry.getURL()); if (classFolder != null) { try { return BaseUtilities.toFile(classFolder.toURI()); } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); } } } } return null; }
final Element scalaHomeElement = doc.createElement(ELEMENT_SCALAHOME); for (Iterator<FileObject> it = instance.getInstallFolders().iterator(); it.hasNext();) { URL url = it.next ().getURL(); final Element resourceElement = doc.createElement(ELEMENT_RESOURCE); resourceElement.appendChild(doc.createTextNode(url.toExternalForm())); scalaHomeElement.appendChild(resourceElement); final List<ClassPath.Entry> psl = this.instance.getSourceFolders().entries(); if (psl.size()>0 && shouldWriteSources ()) { final Element sourcesElement = doc.createElement (ELEMENT_SOURCEPATH); for (Iterator<ClassPath.Entry> it = psl.iterator(); it.hasNext();) { URL url = it.next ().getURL(); final Element resourceElement = doc.createElement (ELEMENT_RESOURCE); resourceElement.appendChild(doc.createTextNode(url.toExternalForm())); sourcesElement.appendChild(resourceElement); for (URL url : pdl) { final Element resourceElement = doc.createElement(ELEMENT_RESOURCE); resourceElement.appendChild(doc.createTextNode(url.toExternalForm())); javadocElement.appendChild(resourceElement);
final List<ClassPath.Entry> entries = this.cp.entries(); final Set<PathResourceImplementation> _cache = new LinkedHashSet<PathResourceImplementation> (); final PathRegistry preg = PathRegistry.getDefault(); final Set<URL> unInitializedSourceRoots = new HashSet<URL>(); for (ClassPath.Entry entry : entries) { URL url = entry.getURL(); URL[] sourceUrls; if (translate) { try { File cacheFolder = JavaIndex.getClassFolder(sourceUrl); URL cacheUrl = FileUtil.urlForArchiveOrDir(cacheFolder); _cache.add(ClassPathSupport.createResource(cacheUrl)); } catch (IOException ioe) { if (FileObjects.JAR.equals(url.getProtocol())) { URL foo = FileUtil.getArchiveFile(url); if (!FileObjects.FILE.equals(foo.getProtocol())) { FileObject fo = URLMapper.findFileObject(foo); if (fo != null) { foo = URLMapper.findURL(fo, URLMapper.EXTERNAL); if (FileObjects.FILE.equals(foo.getProtocol())) { url = FileUtil.getArchiveRoot(foo);
for(ClassPath.Entry entry : this.cp.entries()) { try { Archive archive = provider.getArchive( entry.getURL(), cacheFile ); if (archive != null) { Iterable<JavaFileObject> entries = archive.getFiles( folderName, ignoreExcludes?null:entry, kinds, filter); entry.getURL().toExternalForm(), packageName, kinds.toString(), LOG.finest(String.format("no cache for: %s", entry.getURL().toExternalForm())); //NOI18N
/** * Returns status of the artifact at relative path runtimePath in platform javaPlatform * @param javaPlatform the {@link JavaPlatform} where the artifact is to be searched for * @param runtimePath relative path to artifact * @return status of artifact presence/inclusion in platform */ @NonNull private static Support forRuntime(@NonNull final JavaPlatform javaPlatform, @NonNull final String runtimePath) { Parameters.notNull("javaPlatform", javaPlatform); //NOI18N Parameters.notNull("rtPath", runtimePath); //NOI18N for (FileObject installFolder : javaPlatform.getInstallFolders()) { final FileObject jfxrtJar = installFolder.getFileObject(runtimePath); if (jfxrtJar != null && jfxrtJar.isData()) { final URL jfxrtRoot = FileUtil.getArchiveRoot(jfxrtJar.toURL()); for (ClassPath.Entry e : javaPlatform.getBootstrapLibraries().entries()) { if (jfxrtRoot.equals(e.getURL())) { return Support.INCLUDED; } } return Support.PRESENT; } } return Support.MISSING; }
private boolean shouldWriteSources () { if (defaultPlatform) { assert this.instance instanceof DefaultPlatformImpl; DefaultPlatformImpl dp = (DefaultPlatformImpl) this.instance; List<ClassPath.Entry> sfEntries = dp.getSourceFolders().entries(); List<URL> defaultSf = DefaultPlatformImpl.getSources (FileUtil.normalizeFile(new File((String)dp.getSystemProperties().get("jdk.home")))); //NOI18N if (defaultSf == null || sfEntries.size() != defaultSf.size()) { return true; } Iterator<ClassPath.Entry> sfit = sfEntries.iterator(); Iterator<URL> defif = defaultSf.iterator(); while (sfit.hasNext()) { ClassPath.Entry entry = sfit.next (); URL url = defif.next(); if (!url.equals(entry.getURL())) { return true; } } return false; } return true; }
@Override public Iterable<JavaFileObject> list(final Location l, final String packageName, final Set<JavaFileObject.Kind> kinds, final boolean recursive) { //Todo: Caching of results, needs listening on FS List<JavaFileObject> result = new ArrayList<JavaFileObject> (); String _name = packageName.replace('.','/'); //NOI18N if (_name.length() != 0) { _name+='/'; //NOI18N } for (ClassPath.Entry entry : this.sourceRoots.entries()) { if (ignoreExcludes || entry.includes(_name)) { FileObject root = entry.getRoot(); if (root != null) { FileObject tmpFile = root.getFileObject(_name); if (tmpFile != null && tmpFile.isFolder()) { Enumeration<? extends FileObject> files = tmpFile.getChildren (recursive); while (files.hasMoreElements()) { FileObject file = files.nextElement(); if (ignoreExcludes || entry.includes(file)) { final JavaFileObject.Kind kind = FileObjects.getKind(file.getExt()); if (kinds.contains(kind)) { result.add (FileObjects.sourceFileObject(file, root)); } } } } } } } return result; }
if (platformVersion.equals(JsfProjectUtils.J2EE_1_3) || platformVersion.equals(JsfProjectUtils.J2EE_1_4)) { FileObject wsClientsSubDir = project.getProjectDirectory().getFileObject( JsfProjectConstants.PATH_LIBRARIES + '/'+ WEBSERVICE_CLIENTS_SUB_DIR); if (wsClientsSubDir != null && hasJarFiles(wsClientsSubDir)) { FileObject ejbClientsSubDir = project.getProjectDirectory().getFileObject( JsfProjectConstants.PATH_LIBRARIES + '/'+ EJB_DATA_SUB_DIR); hasEjbClients = (ejbClientsSubDir != null && hasJarFiles(ejbClientsSubDir)); classPath = ClassPath.getClassPath(JsfProjectUtils.getPageBeanRoot(project), "classpath/packaged"); // NOI18N if(classPath == null) { classPath = ClassPath.getClassPath(JsfProjectUtils.getPageBeanRoot(project), ClassPath.COMPILE); URLClassLoader classPathClassLoader = (URLClassLoader) classPath.getClassLoader(true); URL urls[] = classPathClassLoader.getURLs(); urlSet.addAll(Arrays.asList(urls)); for(ClassPath.Entry entry: classPath.entries()) { urlSet.add(entry.getURL()); File docPath = FileUtil.toFile(docRoot); File buildClassPath = new File(docPath.getParentFile(), "build" + File.separator + // NOI18N "web" + File.separator + "WEB-INF" + File.separator + "classes"); // NOI18N