More tests for KT-28997, fix isLocal for anonymous object in script

This commit is contained in:
Mikhail Glukhikh
2018-12-25 18:20:19 +03:00
parent 661ac711c0
commit a9147ff446
8 changed files with 41 additions and 0 deletions
@@ -812,6 +812,12 @@ public class KtPsiUtil {
else if (parent instanceof KtClassBody && !isMemberOfObjectExpression((KtCallableDeclaration) current)) {
return (KtElement) parent;
}
else if (parent instanceof KtBlockExpression) {
PsiElement grandParent = parent.getParent();
if (grandParent instanceof KtScript) {
return (KtElement) parent;
}
}
}
if (current instanceof KtParameter) {
return (KtElement) current;
@@ -0,0 +1,5 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtObjectDeclaration
// OPTIONS: usages
val x = <caret>object: Any() {
}
@@ -0,0 +1,5 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtObjectDeclaration
// OPTIONS: usages
fun foo() {
val x = <caret>object : Any() {}
}
@@ -0,0 +1 @@
@@ -0,0 +1,7 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtClass
// OPTIONS: usages, constructorUsages
fun foo() {
class <caret>Local
val x = Local()
}
@@ -0,0 +1 @@
New instance creation 6 val x = Local()
@@ -1384,10 +1384,25 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest {
runTest("idea/testData/findUsages/kotlin/script/anonymousObject.0.kts");
}
@TestMetadata("anonymousObjectAsInitializer.0.kts")
public void testAnonymousObjectAsInitializer() throws Exception {
runTest("idea/testData/findUsages/kotlin/script/anonymousObjectAsInitializer.0.kts");
}
@TestMetadata("anonymousObjectInFun.0.kts")
public void testAnonymousObjectInFun() throws Exception {
runTest("idea/testData/findUsages/kotlin/script/anonymousObjectInFun.0.kts");
}
@TestMetadata("dummy.0.kts")
public void testDummy() throws Exception {
runTest("idea/testData/findUsages/kotlin/script/dummy.0.kts");
}
@TestMetadata("localClass.0.kts")
public void testLocalClass() throws Exception {
runTest("idea/testData/findUsages/kotlin/script/localClass.0.kts");
}
}
@TestMetadata("idea/testData/findUsages/kotlin/unresolvedAnnotation")