diff options
author | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-12-15 18:40:36 +0300 |
---|---|---|
committer | Ilya Ryzhenkov <orangy@jetbrains.com> | 2014-12-15 18:40:36 +0300 |
commit | bf6696b193d6a08d1d6c79d4c8e2a0564a286d7e (patch) | |
tree | ad00fbdbe10d90bdf1421632d232e1c464b4de88 | |
parent | 5d0af0b209c43b9f55ff6c80bbca56bab2e4baea (diff) | |
download | dokka-bf6696b193d6a08d1d6c79d4c8e2a0564a286d7e.tar.gz dokka-bf6696b193d6a08d1d6c79d4c8e2a0564a286d7e.tar.bz2 dokka-bf6696b193d6a08d1d6c79d4c8e2a0564a286d7e.zip |
Update to changes in compiler (KDoc is child node of declaration)
-rw-r--r-- | src/Analysis/CommentsAPI.kt | 5 | ||||
-rw-r--r-- | src/Analysis/PsiAPI.kt | 14 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/Analysis/CommentsAPI.kt b/src/Analysis/CommentsAPI.kt index 2407de76..215f3e98 100644 --- a/src/Analysis/CommentsAPI.kt +++ b/src/Analysis/CommentsAPI.kt @@ -10,9 +10,8 @@ fun DeclarationDescriptor.getDocumentationElements(): List<KDoc> { if (psiElement == null) return listOf() - return psiElement.previousSiblings() // go backwards - .takeWhile { it !is JetDeclaration } // till previous declaration - .filter { it is KDoc } // get KDocs + return psiElement.children() // visit children + .takeWhile { it is KDoc } // all KDoc .map { it as KDoc } // cast .toList() .reverse() // make reversed list diff --git a/src/Analysis/PsiAPI.kt b/src/Analysis/PsiAPI.kt index 2282cd1d..19ac4675 100644 --- a/src/Analysis/PsiAPI.kt +++ b/src/Analysis/PsiAPI.kt @@ -3,16 +3,20 @@ package org.jetbrains.dokka import com.intellij.psi.* import kotlin.support.* -fun PsiElement.previousSiblings(): Stream<PsiElement> { - var element: PsiElement? = this +fun PsiElement.children(): Stream<PsiElement> { + val parent = this + var current: PsiElement? = null return object : Stream<PsiElement> { override fun iterator(): Iterator<PsiElement> = object : AbstractIterator<PsiElement>() { + { + setNext(parent.getFirstChild()) + } override fun computeNext() { - element = element?.getPrevSibling() - if (element == null) + current = current?.getNextSibling() + if (current == null) done() else - setNext(element!!) + setNext(current!!) } } } |