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 38b0cf32b816..ae6c4dae4188 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java @@ -584,53 +584,56 @@ public final class StubIndexImpl extends StubIndexEx implements PersistentStateC int fileId, @NotNull Set oldKeys, @NotNull Set newKeys) { - try { - if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) { - LOG.info("stub index '" + stubIndexKey + "' update: " + fileId + - " old = " + Arrays.toString(oldKeys.toArray()) + - " new = " + Arrays.toString(newKeys.toArray()) + - " updated_id = " + System.identityHashCode(newKeys)); - } - final UpdatableIndex index = getIndex(stubIndexKey); - if (index == null) return; - index.updateWithMap(new AbstractUpdateData(fileId) { - @Override - protected boolean iterateKeys(@NotNull KeyValueUpdateProcessor addProcessor, - @NotNull KeyValueUpdateProcessor updateProcessor, - @NotNull RemovedKeyProcessor removeProcessor) throws StorageException { - - if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) { - LOG.info("iterating keys updated_id = " + System.identityHashCode(newKeys)); - } - - boolean modified = false; - - for (K oldKey : oldKeys) { - if (!newKeys.contains(oldKey)) { - removeProcessor.process(oldKey, fileId); - if (!modified) modified = true; - } - } - - for (K oldKey : newKeys) { - if (!oldKeys.contains(oldKey)) { - addProcessor.process(oldKey, null, fileId); - if (!modified) modified = true; - } - } - - if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) { - LOG.info("keys iteration finished updated_id = " + System.identityHashCode(newKeys) + "; modified = " + modified); - } - - return modified; + ProgressManager.getInstance().executeNonCancelableSection(() -> { + try { + if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) { + LOG.info("stub index '" + stubIndexKey + "' update: " + fileId + + " old = " + Arrays.toString(oldKeys.toArray()) + + " new = " + Arrays.toString(newKeys.toArray()) + + " updated_id = " + System.identityHashCode(newKeys)); } - }); - } - catch (StorageException e) { - LOG.info(e); - requestRebuild(); - } + final UpdatableIndex index = getIndex(stubIndexKey); + if (index == null) return; + index.updateWithMap(new AbstractUpdateData(fileId) { + @Override + protected boolean iterateKeys(@NotNull KeyValueUpdateProcessor addProcessor, + @NotNull KeyValueUpdateProcessor updateProcessor, + @NotNull RemovedKeyProcessor removeProcessor) throws StorageException { + + if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) { + LOG.info("iterating keys updated_id = " + System.identityHashCode(newKeys)); + } + + boolean modified = false; + + for (K oldKey : oldKeys) { + if (!newKeys.contains(oldKey)) { + removeProcessor.process(oldKey, fileId); + if (!modified) modified = true; + } + } + + for (K oldKey : newKeys) { + if (!oldKeys.contains(oldKey)) { + addProcessor.process(oldKey, null, fileId); + if (!modified) modified = true; + } + } + + if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) { + LOG.info("keys iteration finished updated_id = " + System.identityHashCode(newKeys) + "; modified = " + modified); + } + + return modified; + } + }); + } + catch (StorageException e) { + LOG.info(e); + requestRebuild(); + } + }); + } private class StubIndexInitialization extends IndexInfrastructure.DataInitialization {