mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-232559 Rename record component: field reference is not renamed if getter overload is present
GitOrigin-RevId: 1555b2079dbba1b92d83c0638e5845efca910dc5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e08eb714bd
commit
13edb2f136
+5
-3
@@ -13,6 +13,8 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JavaRecordComponentSearcher extends QueryExecutorBase<PsiReference, ReferencesSearch.SearchParameters> {
|
||||
@Override
|
||||
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull Processor<? super PsiReference> consumer) {
|
||||
@@ -50,8 +52,8 @@ public class JavaRecordComponentSearcher extends QueryExecutorBase<PsiReference,
|
||||
PsiClass containingClass = recordComponent.getContainingClass();
|
||||
if (containingClass == null) return null;
|
||||
|
||||
PsiMethod[] methods = containingClass.findMethodsByName(name, false);
|
||||
if (methods.length != 1) return null;
|
||||
List<PsiMethod> methods = ContainerUtil.filter(containingClass.findMethodsByName(name, false), m -> m.getParameterList().isEmpty());
|
||||
if (methods.size() != 1) return null;
|
||||
|
||||
PsiField field = containingClass.findFieldByName(name, false);
|
||||
if (field == null) return null;
|
||||
@@ -60,7 +62,7 @@ public class JavaRecordComponentSearcher extends QueryExecutorBase<PsiReference,
|
||||
PsiParameter parameter = compactConstructor != null
|
||||
? ContainerUtil.find(compactConstructor.getParameterList().getParameters(), p -> name.equals(p.getName()))
|
||||
: null;
|
||||
return new RecordNavigationInfo(methods[0], field, parameter, name);
|
||||
return new RecordNavigationInfo(methods.get(0), field, parameter, name);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Main {
|
||||
private record Rec(int <caret>x, int y) {
|
||||
public Rec(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
void x(int y) {}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Main {
|
||||
private record Rec(int <caret>baz, int y) {
|
||||
public Rec(int baz, int y) {
|
||||
this.baz = baz;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
void x(int y) {}
|
||||
}
|
||||
}
|
||||
+4
@@ -50,6 +50,10 @@ public class LightRecordsHighlightingTest extends LightJavaCodeInsightFixtureTes
|
||||
doTestRename();
|
||||
}
|
||||
|
||||
public void testRenameGetterOverloadPresent() {
|
||||
doTestRename();
|
||||
}
|
||||
|
||||
private void doTestRename() {
|
||||
doTest();
|
||||
myFixture.renameElementAtCaret("baz");
|
||||
|
||||
Reference in New Issue
Block a user