Fix search of package-level function/property usages in Java code
This commit is contained in:
@@ -53,4 +53,10 @@ public class JetClsMethodImpl extends ClsMethodImpl implements JetClsMethod {
|
||||
public void delete() throws IncorrectOperationException {
|
||||
origin.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEquivalentTo(PsiElement another) {
|
||||
if (another instanceof JetClsMethod && getOrigin().equals(((JetClsMethod) another).getOrigin())) return true;
|
||||
return super.isEquivalentTo(another);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package client;
|
||||
|
||||
import server.ServerPackage;
|
||||
|
||||
class JClient {
|
||||
String s = ServerPackage.processRequest();
|
||||
|
||||
String sendRequest() {
|
||||
return ServerPackage.processRequest();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
Callable reference (6: 23) val methodRef = ::processRequest()
|
||||
Function call (10: 9) processRequest()
|
||||
Import directive (3: 15) import server.processRequest
|
||||
Import directive (3: 15) import server.processRequest
|
||||
Unclassified usage (6: 30) String s = ServerPackage.processRequest();
|
||||
Unclassified usage (9: 30) return ServerPackage.processRequest();
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
Import directive (3: 15) import server.foo
|
||||
Receiver (8: 35) println("length: ${server.foo.length()}")
|
||||
Selector (7: 33) println("foo = ${server.foo}")
|
||||
@@ -0,0 +1,11 @@
|
||||
package client;
|
||||
|
||||
import server.ServerPackage;
|
||||
|
||||
class JClient {
|
||||
void fooBar() {
|
||||
System.out.println("foo = " + ServerPackage.getFoo());
|
||||
System.out.println("length: " + ServerPackage.getFoo().length());
|
||||
ServerPackage.setFoo("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
Import directive (3: 15) import server.foo
|
||||
Receiver (8: 35) println("length: ${server.foo.length()}")
|
||||
Selector (7: 33) println("foo = ${server.foo}")
|
||||
Unclassified usage (7: 53) System.out.println("foo = " + ServerPackage.getFoo());
|
||||
Unclassified usage (8: 55) System.out.println("length: " + ServerPackage.getFoo().length());
|
||||
Unclassified usage (9: 23) ServerPackage.setFoo("");
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<node text="packageFun() ()" base="true">
|
||||
<node text="KA.name(2 usages) ()"/>
|
||||
<node text="packageFun.localFun(String)(2 usages) ()"/>
|
||||
<node text="JA.foo(String)(2 usages) ()">
|
||||
<node text="PrintStream.println(String) (java.io)"/>
|
||||
</node>
|
||||
<node text="KA.foo(String)(3 usages) ()"/>
|
||||
<node text="packageVal ()"/>
|
||||
<node text="JA.JA()(4 usages) ()"/>
|
||||
<node text="KA(5 usages) ()"/>
|
||||
</node>
|
||||
@@ -0,0 +1,21 @@
|
||||
class KA {
|
||||
val name = "A"
|
||||
fun foo(s: String): String = "A: $s"
|
||||
}
|
||||
|
||||
val packageVal = ""
|
||||
|
||||
fun <caret>packageFun() {
|
||||
fun localFun(s: String): String = s
|
||||
val localVal = localFun("")
|
||||
|
||||
KA().foo(KA().name)
|
||||
JA().foo(JA().name)
|
||||
localFun(packageVal)
|
||||
|
||||
run {
|
||||
KA().foo(KA().name)
|
||||
JA().foo(JA().name)
|
||||
KA().foo(localVal)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class JA {
|
||||
public JA() {
|
||||
|
||||
}
|
||||
|
||||
public String name = "A";
|
||||
|
||||
public String foo(String s) {
|
||||
System.out.println(s);
|
||||
return "A " + s;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<node text="packageVal ()" base="true">
|
||||
<node text="JA.JA()(4 usages) ()"/>
|
||||
<node text="KA.foo(String)(2 usages) ()"/>
|
||||
<node text="localFun(String)(2 usages) ()">
|
||||
<node text="packageFun(String) ()"/>
|
||||
</node>
|
||||
<node text="KA.name(2 usages) ()"/>
|
||||
<node text="JA.foo(String)(2 usages) ()">
|
||||
<node text="PrintStream.println(String) (java.io)"/>
|
||||
</node>
|
||||
<node text="packageFun(String) ()"/>
|
||||
<node text="KA(4 usages) ()"/>
|
||||
</node>
|
||||
@@ -0,0 +1,24 @@
|
||||
class KA {
|
||||
val name = "A"
|
||||
fun foo(s: String): String = "A: $s"
|
||||
}
|
||||
|
||||
fun packageFun(s: String): String = s
|
||||
|
||||
val <caret>packageVal: String
|
||||
get() {
|
||||
fun localFun(s: String): String = packageFun(s)
|
||||
val localVal = localFun("")
|
||||
|
||||
KA().foo(KA().name)
|
||||
JA().foo(JA().name)
|
||||
localFun("")
|
||||
|
||||
run {
|
||||
KA().foo(KA().name)
|
||||
JA().foo(JA().name)
|
||||
packageFun(localVal)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class JA {
|
||||
public JA() {
|
||||
|
||||
}
|
||||
|
||||
public String name = "A";
|
||||
|
||||
public String foo(String s) {
|
||||
System.out.println(s);
|
||||
return "A " + s;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<node text="packageFun(String) ()" base="true">
|
||||
<node text="bar.localFun() ()"/>
|
||||
<node text="main0.kt ()"/>
|
||||
<node text="JA.foo() ()"/>
|
||||
<node text="KClientObj ()"/>
|
||||
<node text="KClient ()"/>
|
||||
<node text="KClient ()"/>
|
||||
<node text="KClient.bar ()"/>
|
||||
<node text="KClient.bar() ()"/>
|
||||
<node text="JA ()"/>
|
||||
</node>
|
||||
@@ -0,0 +1,26 @@
|
||||
fun <caret>packageFun(s: String): String = s
|
||||
|
||||
val packageVal = packageFun("")
|
||||
|
||||
class KClient {
|
||||
{
|
||||
packageFun("")
|
||||
}
|
||||
|
||||
class object {
|
||||
val a = packageFun("")
|
||||
}
|
||||
|
||||
val bar: String
|
||||
get() = packageFun("")
|
||||
|
||||
fun bar() {
|
||||
fun localFun() = packageFun("")
|
||||
|
||||
packageFun("")
|
||||
}
|
||||
}
|
||||
|
||||
object KClientObj {
|
||||
val a = packageFun("")
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class JA {
|
||||
public String name = _DefaultPackage.packageFun("");
|
||||
|
||||
public String foo() {
|
||||
return _DefaultPackage.packageFun("");
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
<node text="packageVal ()" base="true">
|
||||
<node text="JA ()"/>
|
||||
<node text="JA.getName()(2 usages) ()"/>
|
||||
<node text="KClient ()"/>
|
||||
<node text="KClient ()"/>
|
||||
<node text="KClient.bar() ()"/>
|
||||
<node text="KClient.bar(2 usages) ()"/>
|
||||
<node text="KClientObj(2 usages) ()"/>
|
||||
<node text="bar.localFun() ()"/>
|
||||
<node text="packageFun(String) ()"/>
|
||||
</node>
|
||||
@@ -0,0 +1,30 @@
|
||||
var <caret>packageVal = ""
|
||||
|
||||
fun packageFun(s: String): String = packageVal + s
|
||||
|
||||
class KClient {
|
||||
{
|
||||
packageVal = ""
|
||||
}
|
||||
|
||||
class object {
|
||||
val a = packageVal
|
||||
}
|
||||
|
||||
val bar: String
|
||||
get() = packageVal
|
||||
set(value: String) {packageVal = value}
|
||||
|
||||
fun bar() {
|
||||
fun localFun() = packageVal
|
||||
|
||||
val s = packageVal
|
||||
}
|
||||
}
|
||||
|
||||
object KClientObj {
|
||||
val a = packageVal
|
||||
{
|
||||
packageVal = ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class JA {
|
||||
public String name = _DefaultPackage.getPackageVal();
|
||||
|
||||
public String getName() {
|
||||
_DefaultPackage.setPackageVal("");
|
||||
return _DefaultPackage.getPackageVal();
|
||||
}
|
||||
}
|
||||
@@ -227,9 +227,9 @@ public class JetFindUsagesTest extends AbstractJetFindUsagesTest {
|
||||
doTest("idea/testData/findUsages/findPropertyUsages/javaPropertyUsages.0.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPropertyUsages.0.kt")
|
||||
public void testKotlinPropertyUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/findPropertyUsages/kotlinPropertyUsages.0.kt");
|
||||
@TestMetadata("kotlinTopLevelPropertyUsages.0.kt")
|
||||
public void testKotlinTopLevelPropertyUsages() throws Exception {
|
||||
doTest("idea/testData/findUsages/findPropertyUsages/kotlinTopLevelPropertyUsages.0.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -237,6 +237,16 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
doCallerHierarchyTest("idea/testData/hierarchy/calls/callers/kotlinNestedInnerClass");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPackageFunction")
|
||||
public void testKotlinPackageFunction() throws Exception {
|
||||
doCallerHierarchyTest("idea/testData/hierarchy/calls/callers/kotlinPackageFunction");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPackageProperty")
|
||||
public void testKotlinPackageProperty() throws Exception {
|
||||
doCallerHierarchyTest("idea/testData/hierarchy/calls/callers/kotlinPackageProperty");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinProperty")
|
||||
public void testKotlinProperty() throws Exception {
|
||||
doCallerHierarchyTest("idea/testData/hierarchy/calls/callers/kotlinProperty");
|
||||
@@ -305,6 +315,16 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
|
||||
doCalleeHierarchyTest("idea/testData/hierarchy/calls/callees/kotlinObject");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPackageFunction")
|
||||
public void testKotlinPackageFunction() throws Exception {
|
||||
doCalleeHierarchyTest("idea/testData/hierarchy/calls/callees/kotlinPackageFunction");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinPackageProperty")
|
||||
public void testKotlinPackageProperty() throws Exception {
|
||||
doCalleeHierarchyTest("idea/testData/hierarchy/calls/callees/kotlinPackageProperty");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinProperty")
|
||||
public void testKotlinProperty() throws Exception {
|
||||
doCalleeHierarchyTest("idea/testData/hierarchy/calls/callees/kotlinProperty");
|
||||
|
||||
Reference in New Issue
Block a user