aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/javadoc/source-position.kt
blob: 6125f9689c410625f245c8a5acf042872a9885b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package org.jetbrains.dokka.javadoc

import com.sun.javadoc.SourcePosition
import org.jetbrains.dokka.DocumentationNode
import org.jetbrains.dokka.NodeKind
import java.io.File

class SourcePositionAdapter(val docNode: DocumentationNode) : SourcePosition {

    private val sourcePositionParts: List<String> by lazy {
        docNode.details(NodeKind.SourcePosition).firstOrNull()?.name?.split(":") ?: emptyList()
    }

    override fun file(): File? = if (sourcePositionParts.isEmpty()) null else File(sourcePositionParts[0])

    override fun line(): Int = sourcePositionParts.getOrNull(1)?.toInt() ?: -1

    override fun column(): Int = sourcePositionParts.getOrNull(2)?.toInt() ?: -1
}