FIR IDE: render captured type

This commit is contained in:
Tianyu Geng
2021-10-07 10:56:09 -07:00
committed by Ilya Kirillov
parent 8b44a4685f
commit ba359fb296
6 changed files with 31 additions and 25 deletions
@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.analysis.api.fir.renderer package org.jetbrains.kotlin.analysis.api.fir.renderer
import org.jetbrains.kotlin.analysis.api.components.KtTypeRendererOptions
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.tryCollectDesignation
import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.containingClass import org.jetbrains.kotlin.fir.containingClass
import org.jetbrains.kotlin.fir.containingClassForLocal import org.jetbrains.kotlin.fir.containingClassForLocal
@@ -20,8 +22,6 @@ import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
import org.jetbrains.kotlin.fir.symbols.impl.LookupTagInternals import org.jetbrains.kotlin.fir.symbols.impl.LookupTagInternals
import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.tryCollectDesignation
import org.jetbrains.kotlin.analysis.api.components.KtTypeRendererOptions
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.renderer.render import org.jetbrains.kotlin.renderer.render
@@ -86,6 +86,11 @@ internal class ConeTypeIdeRenderer(
renderAnnotationList(annotations) renderAnnotationList(annotations)
append(renderFlexibleType(renderType(type.lowerBound), renderType(type.upperBound))) append(renderFlexibleType(renderType(type.lowerBound), renderType(type.upperBound)))
} }
is ConeCapturedType -> {
renderAnnotationList(annotations)
append(type.render())
renderNullability(type.type)
}
else -> appendError("Unexpected cone type ${type::class.qualifiedName}") else -> appendError("Unexpected cone type ${type::class.qualifiedName}")
} }
} }
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.analysis.api.fir.components package org.jetbrains.kotlin.analysis.api.fir.components
import org.jetbrains.kotlin.analysis.api.analyse import org.jetbrains.kotlin.analysis.api.analyse
import org.jetbrains.kotlin.analysis.api.components.KtTypeRendererOptions
import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction import org.jetbrains.kotlin.analysis.api.fir.executeOnPooledThreadInReadAction
import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleFileTest import org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleFileTest
import org.jetbrains.kotlin.analysis.api.types.KtType import org.jetbrains.kotlin.analysis.api.types.KtType
@@ -31,7 +32,7 @@ abstract class AbstractGetSuperTypesTest : AbstractHLApiSingleFileTest() {
fun List<KtType>.print(name: String) { fun List<KtType>.print(name: String) {
appendLine(name) appendLine(name)
for (type in this) { for (type in this) {
appendLine(type.render()) appendLine(type.render(KtTypeRendererOptions.DEFAULT))
} }
appendLine() appendLine()
} }
@@ -30,7 +30,7 @@ public data class KtTypeRendererOptions(
* When `true` will render as `UnresolvedQualifier` * When `true` will render as `UnresolvedQualifier`
* When `false` will render as "ERROR_TYPE <symbol not found for UnresolvedQualifier>" * When `false` will render as "ERROR_TYPE <symbol not found for UnresolvedQualifier>"
*/ */
public val renderUnresolvedTypeAsResolved: Boolean = true public val renderUnresolvedTypeAsResolved: Boolean = true,
) { ) {
public companion object { public companion object {
public val DEFAULT: KtTypeRendererOptions = KtTypeRendererOptions() public val DEFAULT: KtTypeRendererOptions = KtTypeRendererOptions()
@@ -1,17 +1,17 @@
[direct super types] [direct super types]
kotlin.collections.List<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.List<CapturedType(in kotlin/String)>
kotlin.collections.MutableCollection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableCollection<CapturedType(in kotlin/String)>
[approximated direct super types] [approximated direct super types]
kotlin.collections.List<kotlin.Any?> kotlin.collections.List<kotlin.Any?>
kotlin.collections.MutableCollection<in kotlin.String> kotlin.collections.MutableCollection<in kotlin.String>
[all super types] [all super types]
kotlin.collections.List<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.List<CapturedType(in kotlin/String)>
kotlin.collections.MutableCollection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableCollection<CapturedType(in kotlin/String)>
kotlin.collections.Collection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.Collection<CapturedType(in kotlin/String)>
kotlin.collections.MutableIterable<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableIterable<CapturedType(in kotlin/String)>
kotlin.collections.Iterable<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.Iterable<CapturedType(in kotlin/String)>
kotlin.Any kotlin.Any
[approximated all super types] [approximated all super types]
@@ -1,17 +1,17 @@
[direct super types] [direct super types]
kotlin.collections.List<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.List<CapturedType(out kotlin/String)>
kotlin.collections.MutableCollection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableCollection<CapturedType(out kotlin/String)>
[approximated direct super types] [approximated direct super types]
kotlin.collections.List<kotlin.String> kotlin.collections.List<kotlin.String>
kotlin.collections.MutableCollection<out kotlin.String> kotlin.collections.MutableCollection<out kotlin.String>
[all super types] [all super types]
kotlin.collections.List<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.List<CapturedType(out kotlin/String)>
kotlin.collections.MutableCollection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableCollection<CapturedType(out kotlin/String)>
kotlin.collections.Collection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.Collection<CapturedType(out kotlin/String)>
kotlin.collections.MutableIterable<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableIterable<CapturedType(out kotlin/String)>
kotlin.collections.Iterable<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.Iterable<CapturedType(out kotlin/String)>
kotlin.Any kotlin.Any
[approximated all super types] [approximated all super types]
@@ -1,17 +1,17 @@
[direct super types] [direct super types]
kotlin.collections.List<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.List<CapturedType(*)>
kotlin.collections.MutableCollection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableCollection<CapturedType(*)>
[approximated direct super types] [approximated direct super types]
kotlin.collections.List<kotlin.Any?> kotlin.collections.List<kotlin.Any?>
kotlin.collections.MutableCollection<out kotlin.Any?> kotlin.collections.MutableCollection<out kotlin.Any?>
[all super types] [all super types]
kotlin.collections.List<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.List<CapturedType(*)>
kotlin.collections.MutableCollection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableCollection<CapturedType(*)>
kotlin.collections.Collection<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.Collection<CapturedType(*)>
kotlin.collections.MutableIterable<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.MutableIterable<CapturedType(*)>
kotlin.collections.Iterable<ERROR_TYPE <Unexpected cone type org.jetbrains.kotlin.fir.types.ConeCapturedType>> kotlin.collections.Iterable<CapturedType(*)>
kotlin.Any kotlin.Any
[approximated all super types] [approximated all super types]