public interface VirtualFileGist<Data>
VirtualFile
content, persists it between IDE restarts,
and updates it when the content is changed. The data is calculated lazily, when needed, and can be different for different projects.
Obtained using GistManager.newVirtualFileGist(java.lang.String, int, com.intellij.util.io.DataExternalizer<Data>, com.intellij.util.gist.VirtualFileGist.GistCalculator<Data>)
.
Tracks VFS content only. Unsaved/uncommitted documents have no effect on the getFileData(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile)
results.
Neither do any disk file changes, until VFS refresh has detected them. To work with PSI content, use PsiFileGist
.
Please note that every call to getFileData(com.intellij.openapi.project.Project, com.intellij.openapi.vfs.VirtualFile)
means a disk access. Clients that access gists frequently should take care of proper caching themselves. The data is calculated on demand when first requested, so if you need this data for a lot of files at once, this can take some amount of time on the first query. If that's unacceptable from the UX perspective,
consider using FileBasedIndexExtension
instead.
The differences to file-based index:
Modifier and Type | Interface and Description |
---|---|
static interface |
VirtualFileGist.GistCalculator<Data>
Used by
VirtualFileGist to calculate the data when it's needed and to recalculate it after file changes. |
Modifier and Type | Method and Description |
---|---|
Data |
getFileData(Project project,
VirtualFile file)
Calculate or get the cached data by the current virtual file content in the given project (or null, if the data is project-independent).
|
Data getFileData(Project project, VirtualFile file)