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; }
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); }
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); }
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); } }
String ext; if (tuple.virtual) { ext = FileObjects.getExtension(tuple.indexable.getURL().getPath()) +'.'+ FileObjects.RX; //NOI18N
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; }
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()) {
/** * 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); } }
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;