Introduce FirResolvedTypeRef.delegatedTypeRef to see children types in IDE

This is needed to have access to resolved children types (e.g. type arguments) from IDE
This commit is contained in:
Mikhail Glukhikh
2019-07-31 15:46:06 +03:00
parent 38c1a50c1d
commit 8808c775a4
14 changed files with 41 additions and 5 deletions
@@ -20,6 +20,7 @@ abstract class FirErrorTypeRef : FirResolvedTypeRef(), FirDiagnosticHolder {
abstract override val source: FirSourceElement?
abstract override val annotations: List<FirAnnotationCall>
abstract override val type: ConeKotlinType
abstract override val delegatedTypeRef: FirTypeRef?
abstract override val diagnostic: FirDiagnostic
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorTypeRef(this, data)
@@ -19,6 +19,7 @@ abstract class FirResolvedFunctionTypeRef : FirResolvedTypeRef(), FirFunctionTyp
abstract override val source: FirSourceElement?
abstract override val annotations: List<FirAnnotationCall>
abstract override val type: ConeKotlinType
abstract override val delegatedTypeRef: FirTypeRef?
abstract override val isMarkedNullable: Boolean
abstract override val receiverTypeRef: FirTypeRef?
abstract override val valueParameters: List<FirValueParameter>
@@ -19,6 +19,7 @@ abstract class FirResolvedTypeRef : FirPureAbstractElement(), FirTypeRef {
abstract override val source: FirSourceElement?
abstract override val annotations: List<FirAnnotationCall>
abstract val type: ConeKotlinType
abstract val delegatedTypeRef: FirTypeRef?
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitResolvedTypeRef(this, data)
}
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.*
/*
@@ -25,6 +26,7 @@ class FirErrorTypeRefImpl(
) : FirErrorTypeRef(), FirAbstractAnnotatedElement {
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val type: ConeKotlinType = ConeClassErrorType(diagnostic.reason)
override val delegatedTypeRef: FirTypeRef? get() = null
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -27,6 +27,7 @@ class FirResolvedFunctionTypeRefImpl(
override var returnTypeRef: FirTypeRef
) : FirResolvedFunctionTypeRef(), FirAbstractAnnotatedElement {
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val delegatedTypeRef: FirTypeRef? get() = null
override val valueParameters: MutableList<FirValueParameter> = mutableListOf()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.*
/*
@@ -22,13 +23,16 @@ class FirResolvedTypeRefImpl(
override val type: ConeKotlinType
) : FirResolvedTypeRef(), FirAbstractAnnotatedElement {
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override var delegatedTypeRef: FirTypeRef? = null
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
delegatedTypeRef?.accept(visitor, data)
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirResolvedTypeRefImpl {
annotations.transformInplace(transformer, data)
delegatedTypeRef = delegatedTypeRef?.transformSingle(transformer, data)
return this
}
}