aboutsummaryrefslogtreecommitdiff
path: root/src/Analysis/PsiAPI.kt
blob: 2282cd1da2fdb039d9f2c3bf237864abc052baf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package org.jetbrains.dokka

import com.intellij.psi.*
import kotlin.support.*

fun PsiElement.previousSiblings(): Stream<PsiElement> {
    var element: PsiElement? = this
    return object : Stream<PsiElement> {
        override fun iterator(): Iterator<PsiElement> = object : AbstractIterator<PsiElement>() {
            override fun computeNext() {
                element = element?.getPrevSibling()
                if (element == null)
                    done()
                else
                    setNext(element!!)
            }
        }
    }
}