[kotlin] remove analyzeWithReadAction

It's the responsibility of the caller to decide if read action is needed
This commit is contained in:
Ilya Kirillov
2023-07-26 14:22:30 +02:00
committed by Space Team
parent 62e856956c
commit 32456a1611
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.psi.KtFile
* i.e, the module from which perspective the project will be analyzed.
*
* @see KtAnalysisSession
* @see analyzeWithReadAction
*/
public inline fun <R> analyze(
useSiteKtElement: KtElement,
@@ -57,31 +56,12 @@ public inline fun <R> analyzeInDependedAnalysisSession(
KtAnalysisSessionProvider.getInstance(originalFile.project)
.analyseInDependedAnalysisSession(originalFile, elementToReanalyze, action)
/**
* Execute given [action] in [KtAnalysisSession] context like [analyze] does but execute it in read action
* Uses [contextElement] to get a module from which you would like to see the other modules
* Usually [contextElement] is some element form the module you currently analysing now
*
* Should be called from read action
* To analyse something from EDT thread, consider using [analyzeInModalWindow]
* If you are already in read action, consider using [analyze]
*
* @see KtAnalysisSession
* @see analyze
*/
public inline fun <R> analyzeWithReadAction(
contextElement: KtElement,
crossinline action: KtAnalysisSession.() -> R
): R = ApplicationManager.getApplication().runReadAction(Computable {
analyze(contextElement, action)
})
/**
* Show a modal window with a progress bar and specified [windowTitle]
* and execute given [action] task with [KtAnalysisSession] context
* If [action] throws some exception, then [analyzeInModalWindow] will rethrow it
* Should be executed from EDT only
* If you want to analyse something from non-EDT thread, consider using [analyze]/[analyzeWithReadAction]
* If you want to analyse something from non-EDT thread, consider using [analyze]
*/
public inline fun <R> analyzeInModalWindow(
contextElement: KtElement,
@@ -91,7 +71,9 @@ public inline fun <R> analyzeInModalWindow(
ApplicationManager.getApplication().assertIsDispatchThread()
val task = object : Task.WithResult<R, Exception>(contextElement.project, windowTitle, /*canBeCancelled*/ true) {
override fun compute(indicator: ProgressIndicator): R =
analyzeWithReadAction(contextElement) { action() }
ApplicationManager.getApplication().runReadAction(Computable {
analyze(contextElement, action)
})
}
task.queue()
return task.result