jessewilson
08/24/2021, 8:48 PMCompilerMessageSourceLocation
from my IrElement
, which happens to be an IrCallImpl
so that I can call MessageCollector.report
with a useful source location. Is there an API somewhere to extract a source location from an element?jessewilson
08/24/2021, 8:49 PMjessewilson
08/24/2021, 8:53 PMZac Sweers
08/24/2021, 9:08 PMjessewilson
08/24/2021, 9:29 PMjessewilson
08/24/2021, 9:29 PM/** Finds the line and column of [irElement] within this file. */
fun IrFile.locationOf(irElement: IrElement?): CompilerMessageSourceLocation {
val sourceRangeInfo = fileEntry.getSourceRangeInfo(
beginOffset = irElement?.startOffset ?: UNDEFINED_OFFSET,
endOffset = irElement?.endOffset ?: UNDEFINED_OFFSET
)
return CompilerMessageLocationWithRange.create(
path = sourceRangeInfo.filePath,
lineStart = sourceRangeInfo.startLineNumber + 1,
columnStart = sourceRangeInfo.startColumnNumber + 1,
lineEnd = sourceRangeInfo.endLineNumber + 1,
columnEnd = sourceRangeInfo.endColumnNumber + 1,
lineContent = null
)!!
}
jessewilson
08/24/2021, 9:29 PMAlexander Ioffe
01/03/2024, 6:28 PM