diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java index 56dc97ff59c0..6e367d9a271f 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -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); } diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 522277621736..f9fbfa40f1c5 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -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); } diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexInfrastructureExtension.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexInfrastructureExtension.java index 3ad17911a39f..c431ed502160 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexInfrastructureExtension.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexInfrastructureExtension.java @@ -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 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.