void (int fileId, @NotNull VirtualFile file, boolean contentChange) { if (ensureFileBelongsToIndexableFilter(fileId, file) == FileAddStatus.SKIPPED) { doInvalidateIndicesForFile(fileId, file); return; } Project projectForFile = findProjectForFileId(fileId); if (projectForFile == null) { LOG.error("ensureFileBelongsToIndexableFilter returned ADDED or PRESENT, but findProjectForFileId returned null for file: " + file); doInvalidateIndicesForFile(fileId, file); return; } var indexingRequest = projectForFile.getService(ProjectIndexingDependenciesService.class).getLatestIndexingRequestToken(); var indexingStamp = indexingRequest.getFileIndexingStamp(file); List<ID<?, ?>> nontrivialFileIndexedStates = IndexingStamp.getNontrivialFileIndexedStates(fileId); // transient index value can depend on disk value because former is diff to latter // it doesn't matter content froze or not: indices might depend on file name too removeTransientFileDataFromIndices(nontrivialFileIndexedStates, fileId, file); boolean isRegularFile = !file.isDirectory(); IndexedFileImpl indexedFile = new IndexedFileImpl(file, projectForFile); // Apply index contentless indexes in-place // For 'normal indices' schedule the file for update and reset stamps for all affected indices (there // can be a client that used indices between before and after events, in such case indices are up-to-date due to force update // with old content) if (!file.isValid() || (isRegularFile && isTooLarge(file))) { // large file might be scheduled for update in before event when its size was not large getChangedFilesCollector().scheduleForUpdate(new DeletedVirtualFileStub((VirtualFileWithId)file)); } else { FileTypeManagerEx.getInstanceEx().freezeFileTypeTemporarilyIn(file, () -> { List<ID<?, ?>> candidates = getRequiredIndexes(indexedFile); // TODO-ank: delete not needed indexed data now? (will be deleted during indexing) boolean scheduleForUpdate = false; FileContent fileContent = null; for (int i = 0, size = candidates.size(); i < size; ++i) { final ID<?, ?> indexId = candidates.get(i); if (needsFileContentLoading(indexId)) { getIndex(indexId).invalidateIndexedStateForFile(fileId); scheduleForUpdate = true; } else if (!contentChange || indexId == FileTypeIndex.NAME){ // TODO-ank: quite a strange condition. Mostly to preserve old behavior // and please the test com.intellij.util.indexing.RequestedToRebuildIndexTest if (fileContent == null) { fileContent = new IndexedFileWrapper(indexedFile); } updateSingleIndex(indexId, file, fileId, fileContent); } } if (scheduleForUpdate) { IndexingStamp.flushCache(fileId); getChangedFilesCollector().scheduleForUpdate(file); } else { IndexingFlag.setFileIndexed(file, indexingStamp); } }); } }