From dcf14b48fb091734c40822f57637d2baeb0674eb Mon Sep 17 00:00:00 2001 From: Tomas Husak Date: Fri, 23 Jan 2026 10:58:52 +0100 Subject: [PATCH] CPP-47417 [platform]: add WorkspaceFileKind.EXTERNAL_NON_INDEXABLE Space-RevId: 02224f127daa7c1a5712fb07101b27dc0f6e4fce GitOrigin-RevId: 1d4c9807baab256fed17e35eac5e913d02efbd10 --- .../file/impl/ResolveScopeManagerImpl.java | 2 +- .../NonIndexableFilesSEContributor.kt | 2 +- .../util/indexing/NonIndexableFilesUtils.kt | 4 +- .../util/indexing/ReincludedRootsUtil.java | 2 +- .../contentQueue/IndexUpdateRunner.kt | 4 +- .../roots/IndexingIteratorsProviderImpl.kt | 1 + .../ide/ShowWorkspaceFileStateAction.kt | 2 +- .../openapi/vfs/newvfs/RefreshWorker.java | 2 +- .../core/fileIndex/CustomKindFileSetTest.kt | 2 +- .../core/fileIndex/NonIndexableFileSetTest.kt | 2 +- .../NonRecursiveWorkspaceFileSetTest.kt | 8 +-- .../api-dump-experimental.txt | 9 ++-- .../ProjectModelEntityContextProvider.kt | 1 + .../roots/impl/DirectoryIndexImpl.java | 2 +- .../roots/impl/ModuleFileIndexImpl.java | 10 ++-- .../roots/impl/ProjectFileIndexFacade.java | 4 +- .../roots/impl/ProjectFileIndexImpl.java | 50 +++++++++---------- .../core/fileIndex/WorkspaceFileIndex.kt | 9 +++- .../WorkspaceFileIndexContributor.kt | 9 +++- .../impl/EmptyWorkspaceFileIndexData.kt | 1 + .../fileIndex/impl/WorkspaceFileIndexData.kt | 1 + .../impl/WorkspaceFileIndexDataImpl.kt | 9 ++-- .../fileIndex/impl/WorkspaceFileIndexEx.kt | 3 ++ .../fileIndex/impl/WorkspaceFileIndexImpl.kt | 30 +++++++---- .../impl/infiniteProcessingReporting.kt | 2 +- .../core/fileIndex/impl/workspaceFileSets.kt | 3 +- .../provider/CandidateCollector.kt | 1 + 27 files changed, 106 insertions(+), 69 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java b/platform/analysis-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java index ff6b23b9e915..5313c86df0df 100644 --- a/platform/analysis-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java +++ b/platform/analysis-impl/src/com/intellij/psi/impl/file/impl/ResolveScopeManagerImpl.java @@ -207,7 +207,7 @@ public final class ResolveScopeManagerImpl extends ResolveScopeManager implement var empty = projectFileIndex.findContainingLibraries(notNullVFile).isEmpty() && projectFileIndex.findContainingSdks(notNullVFile).isEmpty(); if (empty && - (WorkspaceFileIndex.getInstance(myProject).findFileSet(notNullVFile, true, false, false, true, true, true) != null || + (WorkspaceFileIndex.getInstance(myProject).findFileSet(notNullVFile, true, false, false, true, true, true, true) != null || myAdditionalIndexableFileSet.isInSet(notNullVFile))) { return allScope; } diff --git a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/NonIndexableFilesSEContributor.kt b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/NonIndexableFilesSEContributor.kt index 6416a6ca89b7..592a86b0e8aa 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/NonIndexableFilesSEContributor.kt +++ b/platform/lang-impl/src/com/intellij/ide/actions/searcheverywhere/NonIndexableFilesSEContributor.kt @@ -189,7 +189,7 @@ class NonIndexableFilesSEContributor(event: AnActionEvent) : WeightedSearchEvery private fun WorkspaceFileIndexEx.findNonIndexableFileSet( file: VirtualFile, -): WorkspaceFileSet? = findFileSet(file, true, false, true, false, false, false) +): WorkspaceFileSet? = findFileSet(file, true, false, true, false, false, true, false) private fun PsiManager.getPsiFileSystemItem(file: VirtualFile): PsiFileSystemItem? = when { file.isDirectory -> ReadAction.nonBlocking { findDirectory(file) }.executeSynchronously() diff --git a/platform/lang-impl/src/com/intellij/util/indexing/NonIndexableFilesUtils.kt b/platform/lang-impl/src/com/intellij/util/indexing/NonIndexableFilesUtils.kt index 61e784808a3a..925ab4773e8d 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/NonIndexableFilesUtils.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/NonIndexableFilesUtils.kt @@ -58,7 +58,7 @@ private data class AllFileSets(val recursive: List, val nonRec private fun WorkspaceFileIndex.allIndexableFileSets(root: VirtualFile): AllFileSets { val indexableFileSets = runReadAction { - findFileSets(root, true, true, false, true, true, true) + findFileSets(root, true, true, false, true, true, false, true) } return indexableFileSets .partition { fileSet -> fileSet !is WorkspaceFileSetWithCustomData<*> || fileSet.recursive } @@ -67,7 +67,7 @@ private fun WorkspaceFileIndex.allIndexableFileSets(root: VirtualFile): AllFileS private fun WorkspaceFileIndexEx.isExcludedOrInvalid(file: VirtualFile): Boolean { val info = runReadAction { - getFileInfo(file, true, true, true, true, true, true) + getFileInfo(file, true, true, true, true, true, true, true) } return when (info) { NonWorkspace.EXCLUDED -> true diff --git a/platform/lang-impl/src/com/intellij/util/indexing/ReincludedRootsUtil.java b/platform/lang-impl/src/com/intellij/util/indexing/ReincludedRootsUtil.java index eb3d8cf81561..2559acc06b34 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/ReincludedRootsUtil.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/ReincludedRootsUtil.java @@ -102,7 +102,7 @@ public final class ReincludedRootsUtil { VirtualFileUrlManager fileUrlManager = WorkspaceModel.getInstance(project).getVirtualFileUrlManager(); for (VirtualFile file : files) { WorkspaceFileSet fileSet = ReadAction.nonBlocking(() -> { - return workspaceFileIndex.findFileSet(file, true, true, true, true, true, true); + return workspaceFileIndex.findFileSet(file, true, true, true, true, true, true, true); }).expireWith(project).executeSynchronously(); if (fileSet == null) { diff --git a/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt b/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt index a87d365e7308..884433070ac4 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/contentQueue/IndexUpdateRunner.kt @@ -316,11 +316,11 @@ class IndexUpdateRunner( val workspaceFileIndex = WorkspaceFileIndex.getInstance(project) val excluded = readActionUndispatched { val isIndexable = workspaceFileIndex.isIndexable(file) - val belongsToContentNonIndexable = workspaceFileIndex.findFileSet(file, true, false, includeContentNonIndexableSets = true, false, false, false) != null + val belongsToNonIndexable = workspaceFileIndex.findFileSet(file, true, false, includeContentNonIndexableSets = true, false, false, includeExternalNonIndexableSets = true, false) != null // We don't want to just exclude all !isIndexable, // because they may be contributed by an indexing contributor while WorkspaceFileIndex is not aware about it. // We only want to exclude the files that are explicitly registered as non indexable. - ProjectRootManager.getInstance(project).fileIndex.isExcluded(file) || (!isIndexable && belongsToContentNonIndexable) + ProjectRootManager.getInstance(project).fileIndex.isExcluded(file) || (!isIndexable && belongsToNonIndexable) } if (excluded) { val counter = badFileCounter.incrementAndGet() diff --git a/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexingIteratorsProviderImpl.kt b/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexingIteratorsProviderImpl.kt index eabf153aef83..e6bb04c382d6 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexingIteratorsProviderImpl.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexingIteratorsProviderImpl.kt @@ -154,6 +154,7 @@ class IndexingIteratorsProviderImpl( includeContentNonIndexableSets = true, includeExternalSets = false, includeExternalSourceSets = false, + includeExternalNonIndexableSets = false, includeCustomKindSets = false ) return fileInfo.findFileSet { fileSet -> hasRecursiveRootFromModuleContent(fileSet, module) } != null diff --git a/platform/lang-impl/src/com/intellij/workspaceModel/ide/ShowWorkspaceFileStateAction.kt b/platform/lang-impl/src/com/intellij/workspaceModel/ide/ShowWorkspaceFileStateAction.kt index d120e1208ae1..cb1f34d91faa 100644 --- a/platform/lang-impl/src/com/intellij/workspaceModel/ide/ShowWorkspaceFileStateAction.kt +++ b/platform/lang-impl/src/com/intellij/workspaceModel/ide/ShowWorkspaceFileStateAction.kt @@ -23,7 +23,7 @@ internal class ShowWorkspaceFileStateAction : DumbAwareAction() { val fileSets = WorkspaceFileIndex .getInstance(project) - .findFileSets(virtualFile, true, true, true, true, true, true) + .findFileSets(virtualFile, true, true, true, true, true, true, true) val baseListPopupStep = object : BaseListPopupStep("Workspace File State", fileSets) { override fun isSpeedSearchEnabled() = true diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshWorker.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshWorker.java index 3b82da692711..e87a029a0746 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshWorker.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/RefreshWorker.java @@ -600,7 +600,7 @@ final class RefreshWorker { for (Project openProject : ProjectManager.getInstance().getOpenProjects()) { if (ReadAction.compute(() -> { List indexableFileSet = WorkspaceFileIndex.getInstance(openProject) - .findFileSets(parent, true, true, /*includeContentNonIndexableSets*/ false, true, true, true); + .findFileSets(parent, true, true, /*includeContentNonIndexableSets*/ false, true, true, /*includeExternalNonIndexableSets*/ false, true); return ContainerUtil.exists(indexableFileSet, set -> set instanceof WorkspaceFileSetWithCustomData && ((WorkspaceFileSetWithCustomData)set).getRecursive()); })) { return true; diff --git a/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/CustomKindFileSetTest.kt b/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/CustomKindFileSetTest.kt index eaf313e7d191..79d6f65761fa 100644 --- a/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/CustomKindFileSetTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/CustomKindFileSetTest.kt @@ -76,7 +76,7 @@ class CustomKindFileSetTest { assertFalse(module.moduleContentScope.contains(file)) assertFalse(module.moduleScope.contains(file)) assertIteratedContent(projectModel.project, mustNotContain = listOf(root, file)) - val fileSet = fileIndex.findFileSet(file, true, true, true, true, true, true) + val fileSet = fileIndex.findFileSet(file, true, true, true, true, true, true, true) assertNotNull(fileSet) assertEquals(WorkspaceFileKind.CUSTOM, fileSet!!.kind) } diff --git a/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonIndexableFileSetTest.kt b/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonIndexableFileSetTest.kt index 84ae26bd1450..2f9f0d79d703 100644 --- a/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonIndexableFileSetTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonIndexableFileSetTest.kt @@ -79,7 +79,7 @@ class NonIndexableFileSetTest { assertFalse(fileIndex.isIndexable(root)) assertTrue(projectFileIndex.isInProjectOrExcluded(file)) assertIteratedContent(projectModel.project, mustContain = listOf(root, file)) - val fileSet = fileIndex.findFileSet(file, true, true, true, true, true, true) + val fileSet = fileIndex.findFileSet(file, true, true, true, true, true, true, true) assertNotNull(fileSet) assertEquals(WorkspaceFileKind.CONTENT_NON_INDEXABLE, fileSet!!.kind) } diff --git a/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonRecursiveWorkspaceFileSetTest.kt b/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonRecursiveWorkspaceFileSetTest.kt index ebc3f302a312..40d7042d0b1f 100644 --- a/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonRecursiveWorkspaceFileSetTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/workspaceModel/core/fileIndex/NonRecursiveWorkspaceFileSetTest.kt @@ -66,9 +66,9 @@ class NonRecursiveWorkspaceFileSetTest { it.addEntity(NonRecursiveTestEntity(url, NonPersistentEntitySource)) } readAction { - val fileSet = workspaceFileIndex.findFileSetWithCustomData(file, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) + val fileSet = workspaceFileIndex.findFileSetWithCustomData(file, true, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) assertNull(fileSet) - val nonRecursiveDirFileSet = workspaceFileIndex.findFileSetWithCustomData(nonRecursiveDir, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) + val nonRecursiveDirFileSet = workspaceFileIndex.findFileSetWithCustomData(nonRecursiveDir, true, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) assertNotNull(nonRecursiveDirFileSet) } } @@ -89,9 +89,9 @@ class NonRecursiveWorkspaceFileSetTest { it.addEntity(NonRecursiveTestEntity(url, NonPersistentEntitySource)) } readAction { - val fileSet = workspaceFileIndex.findFileSetWithCustomData(file, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) + val fileSet = workspaceFileIndex.findFileSetWithCustomData(file, true, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) assertNull(fileSet) - val nonRecursiveDirFileSet = workspaceFileIndex.findFileSetWithCustomData(nonRecursiveDir, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) + val nonRecursiveDirFileSet = workspaceFileIndex.findFileSetWithCustomData(nonRecursiveDir, true, true, true, true, true, true, true, NonRecursiveFileCustomData::class.java) assertNotNull(nonRecursiveDirFileSet) } } diff --git a/platform/projectModel-impl/api-dump-experimental.txt b/platform/projectModel-impl/api-dump-experimental.txt index b26a48c8e07c..d1216573b4cd 100644 --- a/platform/projectModel-impl/api-dump-experimental.txt +++ b/platform/projectModel-impl/api-dump-experimental.txt @@ -53,10 +53,10 @@ c:com.intellij.openapi.roots.impl.ProjectFileIndexFacade - s:values():com.intellij.workspaceModel.core.fileIndex.EntityStorageKind[] *:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileIndex - *sf:Companion:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileIndex$Companion -- a:findFileSet(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z):com.intellij.workspaceModel.core.fileIndex.WorkspaceFileSet -- a:findFileSetWithCustomData(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z,java.lang.Class):com.intellij.workspaceModel.core.fileIndex.WorkspaceFileSetWithCustomData -- *a:findFileSets(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z):java.util.List -- *a:findFileSetsWithCustomData(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z,java.lang.Class):java.util.List +- a:findFileSet(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z,Z):com.intellij.workspaceModel.core.fileIndex.WorkspaceFileSet +- a:findFileSetWithCustomData(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z,Z,java.lang.Class):com.intellij.workspaceModel.core.fileIndex.WorkspaceFileSetWithCustomData +- *a:findFileSets(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z,Z):java.util.List +- *a:findFileSetsWithCustomData(com.intellij.openapi.vfs.VirtualFile,Z,Z,Z,Z,Z,Z,Z,java.lang.Class):java.util.List - a:getContentFileSetRoot(com.intellij.openapi.vfs.VirtualFile,Z):com.intellij.openapi.vfs.VirtualFile - s:getInstance(com.intellij.openapi.project.Project):com.intellij.workspaceModel.core.fileIndex.WorkspaceFileIndex - a:isInContent(com.intellij.openapi.vfs.VirtualFile):Z @@ -76,6 +76,7 @@ c:com.intellij.openapi.roots.impl.ProjectFileIndexFacade - sf:CONTENT_NON_INDEXABLE:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileKind - sf:CUSTOM:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileKind - sf:EXTERNAL:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileKind +- sf:EXTERNAL_NON_INDEXABLE:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileKind - sf:EXTERNAL_SOURCE:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileKind - sf:TEST_CONTENT:com.intellij.workspaceModel.core.fileIndex.WorkspaceFileKind - s:getEntries():kotlin.enums.EnumEntries diff --git a/platform/projectModel-impl/src/com/intellij/multiverse/ProjectModelEntityContextProvider.kt b/platform/projectModel-impl/src/com/intellij/multiverse/ProjectModelEntityContextProvider.kt index 8b2f438a6b04..f1d334302777 100644 --- a/platform/projectModel-impl/src/com/intellij/multiverse/ProjectModelEntityContextProvider.kt +++ b/platform/projectModel-impl/src/com/intellij/multiverse/ProjectModelEntityContextProvider.kt @@ -37,6 +37,7 @@ internal class ProjectModelEntityContextProvider : CodeInsightContextProvider { includeContentNonIndexableSets = true, includeExternalSets = true, includeExternalSourceSets = true, + includeExternalNonIndexableSets = true, includeCustomKindSets = true ) if (fileSets.isEmpty()) return emptyList() diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java index 826fcc8e6b88..f93242492f2c 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java @@ -123,7 +123,7 @@ public final class DirectoryIndexImpl extends DirectoryIndex implements Disposab public @NotNull List getOrderEntries(@NotNull VirtualFile fileOrDir) { checkAvailability(); if (myProject.isDefault()) return Collections.emptyList(); - WorkspaceFileInternalInfo fileInfo = myWorkspaceFileIndex.getFileInfo(fileOrDir, true, true, true, true, true, false); + WorkspaceFileInternalInfo fileInfo = myWorkspaceFileIndex.getFileInfo(fileOrDir, true, true, true, true, true, true, false); WorkspaceFileSetWithCustomData fileSet = fileInfo.findFileSet(data -> true); if (fileSet == null) return Collections.emptyList(); return getRootIndex().getOrderEntries(fileSet.getRoot()); diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java index 047de2d3fe8a..5427dc93867a 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ModuleFileIndexImpl.java @@ -81,7 +81,7 @@ public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileInde if (parent == null) { return false; } - WorkspaceFileInternalInfo fileInfo = myWorkspaceFileIndex.getFileInfo(parent, false, true, true, false, false, false); + WorkspaceFileInternalInfo fileInfo = myWorkspaceFileIndex.getFileInfo(parent, false, true, true, false, false, false, false); return fileInfo.findFileSet(this::hasRecursiveRootFromModuleContent) != null; } @@ -95,7 +95,7 @@ public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileInde @Override public boolean isInContent(@NotNull VirtualFile fileOrDir) { WorkspaceFileSetWithCustomData fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, ModuleRelatedRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, false, ModuleRelatedRootData.class); return isFromThisModule(fileSet); } @@ -105,7 +105,7 @@ public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileInde @Override public boolean isInSourceContent(@NotNull VirtualFile fileOrDir) { - WorkspaceFileSetWithCustomData fileSet = myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, ModuleSourceRootData.class); + WorkspaceFileSetWithCustomData fileSet = myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, false, ModuleSourceRootData.class); return fileSet != null && isFromThisModule(fileSet); } @@ -121,13 +121,13 @@ public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileInde @Override public boolean isInTestSourceContent(@NotNull VirtualFile fileOrDir) { - WorkspaceFileSetWithCustomData fileSet = myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, ModuleSourceRootData.class); + WorkspaceFileSetWithCustomData fileSet = myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, false, ModuleSourceRootData.class); return fileSet != null && isFromThisModule(fileSet) && fileSet.getKind() == WorkspaceFileKind.TEST_CONTENT; } @Override public boolean isUnderSourceRootOfType(@NotNull VirtualFile fileOrDir, @NotNull Set> rootTypes) { - WorkspaceFileSetWithCustomData fileSet = myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, ModuleSourceRootData.class); + WorkspaceFileSetWithCustomData fileSet = myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, false, ModuleSourceRootData.class); return isFromThisModule(fileSet) && ProjectFileIndexImpl.isSourceRootOfType(fileSet, rootTypes); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexFacade.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexFacade.java index 7556cb835509..75d05b651352 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexFacade.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexFacade.java @@ -126,11 +126,11 @@ public class ProjectFileIndexFacade extends FileIndexFacade { @Override public boolean isInProjectScope(@NotNull VirtualFile file) { // optimization: equivalent to the super method but has fewer getInfoForFile() calls - WorkspaceFileInternalInfo fileInfo = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, false, false); + WorkspaceFileInternalInfo fileInfo = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, false, true, false); if (fileInfo instanceof WorkspaceFileInternalInfo.NonWorkspace) { return false; } - if (fileInfo.findFileSet(it -> it.getKind() == WorkspaceFileKind.EXTERNAL) != null && !myFileIndex.isInSourceContent(file)) { + if (fileInfo.findFileSet(it -> it.getKind() == WorkspaceFileKind.EXTERNAL || it.getKind() == WorkspaceFileKind.EXTERNAL_NON_INDEXABLE) != null && !myFileIndex.isInSourceContent(file)) { return false; } return true; diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java index 5d542b103a48..b1a9495beb63 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/ProjectFileIndexImpl.java @@ -78,34 +78,34 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public boolean isExcluded(@NotNull VirtualFile file) { - WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, true, true); + WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, true, true, true); return info == WorkspaceFileInternalInfo.NonWorkspace.IGNORED || info == WorkspaceFileInternalInfo.NonWorkspace.EXCLUDED; } @Override public @NotNull Collection<@NotNull LibraryEntity> findContainingLibraries(@NotNull VirtualFile fileOrDir) { - return myWorkspaceFileIndex.findContainingEntities(fileOrDir, LibraryEntity.class, true, false, false, true, true, false); + return myWorkspaceFileIndex.findContainingEntities(fileOrDir, LibraryEntity.class, true, false, false, true, true, true, false); } @Override public @NotNull @Unmodifiable Collection<@NotNull SdkEntity> findContainingSdks(@NotNull VirtualFile fileOrDir) { - return myWorkspaceFileIndex.findContainingEntities(fileOrDir, SdkEntity.class, true, false, false, true, true, false); + return myWorkspaceFileIndex.findContainingEntities(fileOrDir, SdkEntity.class, true, false, false, true, true, true, false); } @Override public boolean isUnderIgnored(@NotNull VirtualFile file) { - WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, true, true); + WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, true, true, true); return info == WorkspaceFileInternalInfo.NonWorkspace.IGNORED; } @Override public boolean isInProject(@NotNull VirtualFile file) { - return myWorkspaceFileIndex.findFileSet(file, true, true, true, true, true, false) != null; + return myWorkspaceFileIndex.findFileSet(file, true, true, true, true, true, true, false) != null; } @Override public boolean isInProjectOrExcluded(@NotNull VirtualFile file) { - WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, true, false); + WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, true, true, false); return info == WorkspaceFileInternalInfo.NonWorkspace.EXCLUDED || !(info instanceof WorkspaceFileInternalInfo.NonWorkspace); } @@ -117,7 +117,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public @Nullable Module getModuleForFile(@NotNull VirtualFile file, boolean honorExclusion) { WorkspaceFileSetWithCustomData fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(file, honorExclusion, true, true, false, false, false, ModuleRelatedRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(file, honorExclusion, true, true, false, false, false, false, ModuleRelatedRootData.class); if (fileSet == null) return null; return fileSet.getData().getModule(); } @@ -125,7 +125,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public @NotNull Set getModulesForFile(@NotNull VirtualFile file, boolean honorExclusion) { List> fileSet = myWorkspaceFileIndex.findFileSetsWithCustomData( - file, honorExclusion, true, true, false, false, false, ModuleRelatedRootData.class + file, honorExclusion, true, true, false, false, false, false, ModuleRelatedRootData.class ); return ContainerUtil.map2LinkedSet(fileSet, s -> s.getData().getModule()); } @@ -137,7 +137,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public VirtualFile getClassRootForFile(@NotNull VirtualFile file) { - WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(file, true, false, false, true, false, false); + WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(file, true, false, false, true, false, false, false); if (fileSet == null) return null; return fileSet.getRoot(); } @@ -145,7 +145,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public @Nullable JpsModuleSourceRootType getContainingSourceRootType(@NotNull VirtualFile file) { WorkspaceFileSetWithCustomData fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(file, true, true, true, false, false, false, ModuleSourceRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(file, true, true, true, false, false, false, false, ModuleSourceRootData.class); if (fileSet == null) return null; return SourceRootTypeRegistry.getInstance().findTypeById(fileSet.getData().getRootTypeId()); @@ -154,14 +154,14 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public boolean isInGeneratedSources(@NotNull VirtualFile file) { WorkspaceFileSetWithCustomData fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(file, true, true, true, false, false, false, ModuleSourceRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(file, true, true, true, false, false, false, false, ModuleSourceRootData.class); return fileSet != null && fileSet.getData().getForGeneratedSources(); } @Override public VirtualFile getSourceRootForFile(@NotNull VirtualFile file) { WorkspaceFileSet fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(file, true, true, true, false, true, false, ModuleOrLibrarySourceRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(file, true, true, true, false, true, false, false, ModuleOrLibrarySourceRootData.class); if (fileSet == null) return null; return fileSet.getRoot(); } @@ -174,12 +174,12 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public VirtualFile getContentRootForFile(@NotNull VirtualFile file, final boolean honorExclusion) { WorkspaceFileSetWithCustomData fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(file, honorExclusion, true, true, false, false, false, + myWorkspaceFileIndex.findFileSetWithCustomData(file, honorExclusion, true, true, false, false, false, false, ModuleContentOrSourceRootData.class); if (fileSet == null) { if (!honorExclusion) { WorkspaceFileSetWithCustomData unloadedFileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(file, false, true, true, false, false, false, + myWorkspaceFileIndex.findFileSetWithCustomData(file, false, true, true, false, false, false, false, UnloadedModuleContentRootData.class); if (unloadedFileSet != null) return unloadedFileSet.getRoot(); } @@ -201,33 +201,33 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public boolean isLibraryClassFile(@NotNull VirtualFile file) { if (file.isDirectory()) return false; - WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(file, true, false, false, true, false, false); + WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(file, true, false, false, true, false, false, false); return fileSet != null; } @Override public boolean isInSource(@NotNull VirtualFile fileOrDir) { WorkspaceFileSet fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, true, false, ModuleOrLibrarySourceRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, true, false, false, ModuleOrLibrarySourceRootData.class); return fileSet != null; } @Override public boolean isInLibraryClasses(@NotNull VirtualFile fileOrDir) { - WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(fileOrDir, true, false, false, true, false, false); + WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(fileOrDir, true, false, false, true, false, false, false); return fileSet != null; } @Override public boolean isInLibrarySource(@NotNull VirtualFile fileOrDir) { - WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(fileOrDir, true, false, false, false, true, false); + WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(fileOrDir, true, false, false, false, true, false, false); return fileSet != null; } // a slightly faster implementation than the default one @Override public boolean isInLibrary(@NotNull VirtualFile fileOrDir) { - WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(fileOrDir, true, false, false, true, true, false); + WorkspaceFileSet fileSet = myWorkspaceFileIndex.findFileSet(fileOrDir, true, false, false, true, true, true, false); return fileSet != null; } @@ -237,7 +237,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn } public @Nullable VirtualFile getModuleSourceOrLibraryClassesRoot(@NotNull VirtualFile file) { - WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, false, false); + WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, false, false, false); WorkspaceFileSetWithCustomData fileSet = info.findFileSet(it -> { WorkspaceFileKind kind = it.getKind(); return kind.isContent() && it.getData() instanceof ModuleOrLibrarySourceRootData || kind == WorkspaceFileKind.EXTERNAL; @@ -246,7 +246,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn } public @NotNull Collection getModuleSourceOrLibraryClassesRoots(@NotNull VirtualFile file) { - WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, false, false); + WorkspaceFileInternalInfo info = myWorkspaceFileIndex.getFileInfo(file, true, true, true, true, false, false, false); List> fileSets = info.findFileSets(it -> { WorkspaceFileKind kind = it.getKind(); return kind.isContent() && it.getData() instanceof ModuleOrLibrarySourceRootData || kind == WorkspaceFileKind.EXTERNAL; @@ -273,21 +273,21 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public boolean isInSourceContent(@NotNull VirtualFile fileOrDir) { WorkspaceFileSet fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, ModuleSourceRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, false, ModuleSourceRootData.class); return fileSet != null; } @Override public boolean isInTestSourceContent(@NotNull VirtualFile fileOrDir) { WorkspaceFileSet fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, ModuleSourceRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, false, ModuleSourceRootData.class); return fileSet != null && fileSet.getKind() == WorkspaceFileKind.TEST_CONTENT; } @Override public boolean isUnderSourceRootOfType(@NotNull VirtualFile fileOrDir, @NotNull Set> rootTypes) { WorkspaceFileSetWithCustomData fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, ModuleSourceRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, true, false, false, false, false, ModuleSourceRootData.class); return isSourceRootOfType(fileSet, rootTypes); } @@ -300,7 +300,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn @Override public @Nullable String getUnloadedModuleNameForFile(@NotNull VirtualFile fileOrDir) { WorkspaceFileSetWithCustomData fileSet = - myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, false, true, true, false, false, false, UnloadedModuleContentRootData.class); + myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, false, true, true, false, false, false, false, UnloadedModuleContentRootData.class); return fileSet != null ? fileSet.getData().getModuleName() : null; } diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndex.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndex.kt index 255b71f7bb89..da3a029bff81 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndex.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndex.kt @@ -40,7 +40,8 @@ interface WorkspaceFileIndex { fun isInContent(file: VirtualFile): Boolean /** - * Returns `true` if [file] is included to the workspace and doesn't have [WorkspaceFileKind.CONTENT_NON_INDEXABLE] kind. + * Returns `true` if [file] is included to the workspace and doesn't have [WorkspaceFileKind.CONTENT_NON_INDEXABLE] or + * [WorkspaceFileKind.EXTERNAL_NON_INDEXABLE] kind. */ @RequiresReadLock fun isIndexable(file: VirtualFile): Boolean @@ -75,6 +76,7 @@ interface WorkspaceFileIndex { * @param includeContentSets if `true` file sets of [content][WorkspaceFileKind.isContent] kind will be processed * @param includeExternalSets if `true` file sets of [WorkspaceFileKind.EXTERNAL] kind will be processed * @param includeExternalSourceSets if `true` file sets of [WorkspaceFileKind.EXTERNAL_SOURCE] kind will be processed + * @param includeExternalNonIndexableSets if `true` file sets of [WorkspaceFileKind.EXTERNAL_NON_INDEXABLE] kind will be processed * @param includeCustomKindSets if `true` file sets of [WorkspaceFileKind.CUSTOM] kind will be processed */ fun findFileSet( @@ -84,6 +86,7 @@ interface WorkspaceFileIndex { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean ): WorkspaceFileSet? @@ -97,6 +100,7 @@ interface WorkspaceFileIndex { * @param includeContentSets if `true` file sets of [content][WorkspaceFileKind.isContent] kind will be processed * @param includeExternalSets if `true` file sets of [WorkspaceFileKind.EXTERNAL] kind will be processed * @param includeExternalSourceSets if `true` file sets of [WorkspaceFileKind.EXTERNAL_SOURCE] kind will be processed + * @param includeExternalNonIndexableSets if `true` file sets of [WorkspaceFileKind.EXTERNAL_NON_INDEXABLE] kind will be processed * @param includeCustomKindSets if `true` file sets of [WorkspaceFileKind.CUSTOM] kind will be processed */ @ApiStatus.Experimental @@ -107,6 +111,7 @@ interface WorkspaceFileIndex { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean ): List @@ -121,6 +126,7 @@ interface WorkspaceFileIndex { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, customDataClass: Class, ): WorkspaceFileSetWithCustomData? @@ -137,6 +143,7 @@ interface WorkspaceFileIndex { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, customDataClass: Class, ): List> diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndexContributor.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndexContributor.kt index 27fb67c7ad92..745a94e816e7 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndexContributor.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/WorkspaceFileIndexContributor.kt @@ -160,6 +160,13 @@ enum class WorkspaceFileKind { */ EXTERNAL_SOURCE, + /** + * Describes external files which may be referenced by [CONTENT] files, but aren't supposed to be edited in the IDE, + * and should NOT be indexed. This is useful for library files that should be visible in the workspace but don't + * need to be indexed (e.g., header search paths in C++ projects that are too large to index). + */ + EXTERNAL_NON_INDEXABLE, + /** * Describes files which may be referenced by [CONTENT], [EXTERNAL], or [EXTERNAL_SOURCE] files, * and aren't supposed to be edited in the IDE. @@ -175,7 +182,7 @@ enum class WorkspaceFileKind { get() = this == CONTENT || this == TEST_CONTENT || this == CONTENT_NON_INDEXABLE val isIndexable: Boolean - get() = (this != CONTENT_NON_INDEXABLE) + get() = (this != CONTENT_NON_INDEXABLE && this != EXTERNAL_NON_INDEXABLE) } /** diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/EmptyWorkspaceFileIndexData.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/EmptyWorkspaceFileIndexData.kt index a8719d0eaa4a..b2b29767bc3f 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/EmptyWorkspaceFileIndexData.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/EmptyWorkspaceFileIndexData.kt @@ -26,6 +26,7 @@ class EmptyWorkspaceFileIndexData private constructor(private val debugName: Str includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean ): WorkspaceFileInternalInfo { return WorkspaceFileInternalInfo.NonWorkspace.NOT_UNDER_ROOTS diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexData.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexData.kt index 4bba23ccc056..aafbf9343d4c 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexData.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexData.kt @@ -21,6 +21,7 @@ interface WorkspaceFileIndexData { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean): WorkspaceFileInternalInfo @RequiresReadLock diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexDataImpl.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexDataImpl.kt index d77a2221d809..6c6ffa79d4cc 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexDataImpl.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexDataImpl.kt @@ -167,6 +167,7 @@ internal class WorkspaceFileIndexDataImpl( includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean ): WorkspaceFileInternalInfo = WorkspaceFileIndexDataMetrics.getFileInfoTimeNanosec.addMeasuredTime { if (!file.isValid) return@addMeasuredTime WorkspaceFileInternalInfo.NonWorkspace.INVALID @@ -180,6 +181,7 @@ internal class WorkspaceFileIndexDataImpl( (if (includeContentNonIndexableSets) WorkspaceFileKindMask.CONTENT_NON_INDEXABLE else 0) or (if (includeExternalSets) WorkspaceFileKindMask.EXTERNAL_BINARY else 0) or (if (includeExternalSourceSets) WorkspaceFileKindMask.EXTERNAL_SOURCE else 0) or + (if (includeExternalNonIndexableSets) WorkspaceFileKindMask.EXTERNAL_NON_INDEXABLE else 0) or (if (includeCustomKindSets) WorkspaceFileKindMask.CUSTOM else 0) var acceptedKindsMask = originalAcceptedKindMask var current: VirtualFile? = file @@ -582,7 +584,7 @@ internal class WorkspaceFileIndexDataImpl( } override fun getPackageName(dirOrFile: VirtualFile): String? = WorkspaceFileIndexDataMetrics.getPackageNameTimeNanosec.addMeasuredTime { - val fileSet = when (val info = getFileInfo(dirOrFile, true, true, true, true, true, true)) { + val fileSet = when (val info = getFileInfo(dirOrFile, true, true, true, true, true, true, true)) { is WorkspaceFileSetWithCustomData<*> -> info.takeIf { it.data is JvmPackageRootDataInternal } is MultipleWorkspaceFileSets -> info.find(JvmPackageRootDataInternal::class.java) else -> null @@ -606,7 +608,7 @@ internal class WorkspaceFileIndexDataImpl( val query = CollectionQuery(packageDirectoryCache.getDirectoriesByPackageName(packageName)) return@addMeasuredTime if (includeLibrarySources) query else query.filtering { - getFileInfo(it, true, true, true, true, false, true) !is WorkspaceFileInternalInfo.NonWorkspace + getFileInfo(it, true, true, true, true, false, true, true) !is WorkspaceFileInternalInfo.NonWorkspace } } @@ -759,6 +761,7 @@ internal fun WorkspaceFileKind.toMask(): Int { WorkspaceFileKind.CONTENT, WorkspaceFileKind.TEST_CONTENT -> WorkspaceFileKindMask.CONTENT WorkspaceFileKind.EXTERNAL -> WorkspaceFileKindMask.EXTERNAL_BINARY WorkspaceFileKind.EXTERNAL_SOURCE -> WorkspaceFileKindMask.EXTERNAL_SOURCE + WorkspaceFileKind.EXTERNAL_NON_INDEXABLE -> WorkspaceFileKindMask.EXTERNAL_NON_INDEXABLE WorkspaceFileKind.CUSTOM -> WorkspaceFileKindMask.CUSTOM WorkspaceFileKind.CONTENT_NON_INDEXABLE -> WorkspaceFileKindMask.CONTENT_NON_INDEXABLE } @@ -864,7 +867,7 @@ private class StoreFileSetsRegistrarImpl( } else { val mask = when (excludedFrom) { - WorkspaceFileKind.EXTERNAL -> WorkspaceFileKindMask.EXTERNAL + WorkspaceFileKind.EXTERNAL -> WorkspaceFileKindMask.EXTERNAL or WorkspaceFileKindMask.EXTERNAL_NON_INDEXABLE WorkspaceFileKind.CONTENT -> WorkspaceFileKindMask.CONTENT or WorkspaceFileKindMask.CONTENT_NON_INDEXABLE else -> excludedFrom.toMask() } diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexEx.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexEx.kt index bab7664d3a93..317cfaaf4a6a 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexEx.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexEx.kt @@ -35,6 +35,7 @@ interface WorkspaceFileIndexEx : WorkspaceFileIndex { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean): WorkspaceFileInternalInfo /** @@ -52,6 +53,7 @@ interface WorkspaceFileIndexEx : WorkspaceFileIndex { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean): Collection /** @@ -66,6 +68,7 @@ interface WorkspaceFileIndexEx : WorkspaceFileIndex { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, ): Collection diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexImpl.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexImpl.kt index e0f192cbc63c..f29b073cfd72 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexImpl.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/WorkspaceFileIndexImpl.kt @@ -90,6 +90,7 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets = true, includeExternalSets = true, includeExternalSourceSets = true, + includeExternalNonIndexableSets = true, includeCustomKindSets = true) != null } @@ -100,15 +101,16 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets = true, includeExternalSets = false, includeExternalSourceSets = false, + includeExternalNonIndexableSets = false, includeCustomKindSets = false) != null } override fun isIndexable(file: VirtualFile): Boolean { - return findFileSet(file, true, true, includeContentNonIndexableSets = false, true, true, true) != null + return findFileSet(file, true, true, includeContentNonIndexableSets = false, true, true, includeExternalNonIndexableSets = false, true) != null } override fun getContentFileSetRoot(file: VirtualFile, honorExclusion: Boolean): VirtualFile? { - return findFileSet(file, honorExclusion, true, true, false, false, false)?.root + return findFileSet(file, honorExclusion, true, true, false, false, false, false)?.root } override fun isUrlInContent(url: String): ThreeState { @@ -163,6 +165,7 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets = true, includeExternalSets = false, includeExternalSourceSets = false, + includeExternalNonIndexableSets = false, includeCustomKindSets = false) }) if (file.isDirectory && fileInfo is NonWorkspace) { @@ -229,6 +232,7 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets = true, includeExternalSets = false, includeExternalSourceSets = false, + includeExternalNonIndexableSets = false, includeCustomKindSets = false) != null } return@processChildrenRecursively if (isChildInContent) { @@ -256,9 +260,10 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, ): WorkspaceFileSet? { - return when (val info = getFileInfo(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeCustomKindSets)) { + return when (val info = getFileInfo(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeExternalNonIndexableSets, includeCustomKindSets)) { is WorkspaceFileSetImpl -> info is MultipleWorkspaceFileSets -> info.find(null) else -> null @@ -272,6 +277,7 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, ): List { val info = getFileInfo( @@ -281,6 +287,7 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets = includeContentNonIndexableSets, includeExternalSets = includeExternalSets, includeExternalSourceSets = includeExternalSourceSets, + includeExternalNonIndexableSets = includeExternalNonIndexableSets, includeCustomKindSets = includeCustomKindSets ) return when (info) { @@ -321,11 +328,12 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, customDataClass: Class, ): WorkspaceFileSetWithCustomData? { val result = when (val info = getFileInfo(file, honorExclusion, includeContentSets, - includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeCustomKindSets)) { + includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeExternalNonIndexableSets, includeCustomKindSets)) { is WorkspaceFileSetWithCustomData<*> -> info.takeIf { customDataClass.isInstance(it.data) } is MultipleWorkspaceFileSets -> info.find(customDataClass) else -> null @@ -341,10 +349,11 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, customDataClass: Class, ): List> { - val info = getFileInfo(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeCustomKindSets) + val info = getFileInfo(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeExternalNonIndexableSets, includeCustomKindSets) val result = when (info) { is WorkspaceFileSetWithCustomData<*> -> listOfNotNull(info.takeIf { customDataClass.isInstance(it.data) }) is MultipleWorkspaceFileSets -> info.fileSets.filter { customDataClass.isInstance(it.data) } @@ -361,20 +370,21 @@ class WorkspaceFileIndexImpl : WorkspaceFileIndexEx, Disposable.Default { includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, + includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean, ): WorkspaceFileInternalInfo { val unwrappedFile = BackedVirtualFile.getOriginFileIfBacked((file as? VirtualFileWindow)?.delegate ?: file) - return getMainIndexData().getFileInfo(unwrappedFile, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeCustomKindSets) + return getMainIndexData().getFileInfo(unwrappedFile, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeExternalNonIndexableSets, includeCustomKindSets) } - override fun findContainingEntities(file: VirtualFile, entityClass: Class, honorExclusion: Boolean, includeContentSets: Boolean, includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, includeCustomKindSets: Boolean): Collection { - val allEntities = findContainingEntities(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeCustomKindSets) + override fun findContainingEntities(file: VirtualFile, entityClass: Class, honorExclusion: Boolean, includeContentSets: Boolean, includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean): Collection { + val allEntities = findContainingEntities(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeExternalNonIndexableSets, includeCustomKindSets) @Suppress("UNCHECKED_CAST") return allEntities.filter { entity -> entity.getEntityInterface() == entityClass } as Collection } - override fun findContainingEntities(file: VirtualFile, honorExclusion: Boolean, includeContentSets: Boolean, includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, includeCustomKindSets: Boolean): Collection { - return when (val fileInfo = getFileInfo(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeCustomKindSets)) { + override fun findContainingEntities(file: VirtualFile, honorExclusion: Boolean, includeContentSets: Boolean, includeContentNonIndexableSets: Boolean, includeExternalSets: Boolean, includeExternalSourceSets: Boolean, includeExternalNonIndexableSets: Boolean, includeCustomKindSets: Boolean): Collection { + return when (val fileInfo = getFileInfo(file, honorExclusion, includeContentSets, includeContentNonIndexableSets, includeExternalSets, includeExternalSourceSets, includeExternalNonIndexableSets, includeCustomKindSets)) { is WorkspaceFileSetImpl -> listOfNotNull(resolveEntity(fileInfo)) is MultipleWorkspaceFileSets -> fileInfo.fileSets.mapNotNull { fileSet -> (fileSet as? StoredFileSet?)?.let { resolveEntity(it) } diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/infiniteProcessingReporting.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/infiniteProcessingReporting.kt index 3709a5916e47..10c3f1e7f077 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/infiniteProcessingReporting.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/infiniteProcessingReporting.kt @@ -10,7 +10,7 @@ import com.intellij.openapi.vfs.VirtualFile internal fun reportInfiniteRecursion(file: VirtualFile, fileIndex: WorkspaceFileIndexImpl) { val parentsData = runReadAction { generateSequence(file, VirtualFile::getParent).joinToString("\n") { file -> - val fileInfo = fileIndex.getFileInfo(file, true, true, true, false, false, false) + val fileInfo = fileIndex.getFileInfo(file, true, true, true, false, false, false, false) val symlinkData = if (file.`is`(VFileProperty.SYMLINK)) { ", link to ${file.canonicalFile}, recursive=${file.isRecursiveOrCircularSymlink}" } diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/workspaceFileSets.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/workspaceFileSets.kt index bd678169302c..68eb97a3ab1f 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/workspaceFileSets.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/core/fileIndex/impl/workspaceFileSets.kt @@ -298,7 +298,8 @@ internal object WorkspaceFileKindMask { const val EXTERNAL = EXTERNAL_SOURCE or EXTERNAL_BINARY const val CUSTOM = 8 const val CONTENT_NON_INDEXABLE = 16 - const val ALL = CONTENT or EXTERNAL or CUSTOM or CONTENT_NON_INDEXABLE + const val EXTERNAL_NON_INDEXABLE = 32 + const val ALL = CONTENT or EXTERNAL or CUSTOM or CONTENT_NON_INDEXABLE or EXTERNAL_NON_INDEXABLE } internal sealed interface ExcludedFileSet : StoredFileSet { diff --git a/plugins/kotlin/base/fir/project-structure/src/org/jetbrains/kotlin/idea/base/fir/projectStructure/provider/CandidateCollector.kt b/plugins/kotlin/base/fir/project-structure/src/org/jetbrains/kotlin/idea/base/fir/projectStructure/provider/CandidateCollector.kt index 42edc62621bf..d80f046a3c2e 100644 --- a/plugins/kotlin/base/fir/project-structure/src/org/jetbrains/kotlin/idea/base/fir/projectStructure/provider/CandidateCollector.kt +++ b/plugins/kotlin/base/fir/project-structure/src/org/jetbrains/kotlin/idea/base/fir/projectStructure/provider/CandidateCollector.kt @@ -70,6 +70,7 @@ internal object CandidateCollector { includeContentNonIndexableSets = true, includeExternalSets = true, includeExternalSourceSets = true, + includeExternalNonIndexableSets = true, includeCustomKindSets = true ).fileSets