[AA] Document analyzeInDependedAnalysisSession and related classes

This commit is contained in:
Marco Pennekamp
2023-08-08 23:28:23 +02:00
committed by Space Team
parent ed13d6b3a4
commit 2db8f31966
3 changed files with 23 additions and 2 deletions
@@ -73,6 +73,12 @@ public abstract class KtAnalysisSession(final override val token: KtLifetimeToke
override val analysisSession: KtAnalysisSession get() = this
/**
* Creates a new [KtAnalysisSession] which depends on this analysis session, but additionally provides its own symbols derived from
* analyzing [elementToReanalyze].
*
* @see analyzeInDependedAnalysisSession
*/
public abstract fun createContextDependentCopy(originalKtFile: KtFile, elementToReanalyze: KtElement): KtAnalysisSession
internal val smartCastProvider: KtSmartCastProvider get() = smartCastProviderImpl
@@ -43,11 +43,18 @@ public inline fun <R> analyze(
return sessionProvider.analyze(useSiteKtModule, action)
}
/**
* Executes the given [action] in the context of a [KtAnalysisSession] that depends on an original analysis session determined by
* [originalFile]. In addition to the symbols provided by the original analysis session, the dependent analysis session provides its own
* symbols derived from analyzing [elementToReanalyze]. This allows analyzing some new or copied (and modified) element in the larger
* context of the original analysis session.
*
* @see KtAnalysisSession.createContextDependentCopy
*/
public inline fun <R> analyzeInDependedAnalysisSession(
originalFile: KtFile,
elementToReanalyze: KtElement,
action: KtAnalysisSession.() -> R
): R =
KtAnalysisSessionProvider.getInstance(originalFile.project)
.analyseInDependedAnalysisSession(originalFile, elementToReanalyze, action)
.analyseInDependedAnalysisSession(originalFile, elementToReanalyze, action)