Search constructor-declared properties together with class declarations

This commit is contained in:
Alexey Sedunov
2013-11-07 17:27:41 +04:00
parent 52ffd52a4e
commit 1b8205273b
5 changed files with 23 additions and 5 deletions
@@ -19,6 +19,10 @@ package org.jetbrains.jet.lang.psi.psiUtil
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.jet.lang.psi.JetDeclaration
import org.jetbrains.jet.lang.psi.JetClass
import java.util.ArrayList
import org.jetbrains.jet.lang.psi.JetClassOrObject
fun PsiElement.getParentByTypeAndPredicate<T: PsiElement>(
parentClass : Class<T>, strict : Boolean = false, predicate: (T) -> Boolean
@@ -54,4 +58,12 @@ fun <T: PsiElement> T.getIfChildIsInBranch(element: PsiElement, branch: T.() ->
fun PsiElement.getParentByTypeAndBranch<T: PsiElement>(
parentClass : Class<T>, strict : Boolean = false, branch: T.() -> PsiElement?) : T? {
return getParentByType(parentClass, strict)?.getIfChildIsInBranch(this, branch)
}
}
fun JetClassOrObject.effectiveDeclarations(): List<JetDeclaration> =
when(this) {
is JetClass ->
getDeclarations() + getPrimaryConstructorParameters().filter { p -> p.getValOrVarNode() != null }
else ->
getDeclarations()
}