String ext; if (tuple.virtual) { ext = FileObjects.getExtension(tuple.indexable.getURL().getPath()) +'.'+ FileObjects.RX; //NOI18N String relativePath = tuple.indexable.getRelativePath(); javax.tools.FileObject fo = manager.getFileForOutput(StandardLocation.CLASS_OUTPUT, "", FileObjects.stripExtension(relativePath) + '.' + ext, tuple.jfo); assert fo != null;
final ClassPath srcPath = ClassPath.getClassPath(context.getRoot(), ClassPath.SOURCE); for (Indexable i : files) { if (javaMimeTypes.contains(i.getMimeType())) continue; URL url = i.getURL(); final FileObject resource = srcPath.findResource(i.getRelativePath()); if (resource == null) { LOG.log( "File {0} not on source path {1}, root {2}", //NOI18N new Object[]{ i.getURL(), srcPath, context.getRoot()
protected void computeFQNs(final Map<JavaFileObject, List<String>> file2FQNs, CompilationUnitTree cut, CompileTuple tuple) { String pack; if (cut.getPackageName() != null) { pack = cut.getPackageName().toString() + "."; //XXX } else { pack = ""; } String path = tuple.indexable.getRelativePath(); int i = path.lastIndexOf('.'); if (i >= 0) path = path.substring(0, i); path = FileObjects.convertFolder2Package(path); List<String> fqns = new LinkedList<String>(); boolean hasClassesLivingElsewhere = false; for (Tree t : cut.getTypeDecls()) { if (TreeUtilities.CLASS_TREE_KINDS.contains(t.getKind())) { String fqn = pack + ((ClassTree) t).getSimpleName().toString(); fqns.add(fqn); if (!path.equals(fqn)) { hasClassesLivingElsewhere = true; } } } if (hasClassesLivingElsewhere) { file2FQNs.put(tuple.jfo, fqns); } }
private static List<? extends Indexable> splitSources(final Iterable<? extends Indexable> indexables, final List<? super Indexable> javaSources) { List<Indexable> virtualSources = new LinkedList<Indexable>(); for (Indexable indexable : indexables) { if (indexable.getURL() == null) { /* Issue #168179: This is probably deleted source file. Just skipping. */ continue; } if (VirtualSourceProviderQuery.hasVirtualSource(indexable)) { virtualSources.add(indexable); } else { javaSources.add(indexable); } } return virtualSources; }
void addRequire(IndexDocument document) { // Don't generate "require" clauses for anything in generated ruby; // these classes are all built in and do not require any includes // (besides, the file names are bogus - they are just derived from // the class name by the stub generator) String folder = (file.getParent() != null) && file.getParent().getParent() != null ? file.getParent().getParent().getNameExt() : ""; if (folder.equals(RubyPlatform.RUBYSTUBS) && file.getName().startsWith("stub_")) { return; } // Index for require-completion String relative = indexable.getRelativePath(); if (relative != null) { if (relative.endsWith(".rb")) { // NOI18N relative = relative.substring(0, relative.length() - 3); document.addPair(FIELD_REQUIRE, relative, true, true); } } }
public static boolean hasVirtualSource (final Indexable indexable) { Parameters.notNull("indexable", indexable); URL url = indexable.getURL(); if (url == null) { // Issue #168179: This is probably deleted source file. Just skipping. return false; } final String extension = FileObjects.getExtension(url.getFile()); return hasVirtualSource(extension); }
/** * Creates {@link File} based {@link JavaFileObject} for {@link Indexable}. * @param indexable for which the {@link JavaFileObject} should be created * @param root - the classpath root owning the file * @param encoding - the file's encoding * @return {@link JavaFileObject}, never returns null */ @NonNull public static PrefetchableJavaFileObject fileFileObject( @NonNull final Indexable indexable, @NonNull final File root, @NullAllowed final JavaFileFilterImplementation filter, @NullAllowed final Charset encoding) throws IOException { assert indexable != null; assert root != null; final String[] pkgNamePair = getFolderAndBaseName( indexable.getRelativePath(), NBFS_SEPARATOR_CHAR); try { final File file = BaseUtilities.toFile(indexable.getURL().toURI()); return new FileBase( file, convertFolder2Package(pkgNamePair[0]), pkgNamePair[1], filter, encoding); } catch (URISyntaxException use) { throw new IOException(use); } }
@Override protected void index(Iterable<? extends Indexable> files, Context context) { if (!CndTraceFlags.USE_INDEXING_API) { return; } // for now we're not interested in such events (project open for example) if (context.isAllFilesIndexing()) { return; } FileObject root = context.getRoot(); for (Indexable idx : files) { final FileObject fo = root.getFileObject(idx.getRelativePath()); if (delegate != null) { delegate.index(fo); } } }
public UsagesVisitor ( JavacTaskImpl jt, CompilationUnitTree cu, JavaFileManager manager, javax.tools.JavaFileObject sibling, Set<? super ElementHandle<TypeElement>> newTypes, final JavaCustomIndexer.CompileTuple tuple) throws MalformedURLException, IllegalArgumentException { this( jt, cu, inferBinaryName(manager, sibling), tuple.virtual ? tuple.indexable.getURL() : sibling.toUri().toURL(), true, tuple.virtual, newTypes, null); }
final File classFolder = JavaIndex.getClassFolder(context); final File aptFolder = JavaIndex.getAptFolder(context.getRootURI(), false); final String sourceRelative = indexable.getRelativePath(); final List<Pair<String,URL>> sourceRelativeURLPairs = new LinkedList<Pair<String,URL>>(); sourceRelativeURLPairs.add(Pair.of(sourceRelative,indexable.getURL())); File file; if (aptFolder.exists()) {
private static void markDirtyFiles(final Context context, final Iterable<? extends Indexable> files) { ClassIndexImpl indexImpl = ClassIndexManager.getDefault().getUsagesQuery(context.getRootURI(), false); if (indexImpl != null) { for (Indexable i : files) { indexImpl.setDirty(i.getURL()); } } }
@Override public void filesDeleted(Iterable<? extends Indexable> deleted, Context context) { final File target = CompileOnSaveAction.Context.getTarget(context.getRootURI()); if (target == null) { return; } if (!BuildArtifactMapperImpl.isUpdateClasses(context.getRootURI())) { return ; } List<File> deletedFiles = new LinkedList<File>(); for (Indexable d : deleted) { try { deletedFiles.add(BaseUtilities.toFile(d.getURL().toURI())); } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); } } try { File sourceRootFile = BaseUtilities.toFile(context.getRootURI().toURI()); BuildArtifactMapperImpl.classCacheUpdated(context.getRootURI(), sourceRootFile, deletedFiles, Collections.<File>emptyList(), true); } catch (URISyntaxException ex) { Exceptions.printStackTrace(ex); } }
for (Indexable indexable : indexables) { final String ext = FileObjects.getExtension(indexable.getURL().getPath()); final VirtualSourceProvider prov = e2p.get(ext); if (prov != null) { final File file = BaseUtilities.toFile(indexable.getURL().toURI()); l.add(file); file2indexables.put(file, indexable);
static void addAptGenerated( @NonNull final Context context, @NonNull JavaParsingContext javaContext, @NonNull final CompileTuple source, @NonNull final Set<javax.tools.FileObject> aptGenerated) throws IOException { final Set<javax.tools.FileObject> genSources = javaContext.getProcessorGeneratedFiles().getGeneratedSources(source.indexable.getURL()); if (genSources != null) { aptGenerated.addAll(genSources); } }
private static CompileTuple createTuple(Context context, JavaParsingContext javaContext, Indexable indexable) { File root = null; if (!context.checkForEditorModifications() && "file".equals(indexable.getURL().getProtocol()) && (root = FileUtil.toFile(context.getRoot())) != null) { //NOI18N try { return new CompileTuple( FileObjects.fileFileObject( indexable, root, javaContext.getJavaFileFilter(), javaContext.getEncoding()), indexable); } catch (Exception ex) { //pass } } FileObject fo = URLMapper.findFileObject(indexable.getURL()); return fo != null ? new CompileTuple(FileObjects.sourceFileObject(fo, context.getRoot()), indexable) : null; }
clear(context, javaContext, i, removedTypes, removedFiles, fmTx); ErrorsCache.setErrors(context.getRootURI(), i, Collections.<Diagnostic<?>>emptyList(), ERROR_CONVERTOR); ExecutableFilesIndex.DEFAULT.setMainClass(context.getRootURI(), i.getURL(), false); javaContext.getCheckSums().remove(i.getURL());
final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE); final String message = String.format("SuperOnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N tuple.indexable.getURL().toString(), FileUtil.getFileDisplayName(context.getRoot()), bootPath == null ? null : bootPath.toString(), javaContext.getFQNs().set(activeTypes, active.indexable.getURL()); boolean[] main = new boolean[1]; if (javaContext.getCheckSums().checkAndSet(active.indexable.getURL(), activeTypes, jt.getElements()) || context.isSupplementaryFilesIndexing()) { javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, addedTypes, main); } else { modifiedTypes.addAll(aTypes); ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().getURL(), active.indexable.getURL(), main[0]); JavaCustomIndexer.setErrors(context, active, dc);
continue; javaContext.getFQNs().set(types, active.indexable.getURL()); boolean[] main = new boolean[1]; if (javaContext.getCheckSums().checkAndSet(active.indexable.getURL(), types, jt.getElements()) || context.isSupplementaryFilesIndexing()) { javaContext.analyze(trees, jt, active, previous.addedTypes, main); } else { previous.modifiedTypes.addAll(aTypes); ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().getURL(), active.indexable.getURL(), main[0]); JavaCustomIndexer.setErrors(context, active, diagnosticListener); Iterable<? extends JavaFileObject> generatedFiles = jt.generate(types);
final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE); final String message = String.format("OnePassCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N tuple.indexable.getURL().toString(), FileUtil.getFileDisplayName(context.getRoot()), bootPath == null ? null : bootPath.toString(), return ParsingOutput.lowMemory(file2FQNs, addedTypes, createdFiles, finished, modifiedTypes, aptGenerated); javaContext.getFQNs().set(types, active.indexable.getURL()); boolean[] main = new boolean[1]; if (javaContext.getCheckSums().checkAndSet(active.indexable.getURL(), types, jt.getElements()) || context.isSupplementaryFilesIndexing()) { javaContext.analyze(Collections.singleton(unit.first()), jt, unit.second(), addedTypes, main); } else { modifiedTypes.addAll(aTypes); ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().getURL(), active.indexable.getURL(), main[0]); JavaCustomIndexer.setErrors(context, active, dc); final boolean virtual = active.virtual;