mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inspections: report unused enum classes
for "Unused declaration" batch inspection GitOrigin-RevId: 04c25515d2cef8867823ea3659a4baab2167c58a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b0edf85f22
commit
d93f3a397d
@@ -170,13 +170,11 @@ public final class RefClassImpl extends RefJavaElementImpl implements RefClass {
|
||||
utilityClass = ClassUtils.isSingleton(psiClass);
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
if (varargConstructor != null && myDefaultConstructor == null) {
|
||||
setDefaultConstructor(varargConstructor);
|
||||
}
|
||||
if (myDefaultConstructor == null && varargConstructor != null) {
|
||||
setDefaultConstructor(varargConstructor);
|
||||
}
|
||||
|
||||
if (!isInterface() && !isAnonymous() && !isEnum() && !isRecord() && !constructorSeen) {
|
||||
if (!constructorSeen && !isInterface() && !isAnonymous()) {
|
||||
// implicit constructor is generated by javac when the class has no other constructor
|
||||
setDefaultConstructor(new RefImplicitConstructorImpl(this));
|
||||
}
|
||||
|
||||
|
||||
+16
-21
@@ -206,17 +206,7 @@ public final class RefJavaUtilImpl extends RefJavaUtil {
|
||||
}
|
||||
if (node.getKind() == UastCallKind.CONSTRUCTOR_CALL) {
|
||||
PsiElement resolvedMethod = returnToPhysical(node.resolve());
|
||||
RefMethod refConstructor = processNewLikeConstruct(resolvedMethod, node);
|
||||
|
||||
if (refConstructor == null) { // No explicit constructor referenced. Should use default one.
|
||||
UReferenceExpression reference = node.getClassReference();
|
||||
if (reference != null) {
|
||||
PsiElement constructorClass = reference.resolve();
|
||||
if (constructorClass instanceof PsiClass psiClass) {
|
||||
processClassReference(psiClass, true, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
processNewLikeConstruct(resolvedMethod, node);
|
||||
}
|
||||
try {
|
||||
node.getTypeArguments().forEach(this::visitTypeRefs);
|
||||
@@ -342,22 +332,27 @@ public final class RefJavaUtilImpl extends RefJavaUtil {
|
||||
refFrom.addReference(refFunctionalExpr, functionalExpr, decl, false, true, expression);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private RefMethod processNewLikeConstruct(PsiElement javaConstructor, UCallExpression call) {
|
||||
if (javaConstructor == null) return null;
|
||||
RefMethodImpl refConstructor =
|
||||
private void processNewLikeConstruct(PsiElement javaConstructor, UCallExpression call) {
|
||||
RefMethodImpl refConstructor = javaConstructor == null ? null :
|
||||
ObjectUtils.tryCast(refManager.getReference(javaConstructor.getOriginalElement()), RefMethodImpl.class);
|
||||
refFrom.addReference(refConstructor, javaConstructor, decl, false, true, null);
|
||||
|
||||
for (UExpression arg : call.getValueArguments()) {
|
||||
arg.accept(this);
|
||||
}
|
||||
|
||||
if (refConstructor != null) {
|
||||
refConstructor.initializeIfNeeded();
|
||||
refFrom.addReference(refConstructor, javaConstructor, decl, false, true, call);
|
||||
refConstructor.updateParameterValues(call, javaConstructor);
|
||||
}
|
||||
return refConstructor;
|
||||
else {
|
||||
UReferenceExpression reference = call.getClassReference();
|
||||
if (reference != null) {
|
||||
PsiElement constructorClass = reference.resolve();
|
||||
if (constructorClass instanceof PsiClass psiClass) {
|
||||
processClassReference(psiClass, true, call);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (UExpression arg : call.getValueArguments()) {
|
||||
arg.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>1</line>
|
||||
<description>Class has 2 instantiations, but they are not reachable from entry points.</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>2</line>
|
||||
|
||||
@@ -23,6 +23,13 @@
|
||||
<description>Field has no usages.</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TC.kt</file>
|
||||
<line>10</line>
|
||||
<entry_point TYPE="class" FQNAME="Nullability" />
|
||||
<description>Class has 3 instantiations, but they are not reachable from entry points.</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>TC.kt</file>
|
||||
<line>11</line>
|
||||
|
||||
Reference in New Issue
Block a user