blob: dc59b0f1bf73b62d16af9860e50ee540499ab2d7 (
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.PsiElement
import kotlin.support.AbstractIterator
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!!)
}
}
}
}
|