[AA] KT-58257 Introduce KotlinModuleDependentsProvider
- Event-based session invalidation requires knowledge about the dependents of a `KtModule`. This is because, when the session for a module is invalidated, all sessions for modules which depend on that module, directly or indirectly, must also be invalidated. - Note that the approach with modification trackers relied on module dependencies. Events have an opposite flow of information compared to modification trackers: Modification trackers request whether a change occurred, while events publish that a change occurred. Thus, the modules which need to be incorporated into the invalidation dynamic are also flipped: dependents instead of dependencies. - `KotlinModuleDependentsProvider` is designed to work generally. It can be used for purposes beyond session invalidation.
This commit is contained in:
committed by
Space Team
parent
7fd8e4d0fd
commit
fe3f7feae4
+31
@@ -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<KtModule>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all direct and indirect dependents of [module], excluding [module] if it depends on itself.
|
||||||
|
*/
|
||||||
|
public abstract fun getTransitiveDependents(module: KtModule): Set<KtModule>
|
||||||
|
|
||||||
|
public companion object {
|
||||||
|
public fun getInstance(project: Project): KotlinModuleDependentsProvider =
|
||||||
|
project.getService(KotlinModuleDependentsProvider::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user