use Kotlin call hierarchy provider only for Kotlin elements, to ensure that it does not interfere with standard Java features of IntelliJ IDEA
This commit is contained in:
@@ -526,10 +526,6 @@
|
||||
<callHierarchyProvider
|
||||
language="kotlin"
|
||||
implementationClass="org.jetbrains.kotlin.idea.hierarchy.calls.KotlinCallHierarchyProvider" />
|
||||
<callHierarchyProvider
|
||||
language="JAVA"
|
||||
implementationClass="org.jetbrains.kotlin.idea.hierarchy.calls.KotlinCallHierarchyProvider"
|
||||
order="first" />
|
||||
<methodHierarchyProvider
|
||||
language="kotlin"
|
||||
implementationClass="org.jetbrains.kotlin.idea.hierarchy.overrides.KotlinOverrideHierarchyProvider" />
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||
import org.jetbrains.kotlin.idea.hierarchy.HierarchyUtils;
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
@@ -42,7 +43,7 @@ public class KotlinCallHierarchyProvider implements HierarchyProvider {
|
||||
if (element == null) return null;
|
||||
|
||||
element = HierarchyUtils.getCallHierarchyElement(element);
|
||||
if (element instanceof KtFile) return null;
|
||||
if (element instanceof KtFile || element.getLanguage() != KotlinLanguage.INSTANCE) return null;
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
<node text="KClient.KClient() ()" base="true">
|
||||
<node text="KA.KA()(2 usages) ()"/>
|
||||
<node text="KA.foo(String) ()"/>
|
||||
<node text="JA.JA()(2 usages) ()"/>
|
||||
<node text="JA.getName() ()"/>
|
||||
<node text="JA.foo(String) ()">
|
||||
<node text="PrintStream.println(String) (java.io)"/>
|
||||
</node>
|
||||
</node>
|
||||
@@ -1,31 +0,0 @@
|
||||
class KA {
|
||||
KA() {
|
||||
}
|
||||
|
||||
public final String name = "A";
|
||||
public final String foo(String s) {
|
||||
return "A " + s;
|
||||
}
|
||||
}
|
||||
|
||||
class KClientBase {
|
||||
|
||||
}
|
||||
|
||||
class KClient extends KClientBase {
|
||||
public <caret>KClient() {
|
||||
super();
|
||||
new KA().foo(new KA().name);
|
||||
new JA().foo(new JA().getName());
|
||||
}
|
||||
|
||||
{
|
||||
new KA().foo(new KA().name);
|
||||
new JA().foo(new JA().getName());
|
||||
}
|
||||
|
||||
public final void bar() {
|
||||
new KA().foo(new KA().name);
|
||||
new JA().foo(new JA().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
open class JA() {
|
||||
public var name: String = "A"
|
||||
|
||||
public open fun foo(s: String): String {
|
||||
System.out.println(s)
|
||||
return "A " + s
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
<node text="KClient.bar() ()" base="true">
|
||||
<node text="KA.KA()(2 usages) ()"/>
|
||||
<node text="KA.foo(String)(2 usages) ()"/>
|
||||
<node text="JA.JA()(4 usages) ()"/>
|
||||
<node text="JA.getName()(2 usages) ()"/>
|
||||
<node text="JA.foo(String)(2 usages) ()">
|
||||
<node text="PrintStream.println(String) (java.io)"/>
|
||||
</node>
|
||||
<node text="Anonymous in bar() in KClient.run() ()">
|
||||
<node text="KA.KA() ()"/>
|
||||
<node text="KA.foo(String) ()"/>
|
||||
<node text="JA.JA()(2 usages) ()"/>
|
||||
<node text="JA.getName() ()"/>
|
||||
<node text="JA.foo(String) ()">
|
||||
<node text="PrintStream.println(String) (java.io)"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
@@ -1,25 +0,0 @@
|
||||
class KA {
|
||||
public KA() {
|
||||
|
||||
}
|
||||
|
||||
public final String name = "A";
|
||||
|
||||
public final String foo(String s) {
|
||||
return "A " + s;
|
||||
}
|
||||
}
|
||||
|
||||
class KClient {
|
||||
public final void <caret>bar() {
|
||||
new KA().foo("");
|
||||
new JA().foo(new JA().getName());
|
||||
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
new KA().foo("");
|
||||
new JA().foo(new JA().getName());
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
open class JA() {
|
||||
public var name: String = "A"
|
||||
|
||||
public open fun foo(s: String): String {
|
||||
System.out.println(s)
|
||||
return "A " + s
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
<node text="KA.KA() ()" base="true">
|
||||
<node text="KClient.bar() ()"/>
|
||||
<node text="KClient.getBar() ()"/>
|
||||
<node text="KClient ()"/>
|
||||
<node text="JA.JA() ()"/>
|
||||
<node text="JA.newKA() ()"/>
|
||||
<node text="JA ()"/>
|
||||
<node text="JA.JA(Int) ()"/>
|
||||
<node text="JA2 ()"/>
|
||||
</node>
|
||||
@@ -1,27 +0,0 @@
|
||||
class KA {
|
||||
public <caret>KA() {
|
||||
|
||||
}
|
||||
|
||||
public final String name = "A";
|
||||
|
||||
public String foo(String s) {
|
||||
return "A " + s;
|
||||
}
|
||||
}
|
||||
|
||||
class KClient {
|
||||
{
|
||||
new KA();
|
||||
}
|
||||
|
||||
public static final a = new KA();
|
||||
|
||||
public final String getBar() {
|
||||
return new KA().name;
|
||||
}
|
||||
|
||||
public final KA bar() {
|
||||
return new KA();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
open class JA: KA {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
constructor(a: Int): super() {
|
||||
|
||||
}
|
||||
|
||||
public var name: String = KA().getName()
|
||||
|
||||
public open fun newKA(): KA? {
|
||||
return KA()
|
||||
}
|
||||
}
|
||||
|
||||
class JA2: KA() {
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<node text="KA.foo(String) ()" base="true">
|
||||
<node text="JA(2 usages) ()"/>
|
||||
<node text="JA.foo()(2 usages) ()"/>
|
||||
<node text="KClient(4 usages) ()"/>
|
||||
<node text="KClient.bar()(2 usages) ()"/>
|
||||
<node text="KClient.getBar()(2 usages) ()"/>
|
||||
</node>
|
||||
@@ -1,31 +0,0 @@
|
||||
class KBase {
|
||||
public String foo(String s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
class KA extends KBase {
|
||||
public final String name = "A";
|
||||
|
||||
@Override
|
||||
public final String <caret>foo(String s) {
|
||||
return "A " + s;
|
||||
}
|
||||
}
|
||||
|
||||
class KClient {
|
||||
{
|
||||
new KBase().foo("");
|
||||
new KA().foo("");
|
||||
}
|
||||
|
||||
public static final String a = new KBase().foo("") + new KA().foo("");
|
||||
|
||||
public final String getBar() {
|
||||
return new KBase().foo("") + new KA().foo("");
|
||||
}
|
||||
|
||||
public final String bar() {
|
||||
return new KBase().foo("") + new KA().foo("");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
open class JA() {
|
||||
public var name: String = KBase().foo("") + KA().foo("")
|
||||
|
||||
public open fun foo(): String {
|
||||
return KBase().foo("") + KA().foo("")
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
<node text="A ()" base="true">
|
||||
<node text="B ()"/>
|
||||
<node text="T ()">
|
||||
<node text="C ()"/>
|
||||
<node text="Y ()"/>
|
||||
</node>
|
||||
<node text="X ()">
|
||||
<node text="Z ()">
|
||||
<node text="D ()"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
@@ -1,30 +0,0 @@
|
||||
class A {
|
||||
public void <caret>foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
@Override
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class C implements T {
|
||||
@Override
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class D extends Z {
|
||||
@Override
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class S {
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
interface T: A {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
open class X: A() {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
open class Y: T {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
open class Z: X() {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class SS {
|
||||
|
||||
}
|
||||
Vendored
-12
@@ -1,12 +0,0 @@
|
||||
<node text="A ()" base="true">
|
||||
<node text="B ()"/>
|
||||
<node text="T ()">
|
||||
<node text="C ()"/>
|
||||
<node text="Y ()"/>
|
||||
</node>
|
||||
<node text="X ()">
|
||||
<node text="Z ()">
|
||||
<node text="D ()"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
@@ -1,28 +0,0 @@
|
||||
interface A {
|
||||
public void <caret>foo();
|
||||
}
|
||||
|
||||
class B implements A {
|
||||
@Override
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class C implements T {
|
||||
@Override
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class D extends Z {
|
||||
@Override
|
||||
public void foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class S {
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
interface T: A {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
open class X: A {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
open class Y: T {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
open class Z: X() {
|
||||
override fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class SS {
|
||||
|
||||
}
|
||||
@@ -202,8 +202,14 @@ public abstract class AbstractHierarchyTest extends KotlinHierarchyViewTestBase
|
||||
super.doHierarchyTest(treeStructureComputable, fileNames);
|
||||
}
|
||||
catch (RefactoringErrorHintException e) {
|
||||
String expectedMessage = FileUtil.loadFile(new File(folderName, "messages.txt"), true);
|
||||
assertEquals(expectedMessage, e.getLocalizedMessage());
|
||||
File file = new File(folderName, "messages.txt");
|
||||
if (file.exists()) {
|
||||
String expectedMessage = FileUtil.loadFile(file, true);
|
||||
assertEquals(expectedMessage, e.getLocalizedMessage());
|
||||
}
|
||||
else {
|
||||
fail("Unexpected error: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -286,18 +286,6 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/hierarchy/calls/callers"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("javaConstructor")
|
||||
public void testJavaConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/javaConstructor/");
|
||||
doCallerHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaMethod")
|
||||
public void testJavaMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/javaMethod/");
|
||||
doCallerHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinClass")
|
||||
public void testKotlinClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinClass/");
|
||||
@@ -421,18 +409,6 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/hierarchy/calls/callees"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("javaConstructor")
|
||||
public void testJavaConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/javaConstructor/");
|
||||
doCalleeHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaMethod")
|
||||
public void testJavaMethod() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/javaMethod/");
|
||||
doCalleeHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinAnonymousObject")
|
||||
public void testKotlinAnonymousObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callees/kotlinAnonymousObject/");
|
||||
@@ -520,18 +496,6 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/hierarchy/overrides"), Pattern.compile("^([^\\.]+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("javaMethodInClass")
|
||||
public void testJavaMethodInClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/overrides/javaMethodInClass/");
|
||||
doOverrideHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaMethodInInterface")
|
||||
public void testJavaMethodInInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/overrides/javaMethodInInterface/");
|
||||
doOverrideHierarchyTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinFunctionInClass")
|
||||
public void testKotlinFunctionInClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/hierarchy/overrides/kotlinFunctionInClass/");
|
||||
|
||||
Reference in New Issue
Block a user