All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.analysis.project.structure.KotlinModuleDependentsProvider.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
Show newest version
/*
 * 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].
 *
 * [getDirectDependents] and [getTransitiveDependents] may return an empty set for [KtBuiltinsModule]s and [KtSdkModule]s even though most
 * modules depend on builtins/SDKs, because it is often not feasible to compute that set. Instead, users of [KotlinModuleDependentsProvider]
 * should keep this limitation in mind and handle it separately. For example, a global modification event should be published for builtins
 * and SDK changes.
 *
 * An empty set is also returned for [KtCodeFragmentModule]s, as no other module can depend on a code fragment.
 * Additionally, [KtCodeFragmentModule] are not returned from [getDirectDependents] for their context modules.
 *
 * 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

    /**
     * Returns all refinement/depends-on dependents of [module], excluding [module] itself. The result is transitive because refinement
     * dependencies are implicitly transitive.
     */
    public abstract fun getRefinementDependents(module: KtModule): Set

    public companion object {
        public fun getInstance(project: Project): KotlinModuleDependentsProvider =
            project.getService(KotlinModuleDependentsProvider::class.java)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy