[FIR] Add unresolved type counter to html dump

This commit is contained in:
Dmitriy Novozhilov
2019-12-05 17:57:32 +03:00
parent bef344b33e
commit 6f222edb88
3 changed files with 39 additions and 4 deletions
@@ -90,6 +90,11 @@ body.dark {
padding-left: 15px; padding-left: 15px;
} }
.dark .unresolved-counter {
color: #d42eff;
padding-left: 15px;
}
.dark .diagnostic-hover { .dark .diagnostic-hover {
background-color: #3a3a3a; background-color: #3a3a3a;
color: #dfdfdf; color: #dfdfdf;
@@ -80,6 +80,11 @@
padding-left: 15px; padding-left: 15px;
} }
.white .unresolved-counter {
color: #d42eff;
padding-left: 15px;
}
.white .diagnostic-hover { .white .diagnostic-hover {
background-color: #eaeaea; background-color: #eaeaea;
color: #000; color: #000;
@@ -80,6 +80,7 @@ private class PackageInfo(val fqName: FqName, val moduleInfo: ModuleInfo) {
} }
val errors = mutableMapOf<String, Int>().withDefault { 0 } val errors = mutableMapOf<String, Int>().withDefault { 0 }
val implicits = mutableMapOf<String, Int>().withDefault { 0 } val implicits = mutableMapOf<String, Int>().withDefault { 0 }
val unresolved = mutableMapOf<String, Int>().withDefault { 0 }
} }
private class ModuleInfo(val name: String, outputRoot: File) { private class ModuleInfo(val name: String, outputRoot: File) {
@@ -93,6 +94,9 @@ private class ModuleInfo(val name: String, outputRoot: File) {
val implicits: Map<FqName, Int> by lazy { val implicits: Map<FqName, Int> by lazy {
packages.mapValues { (_, packageInfo) -> packageInfo.implicits.values.sum() }.withDefault { 0 } packages.mapValues { (_, packageInfo) -> packageInfo.implicits.values.sum() }.withDefault { 0 }
} }
val unresolved: Map<FqName, Int> by lazy {
packages.mapValues { (_, packageInfo) -> packageInfo.unresolved.values.sum() }.withDefault { 0 }
}
} }
private class SupplementaryGenerator(val outputRoot: File) { private class SupplementaryGenerator(val outputRoot: File) {
@@ -122,7 +126,11 @@ private class SupplementaryGenerator(val outputRoot: File) {
) { ) {
+packageInfo.fqName.asString() +packageInfo.fqName.asString()
} }
addErrors(moduleInfo.errors.getValue(packageInfo.fqName), moduleInfo.implicits.getValue(packageInfo.fqName)) addErrors(
moduleInfo.errors.getValue(packageInfo.fqName),
moduleInfo.implicits.getValue(packageInfo.fqName),
moduleInfo.unresolved.getValue(packageInfo.fqName)
)
} }
} }
} }
@@ -130,13 +138,16 @@ private class SupplementaryGenerator(val outputRoot: File) {
} }
} }
fun LI.addErrors(errors: Int, implicits: Int) { fun LI.addErrors(errors: Int, implicits: Int, unresolved: Int) {
if (errors > 0) { if (errors > 0) {
span(classes = "error-counter") { +(errors.toString()) } span(classes = "error-counter") { +(errors.toString()) }
} }
if (implicits > 0) { if (implicits > 0) {
span(classes = "implicit-counter") { +(implicits.toString()) } span(classes = "implicit-counter") { +(implicits.toString()) }
} }
if (unresolved > 0) {
span(classes = "unresolved-counter") { +(unresolved.toString()) }
}
} }
fun linkToIndex(moduleInfo: ModuleInfo, from: File): String { fun linkToIndex(moduleInfo: ModuleInfo, from: File): String {
@@ -174,7 +185,11 @@ private class SupplementaryGenerator(val outputRoot: File) {
for (file in packageInfo.contents) { for (file in packageInfo.contents) {
li { li {
a(href = "./$file.fir.html", classes = "container-ref") { +file } a(href = "./$file.fir.html", classes = "container-ref") { +file }
addErrors(packageInfo.errors.getValue(file), packageInfo.implicits.getValue(file)) addErrors(
packageInfo.errors.getValue(file),
packageInfo.implicits.getValue(file),
packageInfo.unresolved.getValue(file)
)
} }
} }
} }
@@ -197,7 +212,11 @@ private class SupplementaryGenerator(val outputRoot: File) {
for (module in modules) { for (module in modules) {
li { li {
a(href = linkToIndex(module, outputRoot), classes = "container-ref") { +module.name } a(href = linkToIndex(module, outputRoot), classes = "container-ref") { +module.name }
addErrors(module.errors.values.sum(), module.implicits.values.sum()) addErrors(
module.errors.values.sum(),
module.implicits.values.sum(),
module.unresolved.values.sum()
)
} }
} }
} }
@@ -304,6 +323,7 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) {
packageForFile(file).apply { packageForFile(file).apply {
errors[file.name] = dumper.errors errors[file.name] = dumper.errors
implicits[file.name] = dumper.implicits implicits[file.name] = dumper.implicits
unresolved[file.name] = dumper.unresolved
} }
} }
@@ -406,9 +426,13 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
var implicits: Int = 0 var implicits: Int = 0
private set private set
var unresolved: Int = 0
private set
fun generate(element: FirFile, builder: StringBuilder) { fun generate(element: FirFile, builder: StringBuilder) {
errors = 0 errors = 0
implicits = 0 implicits = 0
unresolved = 0
builder.appendHTML().html { builder.appendHTML().html {
generate(element) generate(element)
} }
@@ -810,6 +834,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
keyword("<implicit>") keyword("<implicit>")
} }
is FirUserTypeRef -> unresolved { is FirUserTypeRef -> unresolved {
unresolved++
generateList(typeRef.qualifier, separator = ".") { generateList(typeRef.qualifier, separator = ".") {
simpleName(it.name) simpleName(it.name)
generateTypeProjections(it.typeArguments) generateTypeProjections(it.typeArguments)