diff options
Diffstat (limited to 'src/Analysis/PsiAPI.kt')
-rw-r--r-- | src/Analysis/PsiAPI.kt | 14 |
1 files changed, 9 insertions, 5 deletions
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!!) } } } |