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()
|
||||
}
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.psi.JetParameter
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.*
|
||||
import org.jetbrains.jet.asJava.LightClassUtil.PropertyAccessorsPsiMethods
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.*
|
||||
|
||||
val isTargetUsage = (PsiReference::isTargetUsage).searchFilter
|
||||
|
||||
@@ -136,8 +137,8 @@ class ClassDeclarationsUsagesSearchHelper(
|
||||
val items = ArrayList<UsagesSearchRequestItem>()
|
||||
val declHelper = DefaultSearchHelper<JetNamedDeclaration>(skipImports)
|
||||
|
||||
for (decl in target.element.getDeclarations()) {
|
||||
if ((decl is JetNamedFunction && functionUsages) || (decl is JetProperty && propertyUsages)) {
|
||||
for (decl in target.element.effectiveDeclarations()) {
|
||||
if ((decl is JetNamedFunction && functionUsages) || ((decl is JetProperty || decl is JetParameter) && propertyUsages)) {
|
||||
items.add(declHelper.newItem(target.retarget(decl as JetNamedDeclaration)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ trait X {
|
||||
}
|
||||
}
|
||||
|
||||
open class <caret>A: X {
|
||||
open class <caret>A(val t: String, var u: String): X {
|
||||
override val a: String
|
||||
get() {
|
||||
return "?"
|
||||
|
||||
@@ -2,7 +2,9 @@ class Usages {
|
||||
fun foo(a: A) {
|
||||
a.foo("")
|
||||
println("${a.a} ${a.b}")
|
||||
println("${a.t} ${a.u}")
|
||||
a.b = 12
|
||||
a.u = 13
|
||||
}
|
||||
|
||||
fun foo(x: X) {
|
||||
|
||||
+4
-1
@@ -1,3 +1,6 @@
|
||||
Value read (4: 22) println("${a.a} ${a.b}")
|
||||
Value read (4: 29) println("${a.a} ${a.b}")
|
||||
Value write (5: 11) a.b = 12
|
||||
Value read (5: 22) println("${a.t} ${a.u}")
|
||||
Value read (5: 29) println("${a.t} ${a.u}")
|
||||
Value write (6: 11) a.b = 12
|
||||
Value write (7: 11) a.u = 13
|
||||
Reference in New Issue
Block a user