[FIR] Remove unused declarations
This commit is contained in:
committed by
Space Team
parent
6156609617
commit
43b76f3c24
-2
@@ -60,8 +60,6 @@ object FieldSets {
|
||||
|
||||
val typeRefField = field(typeRef, withReplace = true)
|
||||
|
||||
val valueParameters by lazy { fieldList(valueParameter) }
|
||||
|
||||
val typeParameters by lazy { fieldList("typeParameters", typeParameter) }
|
||||
|
||||
val typeParameterRefs by lazy { fieldList("typeParameters", typeParameterRef) }
|
||||
|
||||
@@ -71,7 +71,6 @@ val firBasedSymbolType = type("fir.symbols", "FirBasedSymbol")
|
||||
val functionSymbolType = type("fir.symbols.impl", "FirFunctionSymbol")
|
||||
val backingFieldSymbolType = type("fir.symbols.impl", "FirBackingFieldSymbol")
|
||||
val delegateFieldSymbolType = type("fir.symbols.impl", "FirDelegateFieldSymbol")
|
||||
val classSymbolType = type("fir.symbols.impl", "FirClassSymbol")
|
||||
val classLikeSymbolType = type("fir.symbols.impl", "FirClassLikeSymbol<*>")
|
||||
val regularClassSymbolType = type("fir.symbols.impl", "FirRegularClassSymbol")
|
||||
val typeParameterSymbolType = type("fir.symbols.impl", "FirTypeParameterSymbol")
|
||||
@@ -85,7 +84,6 @@ val emptyContractDescriptionType = generatedType("contracts.impl", "FirEmptyCont
|
||||
val coneDiagnosticType = generatedType("diagnostics", "ConeDiagnostic")
|
||||
val coneStubDiagnosticType = generatedType("diagnostics", "ConeStubDiagnostic")
|
||||
|
||||
val dslBuilderAnnotationType = generatedType("builder", "FirBuilderDsl")
|
||||
val firImplementationDetailType = generatedType("FirImplementationDetail")
|
||||
val declarationOriginType = generatedType("declarations", "FirDeclarationOrigin")
|
||||
val declarationAttributesType = generatedType("declarations", "FirDeclarationAttributes")
|
||||
|
||||
-16
@@ -90,16 +90,6 @@ abstract class AbstractBuilderConfigurator<T : AbstractFirTreeBuilder>(val firTr
|
||||
builder.materializedElement = element
|
||||
return ExceptConfigurator()
|
||||
}
|
||||
|
||||
inner class Helper(val fieldName: String) {
|
||||
infix fun from(element: Element) {
|
||||
val field = element[fieldName] ?: throw IllegalArgumentException("Element $element doesn't have field $fieldName")
|
||||
builder.fields += FieldWithDefault(field)
|
||||
}
|
||||
}
|
||||
|
||||
// fields has <field> from <element>
|
||||
infix fun has(name: String): Helper = Helper(name)
|
||||
}
|
||||
|
||||
inner class ExceptConfigurator {
|
||||
@@ -115,12 +105,6 @@ abstract class AbstractBuilderConfigurator<T : AbstractFirTreeBuilder>(val firTr
|
||||
val fields = Fields()
|
||||
val parents: MutableList<IntermediateBuilder> get() = builder.parents
|
||||
|
||||
var materializedElement: Element
|
||||
get() = throw IllegalArgumentException()
|
||||
set(value) {
|
||||
builder.materializedElement = value
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class IntermediateBuilderDelegateProvider(
|
||||
|
||||
-8
@@ -42,10 +42,6 @@ abstract class AbstractFieldConfigurator<T : AbstractFirTreeBuilder>(private val
|
||||
}
|
||||
}
|
||||
|
||||
fun parentArg(parent: Element, argument: String, type: String) {
|
||||
parentArg(parent, Type(null, argument), Type(null, type))
|
||||
}
|
||||
|
||||
fun parentArg(parent: Element, argument: String, type: Importable) {
|
||||
parentArg(parent, Type(null, argument), type)
|
||||
}
|
||||
@@ -61,10 +57,6 @@ abstract class AbstractFieldConfigurator<T : AbstractFirTreeBuilder>(private val
|
||||
argMap[argument] = type
|
||||
}
|
||||
|
||||
fun Type.withArgs(vararg args: Importable): Pair<Type, List<Importable>> {
|
||||
return this to args.toList()
|
||||
}
|
||||
|
||||
fun Type.withArgs(vararg args: String): Pair<Type, List<Importable>> {
|
||||
return this to args.map { Type(null, it) }
|
||||
}
|
||||
|
||||
-2
@@ -87,8 +87,6 @@ abstract class AbstractFirTreeImplementationConfigurator {
|
||||
|
||||
val parents = ParentsHolder()
|
||||
|
||||
fun Implementation.withArg(argument: Importable): ImplementationWithArg = ImplementationWithArg(this, argument)
|
||||
|
||||
fun optInToInternals() {
|
||||
implementation.requiresOptIn = true
|
||||
}
|
||||
|
||||
+1
-3
@@ -94,6 +94,4 @@ fun Field.withTransform(needTransformInOtherChildren: Boolean = false): Field =
|
||||
|
||||
fun Field.withReplace(): Field = copy().apply {
|
||||
withReplace = true
|
||||
}
|
||||
|
||||
fun FieldSet.withTransform(): FieldSet = this.map { it.withTransform() }
|
||||
}
|
||||
-1
@@ -130,7 +130,6 @@ private fun SmartPrinter.printBuilder(builder: Builder) {
|
||||
|
||||
internal val Field.invisibleField: Boolean get() = customInitializationCall != null
|
||||
|
||||
private val String.nullable: String get() = if (endsWith("?")) this else "$this?"
|
||||
private fun FieldWithDefault.needBackingField(fieldIsUseless: Boolean) =
|
||||
(!nullable || notNull) && origin !is FieldList && if (fieldIsUseless) {
|
||||
defaultValueInImplementation == null
|
||||
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.tree.generator.util
|
||||
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder
|
||||
import org.jetbrains.kotlin.fir.tree.generator.model.Element
|
||||
import org.jetbrains.kotlin.fir.tree.generator.model.Field
|
||||
import java.io.File
|
||||
|
||||
fun printFieldUsageTable(builder: AbstractFirTreeBuilder) {
|
||||
val elements = builder.elements.filter { it.allImplementations.isNotEmpty() }
|
||||
val fields = elements.flatMapTo(mutableSetOf()) { it.allFields }
|
||||
|
||||
val mapping = mutableMapOf<Element, Set<Field>>()
|
||||
val fieldsCount = mutableMapOf<Field, Int>()
|
||||
for (element in elements) {
|
||||
val containingFields = mutableSetOf<Field>()
|
||||
for (field in fields) {
|
||||
if (field in element.allFields) {
|
||||
containingFields += field
|
||||
fieldsCount[field] = fieldsCount.getOrDefault(field, 0) + 1
|
||||
}
|
||||
}
|
||||
mapping[element] = containingFields
|
||||
}
|
||||
|
||||
val sortedFields = fields.sortedByDescending { fieldsCount[it] }
|
||||
File("compiler/fir/tree/table.csv").printWriter().use { printer ->
|
||||
with(printer) {
|
||||
val delim = ","
|
||||
print(delim)
|
||||
println(sortedFields.joinToString(delim) { "${it.name}:${fieldsCount.getValue(it)}" })
|
||||
for (element in elements) {
|
||||
print(element.name + delim)
|
||||
val containingFields = mapping.getValue(element)
|
||||
println(sortedFields.joinToString(delim) { if (it in containingFields) "+" else "-" })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user