in plugin-bazel/src/main/kotlin/org/jetbrains/bazel/workspace/CompiledSourceCodeInsideJarExcludeWorkspaceFileIndexContributor.kt [53:91]
override fun registerFileSets(
entity: LibraryCompiledSourceCodeInsideJarExcludeEntity,
registrar: WorkspaceFileSetRegistrar,
storage: EntityStorage,
) {
val library = storage.resolve(entity.libraryId) ?: return
val compiledSourceCodeInsideJarExcludeEntity = storage.resolve(entity.compiledSourceCodeInsideJarExcludeId) ?: return
val relativePathsToExclude: Set<String> = compiledSourceCodeInsideJarExcludeEntity.relativePathsInsideJarToExclude
val librariesFromInternalTargetsUrls: Set<String> = compiledSourceCodeInsideJarExcludeEntity.librariesFromInternalTargetsUrls
library.roots.map { libraryRoot ->
val contentRootUrl = libraryRoot.url
registrar.registerExclusionCondition(
root = contentRootUrl,
condition = { virtualFile ->
if (virtualFile.isDirectory) return@registerExclusionCondition false
val rootFile = VfsUtilCore.getRootFile(virtualFile)
val relativePath = virtualFile.getRelativePathInsideJar(rootFile)
val relativePathWithoutNestedClass = removeNestedClass(relativePath)
if (rootFile.url in librariesFromInternalTargetsUrls) {
return@registerExclusionCondition virtualFile.hasNonJvmExtension() || relativePathWithoutNestedClass in relativePathsToExclude
}
false
},
entity = entity,
)
if (libraryRoot.type == LibraryRootTypeId.SOURCES) {
registrar.registerExclusionCondition(
root = contentRootUrl,
condition = { virtualFile ->
virtualFile.hasNonJvmExtension()
},
entity = entity,
)
}
}
}