Analysis API FIR/FE1.0: fix backing field rendering & resolving
This commit is contained in:
+4
-1
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.analysis.api.descriptors.KtFe10AnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.Fe10AnalysisFacade.AnalysisMode
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.components.base.Fe10KtAnalysisSessionComponent
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.base.KtFe10Symbol
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.KtFe10DescSyntheticFieldSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.base.KtFe10DescSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.base.classId
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.symbols.descriptorBased.base.getSymbolDescriptor
|
||||
@@ -23,6 +24,7 @@ import org.jetbrains.kotlin.analysis.api.descriptors.symbols.psiBased.base.getRe
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.types.base.KtFe10Type
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.utils.PublicApproximatorConfiguration
|
||||
import org.jetbrains.kotlin.analysis.api.descriptors.utils.cached
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtNamedClassOrObjectSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtPossibleMemberSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.nameOrAnonymous
|
||||
@@ -119,13 +121,14 @@ internal class KtFe10TypeProvider(
|
||||
return TypeUtils.getAllSupertypes(type.type).map { it.toKtType(analysisContext) }
|
||||
}
|
||||
|
||||
override fun getDispatchReceiverType(symbol: KtPossibleMemberSymbol): KtType? {
|
||||
override fun getDispatchReceiverType(symbol: KtCallableSymbol): KtType? {
|
||||
assertIsValidAndAccessible()
|
||||
require(symbol is KtFe10Symbol)
|
||||
|
||||
val descriptor = when (symbol) {
|
||||
is KtFe10DescSymbol<*> -> symbol.descriptor as? CallableDescriptor
|
||||
is KtFe10PsiSymbol<*, *> -> symbol.descriptor as? CallableDescriptor
|
||||
is KtFe10DescSyntheticFieldSymbol -> symbol.descriptor
|
||||
else -> error("No callable descriptor on $symbol")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
|
||||
import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
|
||||
internal class KtFe10DescSyntheticFieldSymbol(
|
||||
private val descriptor: SyntheticFieldDescriptor,
|
||||
val descriptor: SyntheticFieldDescriptor,
|
||||
override val analysisContext: Fe10AnalysisContext
|
||||
) : KtBackingFieldSymbol(), KtFe10Symbol {
|
||||
override val owningProperty: KtKotlinPropertySymbol
|
||||
|
||||
+1
@@ -389,6 +389,7 @@ internal fun getSymbolDescriptor(symbol: KtSymbol): DeclarationDescriptor? {
|
||||
return when (symbol) {
|
||||
is KtFe10DescSymbol<*> -> symbol.descriptor
|
||||
is KtFe10PsiSymbol<*, *> -> symbol.descriptor
|
||||
is KtFe10DescSyntheticFieldSymbol -> symbol.descriptor
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.builtins.isFunctionType
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
@@ -279,6 +280,7 @@ internal class KtFe10Renderer(
|
||||
|
||||
private fun KtFe10RendererConsumer.renderCallable(descriptor: CallableDescriptor) {
|
||||
when (descriptor) {
|
||||
is SyntheticFieldDescriptor -> renderSyntheticFieldDescriptor()
|
||||
is PropertyGetterDescriptor -> renderPropertyAccessor(descriptor)
|
||||
is PropertySetterDescriptor -> renderPropertyAccessor(descriptor)
|
||||
is PropertyDescriptor -> renderProperty(descriptor)
|
||||
@@ -290,6 +292,10 @@ internal class KtFe10Renderer(
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtFe10RendererConsumer.renderSyntheticFieldDescriptor() {
|
||||
append("field")
|
||||
}
|
||||
|
||||
private fun KtFe10RendererConsumer.renderPropertyAccessor(descriptor: PropertyAccessorDescriptor) {
|
||||
if (options.renderDeclarationHeader) {
|
||||
renderAnnotations(descriptor)
|
||||
@@ -440,7 +446,12 @@ internal class KtFe10Renderer(
|
||||
return
|
||||
}
|
||||
val isSingleLineAnnotations = declaration is ValueParameterDescriptor || declaration is TypeParameterDescriptor
|
||||
renderFe10Annotations(declaration.annotations, isSingleLineAnnotations, predicate)
|
||||
renderFe10Annotations(
|
||||
declaration.annotations,
|
||||
isSingleLineAnnotations,
|
||||
renderAnnotationWithShortNames = options.typeRendererOptions.shortQualifiedNames,
|
||||
predicate
|
||||
)
|
||||
}
|
||||
|
||||
private fun KtFe10RendererConsumer.renderModifiers(descriptor: DeclarationDescriptor) {
|
||||
|
||||
Reference in New Issue
Block a user