Test find usages behaviour when failing to text search on Groovy files
Set test directory to directory with test files (not relative to findUsages folder). This way test will be configured as if all testdata is under source root (previously it was copied into package under path with findUsages) and resolvers will see classes under root package. #KT-14974 In Progress
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
class GroovyClass extends JavaWithGroovyInvoke_0 {
|
||||
def fieldNoType = new JavaWithGroovyInvoke_0.OtherJavaClass()
|
||||
def JavaWithGroovyInvoke_0.OtherJavaClass fieldWithType = new JavaWithGroovyInvoke_0.OtherJavaClass()
|
||||
|
||||
def methodNoType() {
|
||||
new JavaWithGroovyInvoke_0.OtherJavaClass()
|
||||
}
|
||||
|
||||
JavaWithGroovyInvoke_0.OtherJavaClass methodWithType() {
|
||||
new JavaWithGroovyInvoke_0.OtherJavaClass()
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// PSI_ELEMENT: com.intellij.psi.PsiMethod
|
||||
// OPTIONS: usages
|
||||
// PLAIN_WHEN_NEEDED
|
||||
|
||||
public class JavaWithGroovyInvoke_0 {
|
||||
public void <caret>invoke() {
|
||||
}
|
||||
|
||||
public static class OtherJavaClass extends JavaWithGroovyInvoke_0 {}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
fun f(c: JavaWithGroovyInvoke_0) {
|
||||
c()
|
||||
}
|
||||
|
||||
fun foo(o: JavaWithGroovyInvoke_0.OtherJavaClass) {
|
||||
o()
|
||||
}
|
||||
|
||||
fun gr(o: GroovyClass) {
|
||||
o()
|
||||
|
||||
o.fieldNoType() // Red reference
|
||||
o.fieldWithType()
|
||||
|
||||
o.methodNoType()() // Red reference
|
||||
o.methodWithType()()
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Searched references to JavaWithGroovyInvoke_0
|
||||
Used plain search of JavaWithGroovyInvoke_0.invoke() in LocalSearchScope:
|
||||
JetFile: JavaWithGroovyInvoke.0.kt
|
||||
Used plain search of JavaWithGroovyInvoke_0.invoke() in whole search scope
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Implicit 'invoke' 10 o()
|
||||
Implicit 'invoke' 13 o.fieldWithType()
|
||||
Implicit 'invoke' 16 o.methodWithType()()
|
||||
Implicit 'invoke' 2 c()
|
||||
Implicit 'invoke' 6 o()
|
||||
@@ -2,7 +2,7 @@
|
||||
// FIND_BY_REF
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
public fun message(@PropertyKey(resourceBundle = "<caret>idea.testData.findUsages.kotlin.propertyFiles.propertyFileUsagesByRef.2") key: String) = key
|
||||
public fun message(@PropertyKey(resourceBundle = "<caret>propertyFileUsagesByRef.2") key: String) = key
|
||||
|
||||
fun test() {
|
||||
message("foo.bar")
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
class A {
|
||||
static String message(@PropertyKey(resourceBundle = "idea.testData.findUsages.kotlin.propertyFiles.propertyFileUsagesByRef.2") String key, Object... args) {
|
||||
static String message(@PropertyKey(resourceBundle = "propertyFileUsagesByRef.2") String key, Object... args) {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
[propertyFileUsagesByRef.0.kt] Usage in string constants 5 public fun message(@PropertyKey(resourceBundle = "idea.testData.findUsages.kotlin.propertyFiles.propertyFileUsagesByRef.2") key: String) = key
|
||||
[propertyFileUsagesByRef.1.java] Method parameter declaration 4 static String message(@PropertyKey(resourceBundle = "idea.testData.findUsages.kotlin.propertyFiles.propertyFileUsagesByRef.2") String key, Object... args) {
|
||||
[propertyFileUsagesByRef.0.kt] Usage in string constants 5 public fun message(@PropertyKey(resourceBundle = "propertyFileUsagesByRef.2") key: String) = key
|
||||
[propertyFileUsagesByRef.1.java] Method parameter declaration 4 static String message(@PropertyKey(resourceBundle = "propertyFileUsagesByRef.2") String key, Object... args) {
|
||||
@@ -2,7 +2,7 @@
|
||||
// FIND_BY_REF
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
public fun message(@PropertyKey(resourceBundle = "idea.testData.findUsages.kotlin.propertyFiles.propertyUsagesByRef.2") key: String) = key
|
||||
public fun message(@PropertyKey(resourceBundle = "propertyUsagesByRef.2") key: String) = key
|
||||
|
||||
fun test() {
|
||||
message("<caret>foo.bar")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
private val BUNDLE_NAME = "idea.testData.findUsages.propertyFiles.propertyFileUsages.0"
|
||||
private val BUNDLE_NAME = "propertyFileUsages.0"
|
||||
|
||||
public fun message(@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyFileUsages.0") key: String) = key
|
||||
public fun message(@PropertyKey(resourceBundle = "propertyFileUsages.0") key: String) = key
|
||||
public fun message2(@PropertyKey(resourceBundle = BUNDLE_NAME) key: String) = key
|
||||
|
||||
fun test() {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Usage in string constants 3 private val BUNDLE_NAME = "idea.testData.findUsages.propertyFiles.propertyFileUsages.0"
|
||||
Usage in string constants 5 public fun message(@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyFileUsages.0") key: String) = key
|
||||
Usage in string constants 3 private val BUNDLE_NAME = "propertyFileUsages.0"
|
||||
Usage in string constants 5 public fun message(@PropertyKey(resourceBundle = "propertyFileUsages.0") key: String) = key
|
||||
@@ -1,20 +1,20 @@
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
|
||||
public fun message(@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") key: String) = key
|
||||
public fun message(@PropertyKey(resourceBundle = "propertyUsages.0") key: String) = key
|
||||
|
||||
public fun String.infixMessage(@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") key: String) = key
|
||||
public fun String.infixMessage(@PropertyKey(resourceBundle = "propertyUsages.0") key: String) = key
|
||||
|
||||
public fun @receiver:PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") String.infixMessage2(s: String) = this
|
||||
public fun @receiver:PropertyKey(resourceBundle = "propertyUsages.0") String.infixMessage2(s: String) = this
|
||||
|
||||
public fun @receiver:PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") String.unaryMinus() = this
|
||||
public fun @receiver:PropertyKey(resourceBundle = "propertyUsages.0") String.unaryMinus() = this
|
||||
|
||||
public fun Int.get(@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") key: String) = this
|
||||
public fun Int.get(@PropertyKey(resourceBundle = "propertyUsages.0") key: String) = this
|
||||
|
||||
public fun @receiver:PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") String.get(s: String) = this
|
||||
public fun @receiver:PropertyKey(resourceBundle = "propertyUsages.0") String.get(s: String) = this
|
||||
|
||||
fun test() {
|
||||
@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") val s1 = "foo.bar"
|
||||
@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") val s2 = "foo.baz"
|
||||
@PropertyKey(resourceBundle = "propertyUsages.0") val s1 = "foo.bar"
|
||||
@PropertyKey(resourceBundle = "propertyUsages.0") val s2 = "foo.baz"
|
||||
message("foo.bar")
|
||||
message("foo.baz")
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
void test() {
|
||||
@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") String s1 = "foo.bar"
|
||||
@PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") String s2 = "foo.baz"
|
||||
@PropertyKey(resourceBundle = "propertyUsages.0") String s1 = "foo.bar"
|
||||
@PropertyKey(resourceBundle = "propertyUsages.0") String s2 = "foo.baz"
|
||||
PropertyUsages_1Kt.message("foo.bar");
|
||||
PropertyUsages_1Kt.message("foo.baz");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[propertyUsages.1.kt] Usage in string constants 16 @PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") val s1 = "foo.bar"
|
||||
[propertyUsages.1.kt] Usage in string constants 16 @PropertyKey(resourceBundle = "propertyUsages.0") val s1 = "foo.bar"
|
||||
[propertyUsages.1.kt] Usage in string constants 18 message("foo.bar")
|
||||
[propertyUsages.1.kt] Usage in string constants 21 "test" infixMessage "foo.bar"
|
||||
[propertyUsages.1.kt] Usage in string constants 23 "foo.bar" infixMessage2 "test"
|
||||
@@ -6,5 +6,5 @@
|
||||
[propertyUsages.1.kt] Usage in string constants 26 -"foo.bar"
|
||||
[propertyUsages.1.kt] Usage in string constants 27 1["foo.bar"]
|
||||
[propertyUsages.1.kt] Usage in string constants 28 "foo.bar"["test"]
|
||||
[propertyUsages.2.java] Usage in string constants 3 @PropertyKey(resourceBundle = "idea.testData.findUsages.propertyFiles.propertyUsages.0") String s1 = "foo.bar"
|
||||
[propertyUsages.2.java] Usage in string constants 5 PropertyUsages_1Kt.message("foo.bar");
|
||||
[propertyUsages.2.java] Usage in string constants 3 @PropertyKey(resourceBundle = "propertyUsages.0") String s1 = "foo.bar"
|
||||
[propertyUsages.2.java] Usage in string constants 5 PropertyUsages_1Kt.message("foo.bar");
|
||||
@@ -64,11 +64,6 @@ abstract class AbstractFindUsagesTest : KotlinLightCodeInsightFixtureTestCase()
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE
|
||||
|
||||
public override fun setUp() {
|
||||
super.setUp()
|
||||
myFixture.testDataPath = PluginTestCaseBase.getTestDataPathBase() + "/findUsages"
|
||||
}
|
||||
|
||||
// used in Spring tests (outside main project!)
|
||||
protected open fun extraConfig(path: String) {
|
||||
}
|
||||
@@ -110,17 +105,13 @@ abstract class AbstractFindUsagesTest : KotlinLightCodeInsightFixtureTestCase()
|
||||
if (!name.startsWith(prefix) || name == mainFileName) return@listFiles false
|
||||
|
||||
val ext = FileUtilRt.getExtension(name)
|
||||
ext == "kt"
|
||||
|| ext == "java"
|
||||
|| ext == "xml"
|
||||
|| ext == "properties"
|
||||
|| ext == "txt" && !name.endsWith(".results.txt")
|
||||
ext in SUPPORTED_EXTENSIONS && !name.endsWith(".results.txt")
|
||||
}
|
||||
|
||||
for (file in extraFiles) {
|
||||
myFixture.configureByFile(rootPath + file.name)
|
||||
myFixture.configureByFile(file.name)
|
||||
}
|
||||
myFixture.configureByFile(path)
|
||||
myFixture.configureByFile(mainFileName)
|
||||
|
||||
val caretElement = if (InTextDirectivesUtils.isDirectiveDefined(mainFileText, "// FIND_BY_REF"))
|
||||
TargetElementUtilBase.findTargetElement(myFixture.editor,
|
||||
@@ -169,6 +160,10 @@ abstract class AbstractFindUsagesTest : KotlinLightCodeInsightFixtureTestCase()
|
||||
ExpressionsOfTypeProcessor.testLog = logList
|
||||
}
|
||||
|
||||
if (InTextDirectivesUtils.isDirectiveDefined(mainFileText, "// PLAIN_WHEN_NEEDED")) {
|
||||
ExpressionsOfTypeProcessor.mode = ExpressionsOfTypeProcessor.Mode.PLAIN_WHEN_NEEDED
|
||||
}
|
||||
|
||||
findUsages(caretElement, options, highlightingMode)
|
||||
}
|
||||
finally {
|
||||
@@ -176,6 +171,8 @@ abstract class AbstractFindUsagesTest : KotlinLightCodeInsightFixtureTestCase()
|
||||
if (logList.size > 0) {
|
||||
log = logList.sorted().joinToString("\n")
|
||||
}
|
||||
|
||||
ExpressionsOfTypeProcessor.mode = ExpressionsOfTypeProcessor.Mode.ALWAYS_SMART
|
||||
}
|
||||
|
||||
val filteringRules = instantiateClasses<UsageFilteringRule>(mainFileText, "// FILTERING_RULES: ")
|
||||
@@ -274,6 +271,7 @@ abstract class AbstractFindUsagesTest : KotlinLightCodeInsightFixtureTestCase()
|
||||
}
|
||||
|
||||
companion object {
|
||||
val SUPPORTED_EXTENSIONS = setOf("kt", "java", "xml", "properties", "txt", "groovy")
|
||||
|
||||
val USAGE_VIEW_PRESENTATION = UsageViewPresentation()
|
||||
|
||||
|
||||
@@ -1639,6 +1639,12 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("JavaWithGroovyInvoke.0.java")
|
||||
public void testJavaWithGroovyInvoke() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/java/findJavaMethodUsages/JavaWithGroovyInvoke.0.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("MismatchedAccessor.0.java")
|
||||
public void testMismatchedAccessor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/java/findJavaMethodUsages/MismatchedAccessor.0.java");
|
||||
|
||||
Reference in New Issue
Block a user