From 32456a161160cba591b5940683048f60e07d90cf Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Wed, 26 Jul 2023 14:22:30 +0200 Subject: [PATCH] [kotlin] remove `analyzeWithReadAction` It's the responsibility of the caller to decide if read action is needed --- .../jetbrains/kotlin/analysis/api/analyze.kt | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/analyze.kt b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/analyze.kt index d053233d41e..4c02bb7a926 100644 --- a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/analyze.kt +++ b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/analyze.kt @@ -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 analyze( useSiteKtElement: KtElement, @@ -57,31 +56,12 @@ public inline fun 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 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 analyzeInModalWindow( contextElement: KtElement, @@ -91,7 +71,9 @@ public inline fun analyzeInModalWindow( ApplicationManager.getApplication().assertIsDispatchThread() val task = object : Task.WithResult(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