diff --git a/java.source/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java b/java.source/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java --- a/java.source/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java +++ b/java.source/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java @@ -140,6 +140,9 @@ @Override protected void index(final Iterable files, final Context context) { + if (context.isTransientIndexing()) { + return; + } 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); @@ -929,6 +932,9 @@ @Override public boolean scanStarted(final Context context) { + if (context.isTransientIndexing()) { + return true; + } JavaIndex.LOG.log(Level.FINE, "scan started for root ({0})", context.getRootURI()); //NOI18N TransactionContext.beginStandardTransaction(context.getRootURI(), true, context.isAllFilesIndexing()); boolean vote = true; @@ -978,7 +984,10 @@ } @Override - public void scanFinished(final Context context) { + public void scanFinished(final Context context) { + if (context.isTransientIndexing()) { + return; + } final TransactionContext txCtx = TransactionContext.get(); assert txCtx != null; try { @@ -999,6 +1008,9 @@ @Override public void filesDeleted(Iterable deleted, Context context) { + if (context.isTransientIndexing()) { + return; + } JavaIndex.LOG.log(Level.FINE, "filesDeleted({0})", deleted); //NOI18N clearFiles(context, deleted); } diff --git a/java.source/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java b/java.source/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java --- a/java.source/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java +++ b/java.source/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java @@ -240,6 +240,7 @@ false, false, false, + false, SuspendSupport.NOP, null, null)); diff --git a/java.source/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java b/java.source/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java --- a/java.source/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java +++ b/java.source/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java @@ -108,7 +108,7 @@ private ParsingOutput runIndexing(List files, List virtualFiles) throws Exception { TransactionContext txc = TransactionContext.beginStandardTransaction(src.toURL(), true, false); Factory f = new JavaCustomIndexer.Factory(); - Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(src.toURL()), src.toURL(), f.getIndexerName(), f.getIndexVersion(), LuceneIndexFactory.getDefault(), false, false, true, SPIAccessor.getInstance().createSuspendStatus(new SuspendStatusImpl() { + Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(src.toURL()), src.toURL(), f.getIndexerName(), f.getIndexVersion(), LuceneIndexFactory.getDefault(), false, false, true, false, SPIAccessor.getInstance().createSuspendStatus(new SuspendStatusImpl() { @Override public boolean isSuspended() { return false; } diff --git a/parsing.api/apichanges.xml b/parsing.api/apichanges.xml --- a/parsing.api/apichanges.xml +++ b/parsing.api/apichanges.xml @@ -110,6 +110,22 @@ + + + Added Context.isTransientIndexing to notify indexers that indexing is started for modified non saved file. + + + + + +

+ Added Context.isTransientIndexing to notify indexers that indexing is started for modified non saved file + as a result of QuerySupport query. +

+
+ + +
Added QuerySupport.findDependentRoots to find out source roots depending on given source root. diff --git a/parsing.api/nbproject/project.properties b/parsing.api/nbproject/project.properties --- a/parsing.api/nbproject/project.properties +++ b/parsing.api/nbproject/project.properties @@ -3,7 +3,7 @@ javac.source=1.6 javadoc.apichanges=${basedir}/apichanges.xml javadoc.arch=${basedir}/arch.xml -spec.version.base=1.65.0 +spec.version.base=1.66.0 test.config.stableBTD.includes=**/*Test.class test.config.stableBTD.excludes=\ diff --git a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java --- a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java +++ b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java @@ -1358,6 +1358,7 @@ false, true, false, + TransientUpdateSupport.isTransientUpdate(), SuspendSupport.NOP, null, null); @@ -1380,6 +1381,7 @@ false, true, false, + TransientUpdateSupport.isTransientUpdate(), SuspendSupport.NOP, null, null); @@ -2192,6 +2194,7 @@ followUpJob, checkEditor, sourceForBinaryRoot, + TransientUpdateSupport.isTransientUpdate(), getSuspendStatus(), getCancelRequest(), logCtx); @@ -2238,6 +2241,7 @@ followUpJob, checkEditor, sourceForBinaryRoot, + TransientUpdateSupport.isTransientUpdate(), getSuspendStatus(), getCancelRequest(), logCtx); @@ -2413,6 +2417,7 @@ followUpJob, checkEditor, sourceForBinaryRoot, + TransientUpdateSupport.isTransientUpdate(), getSuspendStatus(), getCancelRequest(), logCtx); @@ -2545,6 +2550,7 @@ followUpJob, checkEditor, sourceForBinaryRoot, + TransientUpdateSupport.isTransientUpdate(), getSuspendStatus(), getCancelRequest(), logCtx); @@ -2695,6 +2701,7 @@ false, false, false, + TransientUpdateSupport.isTransientUpdate(), getSuspendStatus(), getCancelRequest(), null); @@ -2857,6 +2864,7 @@ followUpJob, checkEditor, sourceForBinaryRoot, + TransientUpdateSupport.isTransientUpdate(), getSuspendStatus(), getCancelRequest(), logCtx); diff --git a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/SPIAccessor.java b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/SPIAccessor.java --- a/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/SPIAccessor.java +++ b/parsing.api/src/org/netbeans/modules/parsing/impl/indexing/SPIAccessor.java @@ -91,6 +91,7 @@ boolean followUpJob, boolean checkForEditorModifications, boolean sourceForBinaryRoot, + boolean transientUpdate, @NonNull final SuspendStatus suspendedStatus, @NullAllowed final CancelRequest cancelRequest, @NullAllowed final LogContext logContext) throws IOException; @@ -105,6 +106,7 @@ boolean followUpJob, boolean checkForEditorModifications, boolean sourceForBinaryRoot, + boolean transientUpdate, @NonNull final SuspendStatus suspendedStatus, @NullAllowed final CancelRequest cancelRequest, @NullAllowed final LogContext logContext) throws IOException; diff --git a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Context.java b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Context.java --- a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Context.java +++ b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Context.java @@ -79,6 +79,7 @@ private final boolean followUpJob; private final boolean checkForEditorModifications; private final boolean sourceForBinaryRoot; + private final boolean transientUpdate; private final CancelRequest cancelRequest; private final SuspendStatus suspendedStatus; private final LogContext logContext; @@ -100,6 +101,7 @@ final boolean followUpJob, final boolean checkForEditorModifications, final boolean sourceForBinaryRoot, + final boolean transientUpdate, @NonNull final SuspendStatus suspendedStatus, @NullAllowed final CancelRequest cancelRequest, @NullAllowed final LogContext logContext @@ -116,6 +118,7 @@ this.followUpJob = followUpJob; this.checkForEditorModifications = checkForEditorModifications; this.sourceForBinaryRoot = sourceForBinaryRoot; + this.transientUpdate = transientUpdate; this.cancelRequest = cancelRequest; this.suspendedStatus = suspendedStatus; this.logContext = logContext; @@ -130,6 +133,7 @@ final boolean followUpJob, final boolean checkForEditorModifications, final boolean sourceForBinaryRoot, + final boolean transientUpdate, @NonNull final SuspendStatus suspendedStatus, @NullAllowed final CancelRequest cancelRequest, @NullAllowed final LogContext logContext @@ -145,6 +149,7 @@ this.followUpJob = followUpJob; this.checkForEditorModifications = checkForEditorModifications; this.sourceForBinaryRoot = sourceForBinaryRoot; + this.transientUpdate = transientUpdate; this.cancelRequest = cancelRequest; this.suspendedStatus = suspendedStatus; this.logContext = logContext; @@ -284,6 +289,21 @@ } /** + * Returns true if the indexing is started for modified non saved file + * as a part of an index query. + * The indexers which are using {@link IndexingSupport} for persistence + * do not need this information as the {@link IndexingSupport} handles + * transient changes itself. Indexers which are using custom storage + * should check the transient indexing flag and don't do any persistent + * changes in case of transient indexing. + * @return true in case of transient indexing. + * @since 1.66 + */ + public boolean isTransientIndexing() { + return transientUpdate; + } + + /** * Notifies indexers whether they should use editor documents rather than just * files. This is mostly useful for CustomIndexers that may optimize * their work and not try to find editor documents for their Indexables. diff --git a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Indexable.java b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Indexable.java --- a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Indexable.java +++ b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/Indexable.java @@ -165,14 +165,15 @@ @Override public Context createContext( - FileObject indexFolder, - URL rootURL, - String indexerName, - int indexerVersion, - IndexFactoryImpl factory, - boolean followUpJob, - boolean checkForEditorModifications, - boolean sourceForBinaryRoot, + @NonNull final FileObject indexFolder, + @NonNull final URL rootURL, + @NonNull final String indexerName, + final int indexerVersion, + @NullAllowed IndexFactoryImpl factory, + final boolean followUpJob, + final boolean checkForEditorModifications, + final boolean sourceForBinaryRoot, + final boolean transientUpdate, @NonNull SuspendStatus suspendedStatus, @NullAllowed CancelRequest cancelRequest, @NullAllowed final LogContext logContext) throws IOException { @@ -185,6 +186,7 @@ followUpJob, checkForEditorModifications, sourceForBinaryRoot, + transientUpdate, suspendedStatus, cancelRequest, logContext); @@ -196,11 +198,12 @@ @NonNull final Callable indexFolderFactory, @NonNull final URL rootURL, @NonNull final String indexerName, - int indexerVersion, + final int indexerVersion, @NullAllowed final IndexFactoryImpl factory, - boolean followUpJob, - boolean checkForEditorModifications, - boolean sourceForBinaryRoot, + final boolean followUpJob, + final boolean checkForEditorModifications, + final boolean sourceForBinaryRoot, + final boolean transientUpdate, @NonNull final SuspendStatus suspendedStatus, @NullAllowed final CancelRequest cancelRequest, @NullAllowed final LogContext logContext) throws IOException { @@ -213,6 +216,7 @@ followUpJob, checkForEditorModifications, sourceForBinaryRoot, + transientUpdate, suspendedStatus, cancelRequest, logContext); diff --git a/parsing.api/test/unit/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupportTest.java b/parsing.api/test/unit/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupportTest.java --- a/parsing.api/test/unit/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupportTest.java +++ b/parsing.api/test/unit/src/org/netbeans/modules/parsing/spi/indexing/support/IndexingSupportTest.java @@ -114,6 +114,7 @@ false, false, false, + false, SuspendSupport.NOP, null, null); @@ -127,6 +128,7 @@ false, false, false, + false, SuspendSupport.NOP, null, null); @@ -152,6 +154,7 @@ false, false, false, + false, SuspendSupport.NOP, null, null); @@ -235,6 +238,7 @@ false, false, false, + false, SuspendSupport.NOP, null, null);