@Override public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException { if (!hasLocation(location)) { throw new IllegalArgumentException(String.valueOf(location)); } final File root = new File(outputRoot); final File file = FileUtil.normalizeFile(new File ( root, FileObjects.resolveRelativePath(packageName, relativeName).replace(FileObjects.NBFS_SEPARATOR_CHAR, File.separatorChar))); //NOI18N return tx.createFileObject(location, file, root,null,null); }
@Override public javax.tools.FileObject getFileForInput (final Location l, final String pkgName, final String relativeName) { final String rp = FileObjects.resolveRelativePath (pkgName, relativeName); final FileObject[] fileRootPair = findFile(rp); return fileRootPair == null ? null : FileObjects.sourceFileObject(fileRootPair[0], fileRootPair[1]); }
@Override public javax.tools.FileObject getFileForInput(Location l, String pkgName, String relativeName) { final String[] names = FileObjects.getFolderAndBaseName( FileObjects.resolveRelativePath(pkgName, relativeName), FileObjects.NBFS_SEPARATOR_CHAR); javax.tools.FileObject fo = tx.readFileObject(l, names[0], names[1]); if (fo != null) { return fo; } return super.getFileForInput(l, pkgName, relativeName); }
@Override public javax.tools.FileObject getFileForOutput( Location l, String pkgName, String relativeName, javax.tools.FileObject sibling ) throws IOException, UnsupportedOperationException, IllegalArgumentException { if (!allowOutput) { throw new UnsupportedOperationException("Output is unsupported."); //NOI18N } javax.tools.JavaFileObject file = findFile (pkgName, relativeName); if (file == null) { final List<ClassPath.Entry> entries = this.cp.entries(); if (!entries.isEmpty()) { final String resourceName = FileObjects.resolveRelativePath(pkgName, relativeName); file = provider.getArchive(entries.get(0).getURL(), cacheFile).create(resourceName, filter); } } return file; //todo: wrap to make read only }
@Override public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException { if (!hasLocation(location)) { throw new IllegalArgumentException(String.valueOf(location)); } final File root = new File(outputRoot); final String path = FileObjects.resolveRelativePath(packageName, relativeName); final String[] names = FileObjects.getFolderAndBaseName(path, FileObjects.NBFS_SEPARATOR_CHAR); final javax.tools.FileObject jfo = tx.readFileObject(location, names[0], names[1]); if (jfo != null) { return (JavaFileObject) jfo; } final Archive archive = provider.getArchive(BaseUtilities.toURI(root).toURL(), false); return archive != null ? archive.getFile(path) : null; }
private javax.tools.JavaFileObject findFile(final String pkgName, String relativeName) { assert pkgName != null; assert relativeName != null; final String resourceName = FileObjects.resolveRelativePath(pkgName,relativeName); for( ClassPath.Entry root : this.cp.entries()) { try { final Archive archive = provider.getArchive (root.getURL(), cacheFile); if (archive != null) { final JavaFileObject file = archive.getFile(resourceName); if (file != null) { return file; } } } catch (IOException e) { Exceptions.printStackTrace(e); } } return null; } }
@Override public javax.tools.FileObject getFileForOutput(final Location l, final String pkgName, final String relativeName, final javax.tools.FileObject sibling) throws IOException, UnsupportedOperationException, IllegalArgumentException { if (StandardLocation.SOURCE_PATH != l) { throw new UnsupportedOperationException("Only StandardLocation.SOURCE_PATH is supported."); // NOI18N } final String rp = FileObjects.resolveRelativePath (pkgName, relativeName); final FileObject[] fileRootPair = findFile(rp); if (fileRootPair == null) { final FileObject[] roots = this.sourceRoots.getRoots(); if (roots.length == 0) { throw new UnsupportedOperationException("No source path"); //NOI18N } final File rootFile = FileUtil.toFile(roots[0]); if (rootFile == null) { throw new UnsupportedOperationException("No source path"); //NOI18N } return FileObjects.sourceFileObject( BaseUtilities.toURI(new File(rootFile,FileObjects.convertFolder2Package(rp, File.separatorChar))).toURL(), roots[0]); } else { return FileObjects.sourceFileObject(fileRootPair[0], fileRootPair[1]); //Todo: wrap to protect from write } }
@Override public javax.tools.FileObject getFileForOutput(Location location, String packageName, String relativeName, javax.tools.FileObject sibling) throws IOException { assertLocation(location, true); final String resourceName = FileObjects.resolveRelativePath(packageName, relativeName); final String[] ncs = FileObjects.getFolderAndBaseName(resourceName, FileObjects.NBFS_SEPARATOR_CHAR); return new MemOutFileObject( FileObjects.convertFolder2Package(ncs[0]), ncs[1]); }
public @Override javax.tools.FileObject getFileForOutput( Location l, String pkgName, String relativeName, javax.tools.FileObject sibling ) throws IOException, UnsupportedOperationException, IllegalArgumentException { assert pkgName != null; assert relativeName != null; URL siblingURL = siblings.hasSibling() ? siblings.getSibling() : sibling == null ? null : sibling.toUri().toURL(); if (siblingURL == null) { throw new IllegalArgumentException ("sibling == null"); } File activeRoot = getClassFolderForSourceImpl (siblingURL); if (activeRoot == null) { activeRoot = getClassFolderForApt(siblingURL); if (activeRoot == null) { //Deleted project throw new InvalidSourcePath (); } } final String path = FileObjects.resolveRelativePath(pkgName, relativeName); final File file = FileUtil.normalizeFile(new File (activeRoot,path.replace(FileObjects.NBFS_SEPARATOR_CHAR, File.separatorChar))); return tx.createFileObject(l, file, activeRoot,null,null); }