Make Kotlin light classes pass "element instanceof StubBasedPsiElement" in LocalSearchScope scope

This commit is contained in:
Nikolay Krasko
2015-09-01 20:52:45 +03:00
parent 853c29be5a
commit 73a24435f7
5 changed files with 44 additions and 2 deletions
@@ -0,0 +1,21 @@
public class ImplementJavaInnerInterface {
interface Test {
void foo();
}
void test() {
Test test = new Test() {
@Override
public void foo() {
}
};
}
void usage(Test test) {
test.<caret>foo();
}
}
// REF: (in KotlinTest).foo()
// REF: <anonymous>.foo()
@@ -0,0 +1,3 @@
class KotlinTest : ImplementJavaInnerInterface.Test {
override fun foo() {}
}
@@ -62,10 +62,18 @@ public class JetGotoImplementationMultifileTest extends JetLightCodeInsightFixtu
doKotlinJavaTest();
}
public void testImplementJavaInnerInterface() throws Exception {
doJavaKotlinTest();
}
private void doKotlinJavaTest() throws Exception {
doMultifileTest(getTestName(false) + ".kt", getTestName(false) + ".java");
}
private void doJavaKotlinTest() throws Exception {
doMultifileTest(getTestName(false) + ".java", getTestName(false) + ".kt");
}
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.test;
import com.intellij.navigation.ItemPresentation;
import com.intellij.navigation.NavigationItem;
import com.intellij.psi.PsiAnonymousClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.util.PsiTreeUtil;
@@ -49,6 +50,9 @@ public final class ReferenceUtils {
String presentableText = presentation.getPresentableText();
String locationString = presentation.getLocationString();
if (locationString == null && element.getParent() instanceof PsiAnonymousClass) {
locationString = "<anonymous>";
}
return locationString == null || navigationElement instanceof PsiPackage
// for PsiPackage, presentableText is FQ name of current package
? presentableText