diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt index ba9665c218a..10b99b09299 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.shortenRefs import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.AbstractImportsTest import org.jetbrains.kotlin.idea.frontend.api.analyze import org.jetbrains.kotlin.idea.util.application.executeWriteCommand @@ -19,12 +20,12 @@ abstract class AbstractFirShortenRefsTest : AbstractImportsTest() { val selectionModel = myFixture.editor.selectionModel if (!selectionModel.hasSelection()) error("No selection in input file") - val (startOffset, endOffset) = runReadAction { selectionModel.selectionStart to selectionModel.selectionEnd } + val selection = runReadAction { TextRange(selectionModel.selectionStart, selectionModel.selectionEnd) } val shortenings = executeOnPooledThread { runReadAction { analyze(file) { - collectPossibleReferenceShortenings(file, startOffset, endOffset) + collectPossibleReferenceShortenings(file, selection) } } } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index a7a001ef9b3..cf643ccf248 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.frontend.api +import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import org.jetbrains.kotlin.idea.frontend.api.calls.KtCall import org.jetbrains.kotlin.idea.frontend.api.components.* @@ -179,5 +180,6 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali fun KtReturnExpression.getReturnTargetSymbol(): KtCallableSymbol? = expressionHandlingComponent.getReturnExpressionTargetSymbol(this) - fun collectPossibleReferenceShortenings(file: KtFile, from: Int, to: Int) = referenceShortener.collectShortenings(file, from, to) + fun collectPossibleReferenceShortenings(file: KtFile, selection: TextRange): ShortenCommand = + referenceShortener.collectShortenings(file, selection) } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt index 7e5ac143ef2..311f50194c0 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt @@ -5,10 +5,11 @@ package org.jetbrains.kotlin.idea.frontend.api.components +import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.psi.KtFile abstract class KtReferenceShortener : KtAnalysisSessionComponent() { - abstract fun collectShortenings(file: KtFile, from: Int, to: Int): ShortenCommand + abstract fun collectShortenings(file: KtFile, selection: TextRange): ShortenCommand } interface ShortenCommand { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 9bf2b12ac56..1c198f076ab 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.util.TextRange import com.intellij.psi.SmartPsiElementPointer import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.descriptors.ClassKind @@ -59,7 +60,7 @@ internal class KtFirReferenceShortener( override val token: ValidityToken, override val firResolveState: FirModuleResolveState, ) : KtReferenceShortener(), KtFirAnalysisSessionComponent { - override fun collectShortenings(file: KtFile, from: Int, to: Int): ShortenCommand { + override fun collectShortenings(file: KtFile, selection: TextRange): ShortenCommand { resolveFileToBodyResolve(file) val firFile = file.getOrBuildFirOfType(firResolveState)