mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[kotlin] Move Declarations performance test: copied writeIntentReadAction {} call from Move Files test.
GitOrigin-RevId: c75c46bca32676195436761495b056132447112c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c82d4a5a10
commit
d16e1d52f5
@@ -1,20 +1,19 @@
|
||||
package com.jetbrains.performancePlugin.commands
|
||||
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.writeIntentReadAction
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.playback.PlaybackContext
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.platform.diagnostic.telemetry.Scope
|
||||
import com.intellij.platform.diagnostic.telemetry.TelemetryManager
|
||||
import com.intellij.platform.diagnostic.telemetry.helpers.use
|
||||
import com.intellij.psi.PsiFileFactory
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException.withIgnoredConflicts
|
||||
import com.intellij.refactoring.move.MoveHandler
|
||||
import com.jetbrains.performancePlugin.commands.dto.MoveDeclarationsData
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtFunction
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
@@ -38,14 +37,16 @@ class MoveKotlinDeclarationsCommand(text: String, line: Int) : PerformanceComman
|
||||
withContext(Dispatchers.EDT) {
|
||||
// Currently Refactor / Move with K2 supports only top-level declarations.
|
||||
// We just select all top-level declarations whose names match any provided name.
|
||||
val file = findFile(project, moveDeclarationData.fromFile)
|
||||
val declarations = psiManager.findFile(file)!!.children.filter {
|
||||
(it is KtClass || it is KtFunction || it is KtProperty) && moveDeclarationData.declarations.contains(it.name)
|
||||
}.toTypedArray()
|
||||
val toFile = psiManager.findFile(findFile(project, moveDeclarationData.toFile))
|
||||
TelemetryManager.getTracer(Scope("MoveDeclarations")).spanBuilder("$NAME$tag").use {
|
||||
withIgnoredConflicts<Throwable> {
|
||||
MoveHandler.doMove(project, declarations, toFile, null, null)
|
||||
writeIntentReadAction {
|
||||
val file = findFile(project, moveDeclarationData.fromFile)
|
||||
val declarations = psiManager.findFile(file)!!.children.filter {
|
||||
(it is KtClass || it is KtFunction || it is KtProperty) && moveDeclarationData.declarations.contains(it.name)
|
||||
}.toTypedArray()
|
||||
val toFile = psiManager.findFile(findFile(project, moveDeclarationData.toFile))
|
||||
TelemetryManager.getTracer(Scope("MoveDeclarations")).spanBuilder("$NAME$tag").use {
|
||||
withIgnoredConflicts<Throwable> {
|
||||
MoveHandler.doMove(project, declarations, toFile, null, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user