[Analysis API] extract the data from the ShortenCommandImpl to the base class

^KT-58992
This commit is contained in:
Ilya Kirillov
2023-05-30 18:16:42 +02:00
committed by Space Team
parent fffc921d42
commit 95cf892eec
4 changed files with 28 additions and 26 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.analysis.api.descriptors.components
import com.intellij.openapi.util.TextRange
import com.intellij.psi.SmartPointerManager
import com.intellij.psi.SmartPsiElementPointer
import org.jetbrains.kotlin.analysis.api.components.KtReferenceShortener
import org.jetbrains.kotlin.analysis.api.components.ShortenCommand
@@ -15,13 +16,14 @@ import org.jetbrains.kotlin.analysis.api.descriptors.components.base.Fe10KtAnaly
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.analysis.api.symbols.KtClassLikeSymbol
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtUserType
internal class KtFe10ReferenceShortener(
override val analysisSession: KtFe10AnalysisSession
override val analysisSession: KtFe10AnalysisSession,
) : KtReferenceShortener(), Fe10KtAnalysisSessionComponent {
override val token: KtLifetimeToken
get() = analysisSession.token
@@ -30,17 +32,20 @@ internal class KtFe10ReferenceShortener(
file: KtFile,
selection: TextRange,
classShortenOption: (KtClassLikeSymbol) -> ShortenOption,
callableShortenOption: (KtCallableSymbol) -> ShortenOption
callableShortenOption: (KtCallableSymbol) -> ShortenOption,
): ShortenCommand {
// Compiler implementation does nothing.
// Descriptor-based shortening is implemented on the IDE plugin side.
val ktFilePointer = SmartPointerManager.createPointer(file)
return object : ShortenCommand {
override val isEmpty: Boolean
get() = true
override val targetFile: SmartPsiElementPointer<KtFile> get() = ktFilePointer
override val importsToAdd: List<FqName> get() = emptyList()
override val starImportsToAdd: List<FqName> get() = emptyList()
override val typesToShorten: List<SmartPsiElementPointer<KtUserType>> get() = emptyList()
override val qualifiersToShorten: List<SmartPsiElementPointer<KtDotQualifiedExpression>> get() = emptyList()
override fun getTypesToShorten(): List<SmartPsiElementPointer<KtUserType>> = emptyList()
override fun getQualifiersToShorten(): List<SmartPsiElementPointer<KtDotQualifiedExpression>> = emptyList()
override val isEmpty: Boolean get() = true
override fun invokeShortening(): List<KtElement> = emptyList()
}