mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] rename: skip additional search for parameter accessors
KTIJ-12718 GitOrigin-RevId: b929805701477e8f4a461fefd59f1fb0b83a0bc0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
72ba98bc92
commit
52ce573c1c
+5
@@ -230,6 +230,11 @@ public class RenameTestGenerated extends AbstractRenameTest {
|
||||
runTest("testData/refactoring/rename/dataClassPropertyWithJava/dataClassPropertyWithJava.test");
|
||||
}
|
||||
|
||||
@TestMetadata("dataClassValuePropertyWithJava/dataClassPropertyWithJava.test")
|
||||
public void testDataClassValuePropertyWithJava_DataClassPropertyWithJava() throws Exception {
|
||||
runTest("testData/refactoring/rename/dataClassValuePropertyWithJava/dataClassPropertyWithJava.test");
|
||||
}
|
||||
|
||||
@TestMetadata("enumGetEntriesFromJava/enumValueOf.test")
|
||||
public void testEnumGetEntriesFromJava_EnumValueOf() throws Exception {
|
||||
runTest("testData/refactoring/rename/enumGetEntriesFromJava/enumValueOf.test");
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class JavaClass {
|
||||
void test() {
|
||||
var a = new XYZ(1).getP1();
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
data class XYZ(val p1: Int, val y: Int) {
|
||||
operator fun component1(): Int = p1
|
||||
}
|
||||
|
||||
fun test(xyz: XYZ) {
|
||||
val (a, b) = xyz
|
||||
val c = a + b
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class JavaClass {
|
||||
void test() {
|
||||
var a = new XYZ(1).getValue();
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
data class XYZ(val /*rename*/value: Int, val y: Int) {
|
||||
operator fun component1(): Int = value
|
||||
}
|
||||
|
||||
fun test(xyz: XYZ) {
|
||||
val (a, b) = xyz
|
||||
val c = a + b
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "AUTO_DETECT",
|
||||
"mainFile": "test.kt",
|
||||
"newName": "p1",
|
||||
"withRuntime": "true",
|
||||
"enabledInK2": true
|
||||
}
|
||||
+9
-7
@@ -67,18 +67,20 @@ abstract class RenameKotlinPsiProcessor : RenamePsiElementProcessor() {
|
||||
searchParameters: KotlinReferencesSearchParameters
|
||||
): Collection<PsiReference> {
|
||||
val references = ReferencesSearch.search(searchParameters).asIterable().toMutableSet()
|
||||
if (element is KtNamedFunction || (element is KtProperty && !element.isLocal) || (element is KtParameter && element.hasValOrVar())) {
|
||||
if (element is KtNamedFunction || (element is KtProperty && !element.isLocal)) {
|
||||
// property accessors for parameters should be covered by KotlinReferencesSearcher.QueryProcessor.searchMethodAware
|
||||
element.toLightMethods().flatMapTo(references) { method ->
|
||||
if (element is KtParameter && DataClassResolver.isComponentLike(method.name)) {
|
||||
// renaming a data class property doesn't change the synthetic component name
|
||||
return@flatMapTo emptyList()
|
||||
}
|
||||
MethodReferencesSearch.search(
|
||||
// ReferenceSearch, called MethodUsagesSearcher#processQuery would still start operator conventions search
|
||||
// because kotlinOptions are lost during the call
|
||||
KotlinMethodReferencesSearchParameters(
|
||||
method,
|
||||
kotlinOptions = KotlinReferencesSearchOptions(
|
||||
acceptImportAlias = false
|
||||
)
|
||||
acceptImportAlias = false,
|
||||
searchForComponentConventions = false,
|
||||
searchForOperatorConventions = false,
|
||||
),
|
||||
scope = searchParameters.effectiveSearchScope,
|
||||
)
|
||||
).asIterable()
|
||||
}
|
||||
|
||||
+5
@@ -230,6 +230,11 @@ public class FirRenameTestGenerated extends AbstractFirRenameTest {
|
||||
runTest("../../idea/tests/testData/refactoring/rename/dataClassPropertyWithJava/dataClassPropertyWithJava.test");
|
||||
}
|
||||
|
||||
@TestMetadata("dataClassValuePropertyWithJava/dataClassPropertyWithJava.test")
|
||||
public void testDataClassValuePropertyWithJava_DataClassPropertyWithJava() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/rename/dataClassValuePropertyWithJava/dataClassPropertyWithJava.test");
|
||||
}
|
||||
|
||||
@TestMetadata("enumGetEntriesFromJava/enumValueOf.test")
|
||||
public void testEnumGetEntriesFromJava_EnumValueOf() throws Exception {
|
||||
runTest("../../idea/tests/testData/refactoring/rename/enumGetEntriesFromJava/enumValueOf.test");
|
||||
|
||||
Reference in New Issue
Block a user