Refine search
private SourceLevelQuery.Result initSourceLevel() { if (!sourceLevelInitialized) { sourceLevel = rootNotNeeded ? null : SourceLevelQuery.getSourceLevel2(ctx.getRoot()); sourceLevelInitialized = true; } return sourceLevel; }
@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; } }
public static File getIndex(Context c) { return FileUtil.toFile(c.getIndexFolder()); }
@NonNull private Iterable<? extends JavaIndexerPlugin> getPlugins() { if (pluginsCache == null) { pluginsCache = createPlugins(ctx.getRootURI(), ctx.getIndexFolder()); } return pluginsCache; }
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); }
final SuspendStatus suspendStatus = context.getSuspendStatus(); final SourcePrefetcher sourcePrefetcher = SourcePrefetcher.create(files, suspendStatus); try { if (tuple != null) { nop = false; if (context.isCancelled()) { return null; tuple.aptGenerated ? null : APTUtils.get(context.getRoot())); if (context.isCancelled() && JavaIndex.LOG.isLoggable(Level.FINEST)) { JavaIndex.LOG.log(Level.FINEST, "SuperOnePassCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca); //NOI18N 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(), classPath == null ? null : classPath.toString(), if (context.isCancelled()) { return null; try { final Iterable<? extends TypeElement> types = jt.enter(trees); if (context.isCancelled()) { return null; if (context.isCancelled()) {
@Override protected void index(Iterable<? extends Indexable> files, Context context) { final URL rootURL = context.getRootURI(); if (FileUtil.getArchiveFile(rootURL) != null) { return; final ClassPath srcPath = ClassPath.getClassPath(context.getRoot(), ClassPath.SOURCE); for (Indexable i : files) { if (javaMimeTypes.contains(i.getMimeType())) i.getURL(), srcPath, context.getRoot() }); } else if (FileUtil.isParentOf(context.getRoot(), resource)) { updated.add(BaseUtilities.toFile(url.toURI())); Exceptions.printStackTrace(ex); File sourceRootFile = BaseUtilities.toFile(context.getRootURI().toURI()); if (!context.checkForEditorModifications()) { // #187514, see also #152222 and JavaCustomIndexer BuildArtifactMapperImpl.classCacheUpdated(context.getRootURI(), sourceRootFile, Collections.<File>emptyList(), updated, true); Exceptions.printStackTrace(ex);
@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); } }
@Override public void scanFinished(Context context) { final TransactionContext txCtx = TransactionContext.get(); assert txCtx != null; try { if (context.isCancelled()) { txCtx.rollBack(); } else { txCtx.commit(); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } } }
private static void clear(final Context context, final JavaParsingContext javaContext, final Indexable indexable, final Set<ElementHandle<TypeElement>> removedTypes, final Set<File> removedFiles, @NonNull final FileManagerTransaction fmTx) throws IOException { assert fmTx != null; 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>>(); Exceptions.printStackTrace(ioe); Exceptions.printStackTrace(ioe);
@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); assert ciTx != null; try { final FileObject root = context.getRoot(); if (root == null) { JavaIndex.LOG.fine("Ignoring request with no root"); //NOI18N return; 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; try { } finally { if (!success) {
@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. if (context.isAllFilesIndexing()) { final BinaryAnalyser ba = uq.getBinaryAnalyser(); if (ba != null) { //ba == null => IDE is exiting, indexing will be done on IDE restart 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()); Exceptions.printStackTrace(e);
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; }
@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 final URL innerURL = FileUtil.getArchiveFile(root); if ("file".equals(innerURL.getProtocol())) { //NOI18N
@NonNull FQN2Files getFQNs() throws IOException { if (fqn2Files == null) { fqn2Files = FQN2Files.forRoot(ctx.getRootURI()); } return fqn2Files; }
@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; } }
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); if (bootPath == null) { bootPath = JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(); ClassPath compilePath = ClassPath.getClassPath(ctx.getRoot(), ClassPath.COMPILE); if (compilePath == null) { compilePath = ClassPath.EMPTY; ClassPath srcPath = ClassPath.getClassPath(ctx.getRoot(), ClassPath.SOURCE); if (srcPath == null) { srcPath = ClassPath.EMPTY; null, true, context.isSourceForBinaryRootIndexing(), false, context.checkForEditorModifications(), null); } else {
@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); } } }
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();
protected final boolean isCancelled() { return ctx.isCancelled(); }