public final class IndexingManager extends Object
Modifier and Type | Method and Description |
---|---|
static IndexingManager |
getDefault() |
boolean |
isIndexing()
Checks whether there are any indexing tasks running.
|
void |
refreshAllIndices(boolean fullRescan,
boolean wait,
File... filesOrFolders)
Schedules a new job that will reindex known source roots determined by
filesOrFolder parameter. |
void |
refreshAllIndices(boolean fullRescan,
boolean wait,
FileObject... filesOrFolders)
Schedules a new job that will reindex known source roots determined by
filesOrFolder parameter. |
void |
refreshAllIndices(FileObject... filesOrFolders)
Schedules a new job that will reindex known source roots determined by
filesOrFolder parameter. |
void |
refreshAllIndices(String indexerName)
Schedules a new job for refreshing all indices created by the given indexer.
|
void |
refreshIndex(URL root,
Collection<? extends URL> files)
Schedules new files for indexing.
|
void |
refreshIndex(URL root,
Collection<? extends URL> files,
boolean fullRescan)
Schedules new files for indexing.
|
void |
refreshIndex(URL root,
Collection<? extends URL> files,
boolean fullRescan,
boolean checkEditor)
Schedules new files for indexing.
|
void |
refreshIndexAndWait(URL root,
Collection<? extends URL> files)
Schedules new files for indexing and blocks until they are reindexed.
|
void |
refreshIndexAndWait(URL root,
Collection<? extends URL> files,
boolean fullRescan)
Schedules new files for indexing and blocks until they are reindexed.
|
void |
refreshIndexAndWait(URL root,
Collection<? extends URL> files,
boolean fullRescan,
boolean checkEditor)
Schedules new files for indexing and blocks until they are reindexed.
|
<T> T |
runProtected(Callable<T> operation)
Runs the
operation in protected mode. |
public static IndexingManager getDefault()
public boolean isIndexing()
true
if there are indexing tasks running, otherwise false
.public void refreshIndex(URL root, Collection<? extends URL> files)
This method simply calls IndexingManager.refreshIndex(java.net.URL, java.util.Collection, boolean)
with forceRefresh
set to true
.
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.
root
- The common parent folder of the files that should be reindexed.filesOrFolders
- The files to reindex. Can be null
or an empty
collection in which case all files under the root
will
be reindexed.public void refreshIndex(URL root, Collection<? extends URL> files, boolean fullRescan)
If forceRefresh
parameter is set to true
no timestamp checks will be done for the files passed to this method.
This means that even files that have not been changed since their last indexing
will be reindexed again. On the other hand if forceRefresh
is
false
the infrastructure will check timestamps and will reindex
only files that have been changed since the last time they were indexed.
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.
root
- The common parent folder of the files that should be reindexed.filesOrFolders
- The files to reindex. Can be null
or an empty
collection in which case all files under the root
will
be reindexed.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.public void refreshIndex(@NonNull URL root, @NullAllowed Collection<? extends URL> files, boolean fullRescan, boolean checkEditor)
If forceRefresh
parameter is set to true
no timestamp checks will be done for the files passed to this method.
This means that even files that have not been changed since their last indexing
will be reindexed again. On the other hand if forceRefresh
is
false
the infrastructure will check timestamps and will reindex
only files that have been changed since the last time they were indexed.
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.
If checkEditor
is true the indexers will use unsaved content
of editor documents. Scan is using the file content rather than editor content,
the editor content is needed only in special cases like error badge recovery.
Simpler version IndexingManager.refreshIndex(java.net.URL, java.util.Collection, boolean)
should be preferred.
root
- The common parent folder of the files that should be reindexed.filesOrFolders
- The files to reindex. Can be null
or an empty
collection in which case all files under the root
will
be reindexed.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.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.public void refreshIndexAndWait(URL root, Collection<? extends URL> files)
IndexingManager.refreshIndex(java.net.URL, java.util.Collection)
,
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.
root
- The common parent folder of the files that should be reindexed.filesOrFolders
- The files to reindex. Can be null
or an empty
collection in which case all files under the root
will
be reindexed.public void refreshIndexAndWait(URL root, Collection<? extends URL> files, boolean fullRescan)
IndexingManager.refreshIndex(java.net.URL, java.util.Collection, 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.
root
- The common parent folder of the files that should be reindexed.filesOrFolders
- The files to reindex. Can be null
or an empty
collection in which case all files under the root
will
be reindexed.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.public void refreshIndexAndWait(URL root, Collection<? extends URL> files, boolean fullRescan, boolean checkEditor) throws IllegalStateException
IndexingManager.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.
root
- The common parent folder of the files that should be reindexed.files
- The files to reindex. Can be null
or an empty
collection in which case all files under the root
will
be reindexed.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.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.IllegalStateException
- when caller holds the parser lock or when called from indexerpublic void refreshAllIndices(String indexerName)
CustomIndexer
s, or EmbeddedIndexer
s.
It is not possible to refresh indices created by BinaryIndexer
s.
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.
indexerName
- The name of the indexer, which indices should be refreshed.
Can be null
in which case all indices created by all
indexers will be refreshed (ie. all types of indexers will used,
not just CustomIndexers
).public void refreshAllIndices(FileObject... filesOrFolders)
filesOrFolder
parameter.
This method does the same as IndexingManager.refreshAllIndices(boolean, boolean, org.openide.filesystems.FileObject[])
with fullRescan == true
and wait == false
.filesOrFolders
- The list of files or folders that should be refreshed.
This can be a mixture of files or folders that either lie under some source
root or contain (folders) source roots. The files lying under a source root
will simply be rescanned. The folders lying under a source root will be rescanned
recursively. Files lying outside of all source roots will be ignored. Folders
lying outside of all source folders will be checked for source roots that they
contain and these source roots will be rescanned.
Can be null
in which case all indices for
all roots will be refreshed.
public void refreshAllIndices(boolean fullRescan, boolean wait, FileObject... filesOrFolders)
filesOrFolder
parameter.
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.
fullRescan
- If false
only modified, new or deleted
files under the roots will be rescanned. Otherwise files will be rescanned
no matter if they were modified or not.wait
- If true
the method will block the caller until
refreshing is done.filesOrFolders
- The list of files or folders that should be refreshed.
This can be a mixture of files or folders that either lie under some source
root or contain (folders) source roots. The files lying under a source root
will simply be rescanned. The folders lying under a source root will be rescanned
recursively. Files lying outside of all source roots will be ignored. Folders
lying outside of all source folders will be checked for source roots that they
contain and these source roots will be rescanned.
Can be null
in which case all indices for
all roots will be refreshed.
public void refreshAllIndices(boolean fullRescan, boolean wait, File... filesOrFolders)
filesOrFolder
parameter. This is the same method as IndexingManager.refreshAllIndices(boolean, boolean, org.openide.filesystems.FileObject[])
,
but it accepts java.io.File
s rather than FileObject
s.
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.
fullRescan
- If false
only modified, new or deleted
files under the roots will be rescanned. Otherwise files will be rescanned
no matter if they were modified or not.wait
- If true
the method will block the caller until
refreshing is done.filesOrFolders
- The list of files or folders that should be refreshed.
This can be a mixture of files or folders that either lie under some source
root or contain (folders) source roots. The files lying under a source root
will simply be rescanned. The folders lying under a source root will be rescanned
recursively. The files lying outside of all source roots will be ignored. Finally,
the folders lying outside of all source folders will be checked for source roots
that they contain and these source roots will be rescanned.
Can be null
in which case all indices for
all roots will be refreshed. The files have to be normalized, @see FileUtil#normalizeFile
public <T> T runProtected(Callable<T> operation) throws Exception
operation
in protected mode. All events that would normally
trigger rescanning are remembered and processed after the operation finishes.
Note that events coming from other threads during the time that this thread is performing the operation will also be queued.
operation
- The operation to run without rescanning while the operation
is running.operation
returns.Exception
- Any exception thrown from the operation is rethrown.