Search constructor-declared properties together with class declarations
This commit is contained in:
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user