mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 18:28:55 +07:00
Java: Unused Declaration - recognize resource expressions in batch mode (IDEA-330141)
GitOrigin-RevId: b382042eeb7b90301f4de90456da51026e045200
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0f3bc83e7a
commit
8a3ec7ba0d
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.codeInspection.reference;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil;
|
||||
@@ -78,11 +78,12 @@ public class RefJavaUtilImpl extends RefJavaUtil {
|
||||
for (PsiType parameter : classType.getParameters()) {
|
||||
parameter.accept(this);
|
||||
}
|
||||
UClass target = UastContextKt.toUElement(classType.resolve(), UClass.class);
|
||||
PsiClass aClass = classType.resolve();
|
||||
UClass target = UastContextKt.toUElement(aClass, UClass.class);
|
||||
if (target != null) {
|
||||
final RefElement refElement = refManager.getReference(target.getSourcePsi());
|
||||
if (refElement != null) refElement.initializeIfNeeded();
|
||||
refFrom.addReference(refElement, target.getSourcePsi(), decl, false, true, null);
|
||||
refFrom.addReference(refElement, aClass, decl, false, true, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -188,6 +189,27 @@ public class RefJavaUtilImpl extends RefJavaUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitTryExpression(@NotNull UTryExpression node) {
|
||||
// hack to workaround the problem that UAST does not support resource expressions IDEA-337821
|
||||
PsiTryStatement tryStatement = (PsiTryStatement)node.getJavaPsi();
|
||||
if (tryStatement != null) {
|
||||
PsiResourceList resourceList = tryStatement.getResourceList();
|
||||
if (resourceList != null) {
|
||||
for (PsiResourceListElement resourceListElement : resourceList) {
|
||||
if (resourceListElement instanceof PsiResourceExpression rExpression) {
|
||||
PsiExpression expression = rExpression.getExpression();
|
||||
UElement uElement = UastContextKt.toUElement(expression);
|
||||
if (uElement instanceof UExpression exp) {
|
||||
exp.accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void visitReferenceExpression(@NotNull UExpression node) {
|
||||
UElement uastParent = node.getUastParent();
|
||||
if (uastParent instanceof UQualifiedReferenceExpression qualifiedReference && qualifiedReference.getSelector() == node) {
|
||||
|
||||
Reference in New Issue
Block a user