blob: 21ba1067a256f3afe80950db8d6665f4f00603a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
package com.jetbrains.dokka
import org.jetbrains.jet.lang.descriptors.*
import org.jetbrains.jet.lexer.*
import org.jetbrains.jet.lang.resolve.*
import org.jetbrains.jet.kdoc.psi.api.*
import org.jetbrains.jet.lang.psi.JetDeclaration
fun BindingContext.getDocumentation(descriptor: DeclarationDescriptor): KDoc? {
val psiElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor)
if (psiElement == null) throw IllegalArgumentException("$descriptor doesn't have connection to source code, is it synthetic?")
return psiElement.previousSiblings().takeWhile { it !is JetDeclaration }.firstOrNull { it is KDoc } as KDoc?
}
|