Add possibility to get line offsets from PsiIrFileEntry
This is needed for tests to be able to get offsets without explicit file on disk.
This commit is contained in:
@@ -53,6 +53,8 @@ class PsiIrFileEntry(val psiFile: PsiFile) : IrFileEntry {
|
||||
|
||||
override fun toString(): String = getRecognizableName()
|
||||
|
||||
fun getLineOffsets() = lineStartOffsets.copyOf()
|
||||
|
||||
fun findPsiElement(irElement: IrElement): PsiElement? {
|
||||
var psiElement = fileViewProvider.findElementAt(irElement.startOffset)
|
||||
while (psiElement != null) {
|
||||
|
||||
@@ -175,9 +175,10 @@ val File.lineStartOffsets: IntArray
|
||||
return buffer.toIntArray()
|
||||
}
|
||||
|
||||
val IrFileEntry.lineStartOffsets
|
||||
get() = File(name).let {
|
||||
if (it.exists() && it.isFile) it.lineStartOffsets else IntArray(0)
|
||||
val IrFileEntry.lineStartOffsets: IntArray
|
||||
get() = when (this) {
|
||||
is PsiIrFileEntry -> this.getLineOffsets()
|
||||
else -> File(name).let { if (it.exists() && it.isFile) it.lineStartOffsets else IntArray(0) }
|
||||
}
|
||||
|
||||
class NaiveSourceBasedFileEntryImpl(
|
||||
|
||||
Reference in New Issue
Block a user