mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
shared index: add api to notify on index version changed
GitOrigin-RevId: 12cb1d2d06dfbad1d75455ce93c39cf9fd9d29eb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b7a7b777ec
commit
ff9322dd60
@@ -188,6 +188,17 @@ public final class StubIndexImpl extends StubIndexEx implements PersistentStateC
|
||||
else registrationResultSink.registerIndexAsInitiallyBuilt(indexKey);
|
||||
if (indexRootHasChildren) FileUtil.deleteWithRenaming(indexRootDir);
|
||||
IndexingStamp.rewriteVersion(indexKey, version); // todo snapshots indices
|
||||
|
||||
try {
|
||||
if (needRebuild) {
|
||||
for (FileBasedIndexInfrastructureExtension ex : FileBasedIndexInfrastructureExtension.EP_NAME.getExtensionList()) {
|
||||
ex.onStubIndexVersionChanged(indexKey);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
} else {
|
||||
registrationResultSink.registerIndexAsUptoDate(indexKey);
|
||||
}
|
||||
|
||||
@@ -333,6 +333,17 @@ public final class FileBasedIndexImpl extends FileBasedIndexEx {
|
||||
File rootDir = IndexInfrastructure.getIndexRootDir(name);
|
||||
if (versionFileExisted) FileUtil.deleteWithRenaming(rootDir);
|
||||
IndexingStamp.rewriteVersion(name, version);
|
||||
|
||||
try {
|
||||
if (versionFileExisted) {
|
||||
for (FileBasedIndexInfrastructureExtension ex : FileBasedIndexInfrastructureExtension.EP_NAME.getExtensionList()) {
|
||||
ex.onFileBasedIndexVersionChanged(name);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
} else {
|
||||
registrationStatusSink.registerIndexAsUptoDate(name);
|
||||
}
|
||||
|
||||
+18
@@ -6,6 +6,7 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.stubs.StubIndexKey;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -49,6 +50,23 @@ public interface FileBasedIndexInfrastructureExtension {
|
||||
@NotNull UpdatableIndex<K, V, FileContent> baseIndex);
|
||||
|
||||
|
||||
/**
|
||||
* Notifies the extension to handle that version of existing file based index version has been changed.
|
||||
*
|
||||
* Actually {@link FileBasedIndex} notifies even if index composite version (extension version + implementation version)
|
||||
* is changed {@link FileBasedIndexImpl#getIndexExtensionVersion(FileBasedIndexExtension)}.
|
||||
*
|
||||
* @param indexId that version is updated.
|
||||
*/
|
||||
void onFileBasedIndexVersionChanged(@NotNull ID<?, ?> indexId);
|
||||
|
||||
/**
|
||||
* Notifies the extension to handle that version of existing stub index has been changed.
|
||||
*
|
||||
* @param indexId that version is updated.
|
||||
*/
|
||||
void onStubIndexVersionChanged(@NotNull StubIndexKey<?, ?> indexId);
|
||||
|
||||
/**
|
||||
* Executed when IntelliJ is shutting down it's indexes (IDE shutdown or plugin load/unload). It is the best time
|
||||
* for the component to flush it's state to the disk and close all pending connections.
|
||||
|
||||
Reference in New Issue
Block a user