[PSI2IR, K/Wasm] Sync start and end offsets on PSI and FIR for primary constructors

This commit is contained in:
Artem Kobzar
2024-02-29 14:42:33 +00:00
committed by Space Team
parent 87e162e052
commit 2e4d02e9f4
126 changed files with 82 additions and 188 deletions
@@ -8,9 +8,15 @@ package org.jetbrains.kotlin.backend.wasm.ir2wasm
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrFileEntry
import org.jetbrains.kotlin.ir.LineAndColumn
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
import org.jetbrains.kotlin.wasm.ir.WasmExpressionBuilder
import org.jetbrains.kotlin.wasm.ir.source.location.SourceLocation
private val IrElement.hasSyntheticOrUndefinedLocation: Boolean
get() = startOffset in SYNTHETIC_OFFSET..UNDEFINED_OFFSET ||
endOffset in SYNTHETIC_OFFSET..UNDEFINED_OFFSET
enum class LocationType {
START {
override fun getLineAndColumnNumberFor(irElement: IrElement, fileEntry: IrFileEntry) =
@@ -26,6 +32,7 @@ enum class LocationType {
fun IrElement.getSourceLocation(fileEntry: IrFileEntry?, type: LocationType = LocationType.START): SourceLocation {
if (fileEntry == null) return SourceLocation.NoLocation("fileEntry is null")
if (hasSyntheticOrUndefinedLocation) return SourceLocation.NoLocation("Synthetic declaration")
val path = fileEntry.name
val (line, column) = type.getLineAndColumnNumberFor(this, fileEntry)