--- a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java +++ a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java @@ -411,7 +411,7 @@ final FileEventLog eventQueue = new FileEventLog(); - private void fileFolderCreatedImpl(FileEvent fe, boolean source) { + private void fileFolderCreatedImpl(FileEvent fe, Boolean source) { FileObject fo = fe.getFile(); if (isCacheFile(fo)) { return; @@ -428,7 +428,7 @@ Pair root = null; if (fo != null && fo.isValid() && VisibilityQuery.getDefault().isVisible(fo)) { - if (source) { + if (source == null || source.booleanValue()) { root = getOwningSourceRoot(fo); if (root != null) { boolean sourcForBinaryRoot = sourcesForBinaryRoots.contains(root.first); @@ -439,7 +439,9 @@ processed = true; } } - } else { + } + + if (!processed && (source == null || !source.booleanValue())) { root = getOwningBinaryRoot(fo); if (root != null) { final Work wrk = new BinaryWork(root.first); @@ -455,7 +457,7 @@ } } - private void fileChangedImpl (FileEvent fe, boolean source) { + private void fileChangedImpl (FileEvent fe, Boolean source) { FileObject fo = fe.getFile(); if (isCacheFile(fo)) { return; @@ -469,7 +471,7 @@ Pair root = null; if (fo != null && fo.isValid() && VisibilityQuery.getDefault().isVisible(fo)) { - if (source) { + if (source == null || source.booleanValue()) { root = getOwningSourceRoot (fo); if (root != null) { boolean sourceForBinaryRoot = sourcesForBinaryRoots.contains(root.first); @@ -480,7 +482,9 @@ processed = true; } } - } else { + } + + if (!processed && (source == null || !source.booleanValue())) { root = getOwningBinaryRoot(fo); if (root != null) { final Work wrk = new BinaryWork(root.first); @@ -496,7 +500,7 @@ } } - private void fileDeletedImpl(FileEvent fe, boolean source) { + private void fileDeletedImpl(FileEvent fe, Boolean source) { FileObject fo = fe.getFile(); if (isCacheFile(fo)) { return; @@ -510,7 +514,7 @@ Pair root = null; if (fo != null && VisibilityQuery.getDefault().isVisible(fo)) { - if (source) { + if (source == null || source.booleanValue()) { root = getOwningSourceRoot (fo); if (root != null) { if (fo.isData() /*&& FileUtil.getMIMEType(fo, recognizers.getMimeTypes())!=null*/) { @@ -521,7 +525,9 @@ processed = true; } } - } else { + } + + if (!processed && (source == null || !source.booleanValue())) { root = getOwningBinaryRoot(fo); if (root != null) { final Work wrk = new BinaryWork(root.first); @@ -537,7 +543,7 @@ } } - private void fileRenamedImpl(FileRenameEvent fe, boolean source) { + private void fileRenamedImpl(FileRenameEvent fe, Boolean source) { FileObject fo = fe.getFile(); if (isCacheFile(fo)) { return; @@ -553,7 +559,7 @@ boolean processed = false; if (newFile != null && newFile.isValid()) { - if (source) { + if (source == null || source.booleanValue()) { root = getOwningSourceRoot(newFile); if (root != null) { FileObject rootFo = root.second; @@ -582,7 +588,9 @@ } processed = true; } - } else { + } + + if (!processed && (source == null || !source.booleanValue())) { root = getOwningBinaryRoot(newFile); if (root != null) { final File parentFile = FileUtil.toFile(newFile.getParent()); @@ -794,7 +802,7 @@ private static final Logger SFEC_LOGGER = Logger.getLogger("org.netbeans.ui.ScanForExternalChanges"); //NOI18N private static final boolean PERF_TEST = Boolean.getBoolean("perf.refactoring.test"); //NOI18N private static final boolean notInterruptible = Boolean.getBoolean("netbeans.indexing.notInterruptible"); //NOI18N - private static final boolean noRecursiveListener = Boolean.getBoolean("netbeans.indexing.notRecursiveListener"); //NOI18N + private static final boolean useRecursiveListeners = Boolean.getBoolean("netbeans.indexing.recursiveListeners"); //NOI18N private static final int FILE_LOCKS_DELAY = org.openide.util.Utilities.isWindows() ? 2000 : 1000; private static final String PROP_LAST_INDEXED_VERSION = RepositoryUpdater.class.getName() + "-last-indexed-document-version"; //NOI18N private static final String PROP_LAST_DIRTY_VERSION = RepositoryUpdater.class.getName() + "-last-dirty-document-version"; //NOI18N @@ -823,12 +831,15 @@ private boolean ignoreIndexerCacheEvents = false; /* test */ final RootsListeners rootsListeners = new RootsListeners(); - private final FileChangeListener sourceRootsListener = new FCL(true); - private final FileChangeListener binaryRootsListener = new FCL(false); + private final FileChangeListener sourceRootsListener = new FCL(useRecursiveListeners ? Boolean.TRUE : null); + private final FileChangeListener binaryRootsListener = new FCL(Boolean.FALSE); private final ThreadLocal inIndexer = new ThreadLocal(); private RepositoryUpdater () { - // no-op + LOGGER.log(Level.INFO, "perf.refactoring.test={0}", PERF_TEST); //NOI18N + LOGGER.log(Level.INFO, "netbeans.indexing.notInterruptible={0}", notInterruptible); //NOI18N + LOGGER.log(Level.INFO, "netbeans.indexing.recursiveListeners={0}", useRecursiveListeners); //NOI18N + LOGGER.log(Level.INFO, "FILE_LOCKS_DELAY={0}", FILE_LOCKS_DELAY); //NOI18N } private void handleActiveDocumentChange(Document deactivated, Document activated) { @@ -3901,6 +3912,7 @@ public void setListener(FileChangeListener sourcesListener, FileChangeListener binariesListener) { assert (sourcesListener != null && binariesListener != null) || (sourcesListener == null && binariesListener == null) : "Both sourcesListener and binariesListener must either be null or non-null"; //NOI18N + //todo: remove removeRecursiveListener from synchronized block synchronized (this) { if (sourcesListener != null) { @@ -3908,10 +3920,18 @@ + ", won't attach " + sourcesListener + " and " + binariesListener; //NOI18N assert sourceRoots.isEmpty() : "Expecting no source roots: " + sourceRoots; //NOI18N assert binaryRoots.isEmpty() : "Expecting no binary roots: " + binaryRoots; //NOI18N + this.sourcesListener = sourcesListener; this.binariesListener = binariesListener; + if (!useRecursiveListeners) { + FileUtil.addFileChangeListener(sourcesListener); + } } else { assert this.sourcesListener != null : "RootsListeners are already dormant"; //NOI18N + + if (!useRecursiveListeners) { + FileUtil.removeFileChangeListener(sourcesListener); + } for(Map.Entry entry : sourceRoots.entrySet()) { safeRemoveRecursiveListener(this.sourcesListener, entry.getValue()); } @@ -3995,11 +4015,7 @@ } private void safeAddRecursiveListener(FileChangeListener listener, File path) { - if (noRecursiveListener) { - if (!noRecursiveListenerLogged.getAndSet(true)) { - LOGGER.info("Recursive listeners are disabled"); //NOI18N - } - } else { + if (useRecursiveListeners) { try { FileUtil.addRecursiveListener(listener, path, new Callable() { @Override @@ -4017,7 +4033,7 @@ } private void safeRemoveRecursiveListener(FileChangeListener listener, File path) { - if (!noRecursiveListener) { + if (useRecursiveListeners) { try { FileUtil.removeRecursiveListener(listener, path); } catch (Exception e) { @@ -4029,9 +4045,9 @@ } // End of RootsListeners class private final class FCL extends FileChangeAdapter { - private final boolean listeningOnSources; - - public FCL(boolean listeningOnSources) { + private final Boolean listeningOnSources; + + public FCL(Boolean listeningOnSources) { this.listeningOnSources = listeningOnSources; }