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,21 @@ + + + Adding refreshIndexAndWait method into the IndexingManager allowing to specify if indexers should use modified content of editors + + + + + +

+ Adding refreshIndexAndWait method into the IndexingManager allowing to specify if indexers should use modified content of editors. +

+
+ + +
Adding refreshIndex method into the IndexingManager allowing to specify if indexers should use modified content of editors 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 @@ -2,4 +2,4 @@ javac.source=1.6 javadoc.apichanges=${basedir}/apichanges.xml javadoc.arch=${basedir}/arch.xml -spec.version.base=1.39.0 +spec.version.base=1.40.0 diff --git a/parsing.api/src/org/netbeans/modules/parsing/api/indexing/IndexingManager.java b/parsing.api/src/org/netbeans/modules/parsing/api/indexing/IndexingManager.java --- a/parsing.api/src/org/netbeans/modules/parsing/api/indexing/IndexingManager.java +++ b/parsing.api/src/org/netbeans/modules/parsing/api/indexing/IndexingManager.java @@ -191,7 +191,7 @@ * be reindexed. */ public void refreshIndexAndWait(URL root, Collection files) { - refreshIndexAndWait(root, files, true); + refreshIndexAndWait(root, files, true, false); } /** @@ -214,13 +214,40 @@ * @since 1.16 */ public void refreshIndexAndWait(URL root, Collection files, boolean fullRescan) { + refreshIndexAndWait(root, files, fullRescan, false); + } + + + /** + * Schedules new files for indexing and blocks until they are reindexed. This + * method does the same thing as {@link #refreshIndex(java.net.URL, java.util.Collection, boolean, boolean) }, + * but it will block the caller until the index refreshing is done. + * + *

IMPORTANT: Please use this with extreme caution. Indexing is generally + * very expensive operation and the more files you ask to reindex the longer the + * job will take. + * + * @param root The common parent folder of the files that should be reindexed. + * @param filesOrFolders The files to reindex. Can be null or an empty + * collection in which case all files under the root will + * be reindexed. + * @param fullRescan If true no timestamps check will be done + * on the files passed in and they all will be reindexed. If + * false only changed files will be reindexed. + * @param checkEditor when true the indexers will use content of modified editor + * documents rather than saved files. For scans the indexers should prefer + * content of files. the document content may be useful for example for error badge + * recovery. + * @since 1.40 + */ + public void refreshIndexAndWait(URL root, Collection files, boolean fullRescan, boolean checkEditor) { if (SwingUtilities.isEventDispatchThread()) { //Prevent AWT deadlock refreshIndexAndWait posted by SwingUtilities.invokeLater //in between completion-active = true and completion-active = false. EventSupport.releaseCompletionCondition(); } if (!RepositoryUpdater.getDefault().isIndexer()) { - RepositoryUpdater.getDefault().addIndexingJob(root, files, false, false, true, fullRescan, false); + RepositoryUpdater.getDefault().addIndexingJob(root, files, false, checkEditor, true, fullRescan, false); } } diff --git a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/QuerySupport.java b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/QuerySupport.java --- a/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/QuerySupport.java +++ b/parsing.api/src/org/netbeans/modules/parsing/spi/indexing/support/QuerySupport.java @@ -270,13 +270,7 @@ LOG.log(Level.WARNING, null, ex); } } - //TODO: 7.0 hot fix, replace by API in IndexingManager in dev! - if (javax.swing.SwingUtilities.isEventDispatchThread()) { - org.netbeans.modules.parsing.impl.event.EventSupport.releaseCompletionCondition(); - } - if (!RepositoryUpdater.getDefault().isIndexer()) { - RepositoryUpdater.getDefault().addIndexingJob(root, list, false, true, true, true, false); - } + IndexingManager.getDefault().refreshIndexAndWait(root, list, true, true); } } final List result = new LinkedList();