Added tests, and fixed some bugs using it
This commit is contained in:
committed by
Valentin Kipyatkov
parent
251d87fd22
commit
939b4768f5
@@ -217,15 +217,15 @@ class KotlinIndicesHelper(
|
|||||||
|
|
||||||
fun getKotlinStatics(name: String): Collection<DeclarationDescriptor> {
|
fun getKotlinStatics(name: String): Collection<DeclarationDescriptor> {
|
||||||
return sequenceOf(KotlinFunctionShortNameIndex.getInstance().get(name, project, scope),
|
return sequenceOf(KotlinFunctionShortNameIndex.getInstance().get(name, project, scope),
|
||||||
KotlinPropertyShortNameIndex.getInstance().get(name, project, scope)).
|
KotlinPropertyShortNameIndex.getInstance().get(name, project, scope))
|
||||||
flatMap { it.asSequence() }
|
.flatMap { it.asSequence() }
|
||||||
.mapNotNull {
|
.mapNotNull {
|
||||||
when (it) {
|
when (it) {
|
||||||
is KtNamedFunction -> it.descriptor
|
is KtNamedFunction -> it.descriptor
|
||||||
is KtProperty -> it.descriptor
|
is KtProperty -> it.descriptor
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}.filterNot { it.importableFqName == null }
|
||||||
.filter(descriptorFilter)
|
.filter(descriptorFilter)
|
||||||
.toSet()
|
.toSet()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// FILE: main.before.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create function 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: dependency.before.kt
|
||||||
|
package bar
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
fun foobar() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: main.after.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create function 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// FILE: main.before.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create local variable 'foobar'
|
||||||
|
// ACTION: Create property 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret> = "barfoo"
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: dependency.before.kt
|
||||||
|
package bar
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
var foobar = "foobar"
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: main.after.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create local variable 'foobar'
|
||||||
|
// ACTION: Create property 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret> = "barfoo"
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// FILE: main.before.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create local variable 'foobar'
|
||||||
|
// ACTION: Create property 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret> = "barfoo"
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: dependency.before.java
|
||||||
|
package bar
|
||||||
|
|
||||||
|
public class Foo {
|
||||||
|
public foobar = "foobar"
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: main.after.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create local variable 'foobar'
|
||||||
|
// ACTION: Create property 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret> = "barfoo"
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// FILE: main.before.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create function 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: dependency.before.java
|
||||||
|
package bar
|
||||||
|
|
||||||
|
public class Foo {
|
||||||
|
public void foobar()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILE: main.after.kt
|
||||||
|
// "Static import" "false"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
// ACTION: Create function 'foobar'
|
||||||
|
// ACTION: Rename reference
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
// FILE: main.before.kt
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: dependency.before.kt
|
||||||
|
package bar
|
||||||
|
|
||||||
|
object Foo {
|
||||||
|
fun foobar() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.after.kt
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
import bar.Foo.foobar
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// FILE: first.before.kt
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
val k = foobar<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: Bar.java
|
||||||
|
|
||||||
|
public class Bar {
|
||||||
|
public static final String foobar = "foobar";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: first.after.kt
|
||||||
|
import Bar.foobar
|
||||||
|
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
val k = foobar<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// FILE: first.before.kt
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: Bar.java
|
||||||
|
|
||||||
|
public class Bar {
|
||||||
|
public static void foobar()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: first.after.kt
|
||||||
|
import Bar.foobar
|
||||||
|
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// FILE: main.before.kt
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret> = "barfoo"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: dependency.before.kt
|
||||||
|
package bar
|
||||||
|
|
||||||
|
object Foo {
|
||||||
|
var foobar = "foobar"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.after.kt
|
||||||
|
// "Static import" "true"
|
||||||
|
// ERROR: Unresolved reference: foobar
|
||||||
|
|
||||||
|
//KT-9009
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
import bar.Foo.foobar
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
foobar<caret> = "barfoo"
|
||||||
|
}
|
||||||
@@ -353,6 +353,32 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
|
|||||||
doTestWithExtraFile(fileName);
|
doTestWithExtraFile(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noStaticImportForClassFunction.test")
|
||||||
|
public void testNoStaticImportForClassFunction() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/noStaticImportForClassFunction.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noStaticImportForClassProperty.test")
|
||||||
|
public void testNoStaticImportForClassProperty() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/noStaticImportForClassProperty.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noStaticImportForJavaNonStaticField.test")
|
||||||
|
public void testNoStaticImportForJavaNonStaticField() throws Exception {
|
||||||
|
String fileName =
|
||||||
|
KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/noStaticImportForJavaNonStaticField.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noStaticImportForJavaNonStaticMethod.test")
|
||||||
|
public void testNoStaticImportForJavaNonStaticMethod() throws Exception {
|
||||||
|
String fileName =
|
||||||
|
KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/noStaticImportForJavaNonStaticMethod.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("notExcludedClass.before.Main.kt")
|
@TestMetadata("notExcludedClass.before.Main.kt")
|
||||||
public void testNotExcludedClass() throws Exception {
|
public void testNotExcludedClass() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/notExcludedClass.before.Main.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/notExcludedClass.before.Main.kt");
|
||||||
@@ -413,6 +439,30 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
|
|||||||
doTestWithExtraFile(fileName);
|
doTestWithExtraFile(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("staticImportFunction.test")
|
||||||
|
public void testStaticImportFunction() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/staticImportFunction.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("staticImportJavaField.test")
|
||||||
|
public void testStaticImportJavaField() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/staticImportJavaField.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("staticImportJavaMethod.test")
|
||||||
|
public void testStaticImportJavaMethod() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/staticImportJavaMethod.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("staticImportProperty.test")
|
||||||
|
public void testStaticImportProperty() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/staticImportProperty.test");
|
||||||
|
doTestWithExtraFile(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("timesAssign.before.Main.kt")
|
@TestMetadata("timesAssign.before.Main.kt")
|
||||||
public void testTimesAssign() throws Exception {
|
public void testTimesAssign() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/timesAssign.before.Main.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/timesAssign.before.Main.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user