[FIR] Implement IR body generators for all FIR declarations generators in plugin prototype

This commit is contained in:
Dmitriy Novozhilov
2021-12-01 16:23:33 +03:00
committed by TeamCityServer
parent 9a0e73e132
commit 86404b8027
35 changed files with 485 additions and 610 deletions
@@ -187,6 +187,8 @@ class NaiveSourceBasedFileEntryImpl(
override val name: String,
private val lineStartOffsets: IntArray = intArrayOf()
) : IrFileEntry {
val lineStartOffsetsAreEmpty: Boolean
get() = lineStartOffsets.isEmpty()
private val MAX_SAVED_LINE_NUMBERS = 50
@@ -254,4 +256,4 @@ inline fun MemberScope.findFirstFunction(name: String, predicate: (CallableMembe
fun filterOutAnnotations(fqName: FqName, annotations: List<IrConstructorCall>): List<IrConstructorCall> {
return annotations.filterNot { it.annotationClass.hasEqualFqName(fqName) }
}
}
@@ -42,6 +42,11 @@ fun IrFile.dumpTreesFromLineNumber(lineNumber: Int, normalizeNames: Boolean = fa
return sb.toString()
}
fun IrFile.shouldSkipDump(): Boolean {
val entry = fileEntry as? NaiveSourceBasedFileEntryImpl ?: return false
return entry.lineStartOffsetsAreEmpty
}
class DumpIrTreeVisitor(
out: Appendable,
normalizeNames: Boolean = false,
@@ -13,10 +13,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsManglerDesc
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
import org.jetbrains.kotlin.ir.util.SymbolTable
import org.jetbrains.kotlin.ir.util.dump
import org.jetbrains.kotlin.ir.util.dumpTreesFromLineNumber
import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi2ir.generators.DeclarationStubGeneratorImpl
@@ -68,6 +65,7 @@ class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServ
val builder = baseDumper.builderForModule(module)
for ((testFile, irFile) in testFileToIrFile) {
if (testFile?.directives?.contains(EXTERNAL_FILE) == true) continue
if (irFile.shouldSkipDump()) continue
var actualDump = irFile.dumpTreesFromLineNumber(lineNumber = 0, normalizeNames = true)
if (actualDump.isEmpty()) {
actualDump = irFile.dumpTreesFromLineNumber(lineNumber = UNDEFINED_OFFSET, normalizeNames = true)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test.backend.handlers
import org.jetbrains.kotlin.ir.IrVerifier
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
import org.jetbrains.kotlin.ir.util.dumpTreesFromLineNumber
import org.jetbrains.kotlin.ir.util.shouldSkipDump
import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler.Companion.groupWithTestFiles
import org.jetbrains.kotlin.test.backend.ir.IrBackendInput
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
@@ -29,6 +30,7 @@ class IrTreeVerifierHandler(testServices: TestServices) : AbstractIrHandler(test
IrVerifier(assertions).verifyWithAssert(irFile)
if (irFile.shouldSkipDump()) continue
val actualDump = irFile.dumpTreesFromLineNumber(lineNumber = 0, normalizeNames = true)
val irFileCopy = irFile.deepCopyWithSymbols()