[Analysis API] remove unneeded analyzeWithSymbolAsContext
This commit is contained in:
-13
@@ -24,19 +24,6 @@ class KtFe10AnalysisSessionProvider(project: Project) : KtAnalysisSessionProvide
|
|||||||
return KtFe10AnalysisSession(useSiteKtElement, factory.create(project))
|
return KtFe10AnalysisSession(useSiteKtElement, factory.create(project))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAnalysisSessionBySymbol(contextSymbol: KtSymbol): KtAnalysisSession {
|
|
||||||
if (contextSymbol is KtFe10Symbol) {
|
|
||||||
return KtFe10AnalysisSession(contextSymbol.analysisContext, contextSymbol.analysisContext.contextElement.getKtModule())
|
|
||||||
} else {
|
|
||||||
val contextElement = contextSymbol.psi
|
|
||||||
if (contextElement is KtElement) {
|
|
||||||
return KtFe10AnalysisSession(contextElement, contextSymbol.token)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw UnsupportedOperationException("getAnalysisSessionBySymbol() should not be used on KtFe10AnalysisSession")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAnalysisSessionByUseSiteKtModule(useSiteKtModule: KtModule, factory: KtLifetimeTokenFactory): KtAnalysisSession {
|
override fun getAnalysisSessionByUseSiteKtModule(useSiteKtModule: KtModule, factory: KtLifetimeTokenFactory): KtAnalysisSession {
|
||||||
throw UnsupportedOperationException("getAnalysisSessionByModule() should not be used on KtFe10AnalysisSession")
|
throw UnsupportedOperationException("getAnalysisSessionByModule() should not be used on KtFe10AnalysisSession")
|
||||||
}
|
}
|
||||||
|
|||||||
-7
@@ -53,13 +53,6 @@ abstract class CachingKtAnalysisSessionProvider<State : Any>(project: Project) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun getAnalysisSessionBySymbol(contextSymbol: KtSymbol): KtAnalysisSession {
|
|
||||||
val firResolveSession = getFirResolveSession(contextSymbol)
|
|
||||||
val token = contextSymbol.token
|
|
||||||
return getCachedAnalysisSession(firResolveSession, token)
|
|
||||||
?: createAnalysisSession(firResolveSession, contextSymbol.token)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCachedAnalysisSession(firResolveSession: State, token: KtLifetimeToken): KtAnalysisSession? {
|
private fun getCachedAnalysisSession(firResolveSession: State, token: KtLifetimeToken): KtAnalysisSession? {
|
||||||
return cache.getCachedAnalysisSession(firResolveSession to token::class)
|
return cache.getCachedAnalysisSession(firResolveSession to token::class)
|
||||||
}
|
}
|
||||||
|
|||||||
-10
@@ -31,18 +31,8 @@ public abstract class KtAnalysisSessionProvider(public val project: Project) : D
|
|||||||
|
|
||||||
public abstract fun getAnalysisSession(useSiteKtElement: KtElement, factory: KtLifetimeTokenFactory): KtAnalysisSession
|
public abstract fun getAnalysisSession(useSiteKtElement: KtElement, factory: KtLifetimeTokenFactory): KtAnalysisSession
|
||||||
|
|
||||||
public abstract fun getAnalysisSessionBySymbol(contextSymbol: KtSymbol): KtAnalysisSession
|
|
||||||
|
|
||||||
public abstract fun getAnalysisSessionByUseSiteKtModule(useSiteKtModule: KtModule, factory: KtLifetimeTokenFactory): KtAnalysisSession
|
public abstract fun getAnalysisSessionByUseSiteKtModule(useSiteKtModule: KtModule, factory: KtLifetimeTokenFactory): KtAnalysisSession
|
||||||
|
|
||||||
public inline fun <R> analyzeWithSymbolAsContext(
|
|
||||||
contextSymbol: KtSymbol,
|
|
||||||
action: KtAnalysisSession.() -> R
|
|
||||||
): R {
|
|
||||||
val analysisSession = getAnalysisSessionBySymbol(contextSymbol)
|
|
||||||
return action(analysisSession)
|
|
||||||
}
|
|
||||||
|
|
||||||
public inline fun <R> analyseInDependedAnalysisSession(
|
public inline fun <R> analyseInDependedAnalysisSession(
|
||||||
originalFile: KtFile,
|
originalFile: KtFile,
|
||||||
elementToReanalyze: KtElement,
|
elementToReanalyze: KtElement,
|
||||||
|
|||||||
Reference in New Issue
Block a user