@Override public void filesDeleted(Iterable<? extends Indexable> deleted, Context context) { JavaIndex.LOG.log(Level.FINE, "filesDeleted({0})", deleted); //NOI18N try { if(!Boolean.parseBoolean(JavaIndex.getAttribute(context.getRootURI(), APT_SOURCE_OUTPUT, null))) { clearFiles(context, deleted); } } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } }
@NonNull FQN2Files getFQNs() throws IOException { if (fqn2Files == null) { fqn2Files = FQN2Files.forRoot(ctx.getRootURI()); } return fqn2Files; }
@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); } }
@NonNull private Iterable<? extends JavaIndexerPlugin> getPlugins() { if (pluginsCache == null) { pluginsCache = createPlugins(ctx.getRootURI(), ctx.getIndexFolder()); } return pluginsCache; }
@Override public boolean scanStarted(final Context context) { JavaIndex.LOG.log(Level.FINE, "scan started for root ({0})", context.getRootURI()); //NOI18N final TransactionContext txctx = TransactionContext.beginStandardTransaction( context.getRootURI(), true, context.isAllFilesIndexing(), context.checkForEditorModifications()); try { return JavaIndexerWorker.reduce( Boolean.TRUE, JavaIndexerWorker.Bool.AND, new IndexCheck(context, txctx.get(ClassIndexEventsTransaction.class)), new MetadataCheck(context)); } catch (final ExecutionException ee) { JavaIndex.LOG.log( Level.WARNING, "Exception while checking cache validity for root: "+context.getRootURI(),//NOI18N ee.getCause()); return false; } catch (InterruptedException ie) { //Ending return false; } }
@Override public boolean scanStarted(final Context context) { try { TransactionContext.beginStandardTransaction( context.getRootURI(), false, context.isAllFilesIndexing(), context.checkForEditorModifications()); final ClassIndexImpl uq = ClassIndexManager.getDefault().createUsagesQuery(context.getRootURI(), false); if (uq == null) { //Closing... return true; } if (uq.getState() != ClassIndexImpl.State.NEW) { //Already checked return true; } return uq.isValid(); } catch (IOException ioe) { JavaIndex.LOG.log(Level.WARNING, "Exception while checking cache validity for root: "+context.getRootURI(), ioe); //NOI18N return false; } }
@Override protected void index(final Context context) { LOG.log(Level.FINE, "index({0})", context.getRootURI()); try { final ClassIndexManager cim = ClassIndexManager.getDefault(); ClassIndexImpl uq = cim.createUsagesQuery(context.getRootURI(), false); if (uq == null) { return; //IDE is exiting, indeces are already closed. changed.addAll(changes.removed); if (!changes.changed.isEmpty() || !changes.added.isEmpty() || !changes.removed.isEmpty()) { deleteSigFiles(context.getRootURI(), changed); if (changes.preBuildArgs) { preBuildArgs(javax.swing.JComponent.class.getName(), context.getRootURI()); final Map<URL,Set<URL>> toRebuild = JavaCustomIndexer.findDependent(context.getRootURI(), srcDeps, binDeps, peers, changed, !changes.added.isEmpty(), false); for (Map.Entry<URL, Set<URL>> entry : toRebuild.entrySet()) { context.addSupplementaryFiles(entry.getKey(), entry.getValue());
static void setErrors(Context context, CompileTuple active, DiagnosticListenerImpl errors) { if (!active.virtual) { Iterable<Diagnostic<? extends JavaFileObject>> filteredErrorsList = Iterators.filter(errors.getDiagnostics(active.jfo), new FilterOutJDK7AndLaterWarnings()); ErrorsCache.setErrors(context.getRootURI(), active.indexable, filteredErrorsList, active.aptGenerated ? ERROR_CONVERTOR_NO_BADGE : ERROR_CONVERTOR); } }
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()); } } }
@NonNull @Override public Boolean call() throws Exception { boolean vote = true; FileObject root = ctx.getRoot(); if (root == null) { return vote; } if (Optional.ofNullable(APTUtils.get(root)) .map((apt) -> apt.verifyAttributes(ctx.getRoot(), false)) .orElse(Boolean.FALSE)) { vote = false; } if (ensureSourcePath(root)) { JavaIndex.LOG.fine("forcing reindex due to source path change"); //NOI18N vote = false; } if (JavaIndex.ensureAttributeValue(ctx.getRootURI(), ClassIndexManager.PROP_DIRTY_ROOT, null)) { JavaIndex.LOG.fine("forcing reindex due to dirty root"); //NOI18N vote = false; } if (!JavaFileFilterListener.getDefault().startListeningOn(ctx.getRoot())) { JavaIndex.LOG.fine("Forcing reindex due to changed JavaFileFilter"); // NOI18N vote = false; } return vote; } }
for (Indexable i : files) { 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()); for (Map.Entry<URL, Set<URL>> entry : findDependent(context.getRootURI(), removedTypes, false).entrySet()) { context.addSupplementaryFiles(entry.getKey(), entry.getValue()); "Broken index for root: {0} reason: {1}, recovering.", //NOI18N new Object[] { context.getRootURI(), bi.getMessage() }); piTx.setBroken(); ciTx.removedCacheFiles(context.getRootURI(), removedFiles); ciTx.removedTypes(context.getRootURI(), removedTypes); } finally { javaContext.finish();
public JavaParsingContext(final Context context, final ClassPath bootPath, final ClassPath compilePath, final ClassPath sourcePath, final Collection<? extends CompileTuple> virtualSources) throws IOException { ctx = context; rootNotNeeded = false; uq = ClassIndexManager.getDefault().createUsagesQuery(context.getRootURI(), true); cpInfo = ClasspathInfoAccessor.getINSTANCE().create(bootPath,compilePath, sourcePath, filter, true, context.isSourceForBinaryRootIndexing(), !virtualSources.isEmpty(), context.checkForEditorModifications(), null); registerVirtualSources(cpInfo, virtualSources); }
@Override protected void index(Iterable<? extends Indexable> files, Context context) { final URL rootURL = context.getRootURI(); if (FileUtil.getArchiveFile(rootURL) != null) { return; File sourceRootFile = BaseUtilities.toFile(context.getRootURI().toURI()); BuildArtifactMapperImpl.classCacheUpdated(context.getRootURI(), sourceRootFile, Collections.<File>emptyList(), updated, true);
if (!file.virtual) { ErrorsCache.setErrors( ctx.getRootURI(), file.indexable, Collections.<Diagnostic<JavaFileObject>>singleton(error),
@NonNull private RootProcessor createProcessor(@NonNull final Context ctx) throws IOException { final URL root = ctx.getRootURI(); final String mainP = root.getProtocol(); if ("jar".equals(mainP)) { //NOI18N
@NonNull @Override public Boolean call() throws Exception { boolean vote = true; final ClassIndexImpl uq = ClassIndexManager.getDefault().createUsagesQuery( ctx.getRootURI(), true, cietx); final boolean classIndexConsistent = uq != null ? uq.getState() != ClassIndexImpl.State.NEW ? true: //Already checked uq.isValid(): true; if (!classIndexConsistent) { vote = false; } return vote; }
@Override protected void index(final Iterable<? extends Indexable> files, final Context context) { JavaIndex.LOG.log(Level.FINE, context.isSupplementaryFilesIndexing() ? "index suplementary({0})" :"index({0})", context.isAllFilesIndexing() ? context.getRootURI() : files); //NOI18N final TransactionContext txCtx = TransactionContext.get(); final FileManagerTransaction fmTx = txCtx.get(FileManagerTransaction.class); APTUtils.sourceRootRegistered(context.getRoot(), context.getRootURI()); final ClassPath sourcePath = ClassPath.getClassPath(root, ClassPath.SOURCE); final ClassPath bootPath = ClassPath.getClassPath(root, ClassPath.BOOT); if (isAptBuildGeneratedFolder(context.getRootURI(),sourcePath)) { txCtx.get(CacheAttributesTransaction.class).setInvalid(true); JavaIndex.setAttribute(context.getRootURI(), APT_SOURCE_OUTPUT, Boolean.TRUE.toString()); JavaIndex.LOG.fine("Ignoring annotation processor build generated folder"); //NOI18N return; JavaIndex.setAttribute(context.getRootURI(), APT_SOURCE_OUTPUT, null); if (!files.iterator().hasNext() && !context.isAllFilesIndexing()) { boolean success = false; } finally { if (!success) { JavaIndex.setAttribute(context.getRootURI(), ClassIndexManager.PROP_DIRTY_ROOT, Boolean.TRUE.toString()); final Collection<? extends CompileTuple> virtualSourceTuples = translateVirtualSources ( splitSources(files,javaSources), context.getRootURI()); final JavaParsingContext javaContext; try {
final List<Pair<String,String>> toDelete = new ArrayList<Pair<String,String>>(); 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>>();
JavaParsingContext(final Context context, final boolean allowNonExistentRoot) throws IOException { ctx = context; rootNotNeeded = allowNonExistentRoot && context.getRoot() == null; uq = ClassIndexManager.getDefault().createUsagesQuery(context.getRootURI(), true); if (!rootNotNeeded) { ClassPath bootPath = ClassPath.getClassPath(ctx.getRoot(), ClassPath.BOOT);