[kotlin] remove analyzeWithReadAction
It's the responsibility of the caller to decide if read action is needed
This commit is contained in:
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.
|
* i.e, the module from which perspective the project will be analyzed.
|
||||||
*
|
*
|
||||||
* @see KtAnalysisSession
|
* @see KtAnalysisSession
|
||||||
* @see analyzeWithReadAction
|
|
||||||
*/
|
*/
|
||||||
public inline fun <R> analyze(
|
public inline fun <R> analyze(
|
||||||
useSiteKtElement: KtElement,
|
useSiteKtElement: KtElement,
|
||||||
@@ -57,31 +56,12 @@ public inline fun <R> analyzeInDependedAnalysisSession(
|
|||||||
KtAnalysisSessionProvider.getInstance(originalFile.project)
|
KtAnalysisSessionProvider.getInstance(originalFile.project)
|
||||||
.analyseInDependedAnalysisSession(originalFile, elementToReanalyze, action)
|
.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]
|
* Show a modal window with a progress bar and specified [windowTitle]
|
||||||
* and execute given [action] task with [KtAnalysisSession] context
|
* and execute given [action] task with [KtAnalysisSession] context
|
||||||
* If [action] throws some exception, then [analyzeInModalWindow] will rethrow it
|
* If [action] throws some exception, then [analyzeInModalWindow] will rethrow it
|
||||||
* Should be executed from EDT only
|
* 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(
|
public inline fun <R> analyzeInModalWindow(
|
||||||
contextElement: KtElement,
|
contextElement: KtElement,
|
||||||
@@ -91,7 +71,9 @@ public inline fun <R> analyzeInModalWindow(
|
|||||||
ApplicationManager.getApplication().assertIsDispatchThread()
|
ApplicationManager.getApplication().assertIsDispatchThread()
|
||||||
val task = object : Task.WithResult<R, Exception>(contextElement.project, windowTitle, /*canBeCancelled*/ true) {
|
val task = object : Task.WithResult<R, Exception>(contextElement.project, windowTitle, /*canBeCancelled*/ true) {
|
||||||
override fun compute(indicator: ProgressIndicator): R =
|
override fun compute(indicator: ProgressIndicator): R =
|
||||||
analyzeWithReadAction(contextElement) { action() }
|
ApplicationManager.getApplication().runReadAction(Computable {
|
||||||
|
analyze(contextElement, action)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
task.queue()
|
task.queue()
|
||||||
return task.result
|
return task.result
|
||||||
|
|||||||
Reference in New Issue
Block a user