KT-18501: Fix to find KDoc even if KDoc is in ModifierList
This commit is contained in:
committed by
Simon Ogorodnik
parent
4b92349031
commit
fe9d3f16d3
@@ -16,14 +16,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi.findDocComment
|
||||
|
||||
import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.PsiWhiteSpace
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclarationModifierList
|
||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
|
||||
fun findDocComment(declaration: KtDeclaration): KDoc? {
|
||||
return declaration.allChildren
|
||||
.dropWhile { it !is KDoc && (it is PsiWhiteSpace || it is PsiComment) }
|
||||
.first() as? KDoc
|
||||
.flatMap {
|
||||
if (it is KtDeclarationModifierList) {
|
||||
return@flatMap it.children.asSequence()
|
||||
}
|
||||
sequenceOf(it)
|
||||
}
|
||||
.dropWhile { it !is KDoc }
|
||||
.firstOrNull() as? KDoc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user