[lombok] ensure to search for fields/components with generated members in the same way as without

- but with additional secondary elements

Otherwise, kotlin usages won't be found, because no one would call MethodReferenceSearch.

Added test for kotlin+lombok setup, only k2

^KTIJ-29440 fixed

GitOrigin-RevId: a769e07571e34b8b07782f09254412c4466ad18a
This commit is contained in:
Anna Kozlova
2024-04-16 11:15:49 +02:00
committed by intellij-monorepo-bot
parent 06573f2b76
commit 16a9e35d3b
5 changed files with 69 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ package de.plushnikov.intellij.plugin.extension;
import com.intellij.find.findUsages.FindUsagesHandler;
import com.intellij.find.findUsages.FindUsagesHandlerFactory;
import com.intellij.find.findUsages.FindUsagesOptions;
import com.intellij.find.findUsages.JavaFindUsagesHelper;
import com.intellij.openapi.project.DumbService;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
@@ -9,6 +11,8 @@ import com.intellij.psi.PsiField;
import com.intellij.psi.PsiMember;
import com.intellij.psi.PsiRecordComponent;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.Processor;
import com.intellij.util.containers.ContainerUtil;
import de.plushnikov.intellij.plugin.psi.LombokLightClassBuilder;
import de.plushnikov.intellij.plugin.psi.LombokLightFieldBuilder;
@@ -44,6 +48,13 @@ public final class LombokFieldFindUsagesHandlerFactory extends FindUsagesHandler
@Override
public FindUsagesHandler createFindUsagesHandler(@NotNull PsiElement element, boolean forHighlightUsages) {
return new FindUsagesHandler(element) {
@Override
public boolean processElementUsages(@NotNull PsiElement element,
@NotNull Processor<? super UsageInfo> processor,
@NotNull FindUsagesOptions options) {
return JavaFindUsagesHelper.processElementUsages(element, options, processor);
}
@Override
public PsiElement @NotNull [] getSecondaryElements() {
final PsiMember psiMember = (PsiMember)getPsiElement();