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

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

class SourcePositionAdapter(val docNode: DocumentationNode) : SourcePosition {

    private val sourcePositionParts: List<String> by lazy {
        docNode.details(DocumentationNode.Kind.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
}