FIR general refactoring: get rid of ConeSymbols
This commit is contained in:
@@ -25,6 +25,8 @@ import org.jetbrains.kotlin.fir.resolve.directExpansionType
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.withNullability
|
||||
import org.jetbrains.kotlin.fir.symbols.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
@@ -41,8 +43,8 @@ import java.io.Writer
|
||||
internal interface FirLinkResolver {
|
||||
fun nearPackage(fqName: FqName): String?
|
||||
|
||||
fun symbolSignature(symbol: ConeSymbol): String
|
||||
fun nearSymbolLocation(symbol: ConeSymbol): String?
|
||||
fun symbolSignature(symbol: FirBasedSymbol<*>): String
|
||||
fun nearSymbolLocation(symbol: FirBasedSymbol<*>): String?
|
||||
|
||||
fun classLocation(classId: ClassId): String?
|
||||
|
||||
@@ -283,7 +285,7 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) {
|
||||
supplementaryGenerator.supplementary(this, originDir)
|
||||
}
|
||||
|
||||
override fun symbolSignature(symbol: ConeSymbol): String {
|
||||
override fun symbolSignature(symbol: FirBasedSymbol<*>): String {
|
||||
val id = index.symbolIds[symbol] ?: error("Not found $symbol")
|
||||
return "id$id"
|
||||
}
|
||||
@@ -300,7 +302,7 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) {
|
||||
return location.relativeTo(originDir).path + "#$classId"
|
||||
}
|
||||
|
||||
override fun nearSymbolLocation(symbol: ConeSymbol): String? {
|
||||
override fun nearSymbolLocation(symbol: FirBasedSymbol<*>): String? {
|
||||
val location = index.symbols[symbol] ?: return null
|
||||
return location.relativeTo(originDir).path + "#${symbolSignature(symbol)}"
|
||||
}
|
||||
@@ -918,18 +920,18 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
}
|
||||
}
|
||||
|
||||
private fun ConeSymbol.describe(): String {
|
||||
private fun FirBasedSymbol<*>.describe(): String {
|
||||
return when (this) {
|
||||
is ConeClassLikeSymbol -> classId.asString()
|
||||
is ConeCallableSymbol -> callableId.toString()
|
||||
is FirClassLikeSymbol<*> -> classId.asString()
|
||||
is FirCallableSymbol<*> -> callableId.toString()
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun FlowContent.symbolRef(symbol: ConeSymbol?, body: FlowContent.() -> Unit) {
|
||||
private fun FlowContent.symbolRef(symbol: FirBasedSymbol<*>?, body: FlowContent.() -> Unit) {
|
||||
val (link, classes) = when (symbol) {
|
||||
null -> null to setOf()
|
||||
is ConeClassLikeSymbol -> linkResolver.classLocation(symbol.classId) to setOf("class-fqn")
|
||||
is FirClassLikeSymbol<*> -> linkResolver.classLocation(symbol.classId) to setOf("class-fqn")
|
||||
else -> linkResolver.nearSymbolLocation(symbol) to setOf("symbol")
|
||||
}
|
||||
declarationRef(link, classes) {
|
||||
@@ -964,7 +966,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
}
|
||||
is FirResolvedCallableReference -> {
|
||||
resolved {
|
||||
symbolRef(reference.coneSymbol) {
|
||||
symbolRef(reference.resolvedSymbol) {
|
||||
simpleName(reference.name)
|
||||
}
|
||||
}
|
||||
@@ -1255,7 +1257,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
}
|
||||
}
|
||||
|
||||
private fun FlowContent.symbolAnchor(symbol: ConeSymbol, body: FlowContent.() -> Unit) {
|
||||
private fun FlowContent.symbolAnchor(symbol: AbstractFirBasedSymbol<*>, body: FlowContent.() -> Unit) {
|
||||
span(classes = "declaration") {
|
||||
id = linkResolver.symbolSignature(symbol)
|
||||
body()
|
||||
|
||||
Reference in New Issue
Block a user