[kotlin] Clean up ShortenSelectionAction

#KTIJ-28116

GitOrigin-RevId: e3b5ad32473fe3134ba15b2c32ef44582fdabfca
This commit is contained in:
Bart van Helvert
2023-12-28 23:17:22 +00:00
committed by intellij-monorepo-bot
parent 53f4384783
commit 2f289ccda6
@@ -8,7 +8,6 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiDocumentManager
import org.jetbrains.kotlin.analysis.api.analyze
import org.jetbrains.kotlin.idea.base.analysis.api.utils.shortenReferencesInRange
import org.jetbrains.kotlin.psi.KtFile
@@ -23,10 +22,8 @@ internal class ShortenSelectionAction : AnAction() {
val editor = CommonDataKeys.EDITOR.getData(dataContext) ?: return
val file = PsiDocumentManager.getInstance(project).getPsiFile(editor.document) as? KtFile ?: return
val selection = TextRange(editor.selectionModel.selectionStart, editor.selectionModel.selectionEnd)
WriteCommandAction.runWriteCommandAction(project, templateText, null, {
analyze(file) {
shortenReferencesInRange(file, selection)
}
WriteCommandAction.runWriteCommandAction(project, templateText, /* groupID = */ null, {
shortenReferencesInRange(file, selection)
}, file)
}
}