diff --git a/analysis/project-structure/src/org/jetbrains/kotlin/analysis/project/structure/KotlinModuleDependentsProvider.kt b/analysis/project-structure/src/org/jetbrains/kotlin/analysis/project/structure/KotlinModuleDependentsProvider.kt new file mode 100644 index 00000000000..828658ad42e --- /dev/null +++ b/analysis/project-structure/src/org/jetbrains/kotlin/analysis/project/structure/KotlinModuleDependentsProvider.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.analysis.project.structure + +import com.intellij.openapi.project.Project + +/** + * [KotlinModuleDependentsProvider] provides dependents for a [KtModule], which are modules that depend on the [KtModule]. + * + * Implementations of this provider should ensure that results are provided in reasonable time, for example by caching results, as its + * functions may be called frequently. + */ +public abstract class KotlinModuleDependentsProvider { + /** + * Returns all direct dependents of [module], excluding [module] if it depends on itself. + */ + public abstract fun getDirectDependents(module: KtModule): Set + + /** + * Returns all direct and indirect dependents of [module], excluding [module] if it depends on itself. + */ + public abstract fun getTransitiveDependents(module: KtModule): Set + + public companion object { + public fun getInstance(project: Project): KotlinModuleDependentsProvider = + project.getService(KotlinModuleDependentsProvider::class.java) + } +}