Fix unused declaration record false positives in batch inspection (IDEA-293902)

GitOrigin-RevId: 9f6e745abc93560315c708cf3e6806f86533ac1e
This commit is contained in:
Bas Leijdekkers
2022-05-26 14:49:21 +02:00
committed by intellij-monorepo-bot
parent a7e54c330d
commit ae88c6cbb4
9 changed files with 110 additions and 11 deletions

View File

@@ -167,7 +167,11 @@ public class RefJavaUtilImpl extends RefJavaUtil {
visitClass(((UObjectLiteralExpression)node).getDeclaration());
}
if (node.getKind() == UastCallKind.CONSTRUCTOR_CALL) {
PsiMethod resolvedMethod = node.resolve();
PsiElement resolvedMethod = node.resolve();
if (resolvedMethod instanceof LightElement) {
UElement uElement = UastContextKt.toUElement(resolvedMethod);
resolvedMethod = uElement == null ? null : uElement.getSourcePsi();
}
final List<UExpression> argumentList = node.getValueArguments();
RefMethod refConstructor = processNewLikeConstruct(resolvedMethod, argumentList);
@@ -295,9 +299,10 @@ public class RefJavaUtilImpl extends RefJavaUtil {
}
@Nullable
private RefMethod processNewLikeConstruct(final PsiMethod javaConstructor, final List<UExpression> argumentList) {
private RefMethod processNewLikeConstruct(PsiElement javaConstructor, List<UExpression> argumentList) {
if (javaConstructor == null) return null;
RefMethodImpl refConstructor = (RefMethodImpl)refManager.getReference(javaConstructor.getOriginalElement());
RefMethodImpl refConstructor =
ObjectUtils.tryCast(refManager.getReference(javaConstructor.getOriginalElement()), RefMethodImpl.class);
refFrom.addReference(refConstructor, javaConstructor, decl, false, true, null);
for (UExpression arg : argumentList) {