mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] visibility inspection: fix class references in annotation list (IDEA-279225)
GitOrigin-RevId: cb8bebcfdc0bde638a70ee8b67de29893af63033
This commit is contained in:
committed by
intellij-monorepo-bot
parent
196c7248db
commit
de9873d15d
+5
-13
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package com.intellij.codeInspection.visibility;
|
||||
|
||||
@@ -435,18 +435,10 @@ public final class VisibilityInspection extends GlobalJavaBatchInspectionTool {
|
||||
if (modifierList == null) return false;
|
||||
final PsiElement toElement = to.getPsiElement();
|
||||
|
||||
final boolean [] resolved = {false};
|
||||
modifierList.accept(new JavaRecursiveElementWalkingVisitor() {
|
||||
@Override
|
||||
public void visitReferenceExpression(PsiReferenceExpression expression) {
|
||||
if (resolved[0]) return;
|
||||
super.visitReferenceExpression(expression);
|
||||
if (expression.resolve() == toElement) {
|
||||
resolved[0] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
return resolved[0];
|
||||
return SyntaxTraverser.psiTraverser(modifierList)
|
||||
.filter(PsiJavaCodeReferenceElement.class)
|
||||
.filter(ref -> ref.isReferenceTo(toElement))
|
||||
.first() != null;
|
||||
}
|
||||
|
||||
private static boolean isInExtendsList(final RefJavaElement to, final PsiReferenceList extendsList) {
|
||||
|
||||
+9
-9
@@ -1,5 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
<problem>
|
||||
<file>ThisClass.java</file>
|
||||
<line>6</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Declaration access can be weaker</problem_class>
|
||||
<hints>
|
||||
<hint value="packageLocal" />
|
||||
</hints>
|
||||
<description>Can be package-private</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>ThisClass.java</file>
|
||||
<line>5</line>
|
||||
@@ -9,14 +18,5 @@
|
||||
</hints>
|
||||
<description>Can be package-private</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>ThisClass.java</file>
|
||||
<line>4</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Declaration access can be weaker</problem_class>
|
||||
<hints>
|
||||
<hint value="packageLocal" />
|
||||
</hints>
|
||||
<description>Can be package-private</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
|
||||
+5
@@ -1,9 +1,14 @@
|
||||
import java.util.ArrayList;
|
||||
@SuppressWarnings(ThisClass.PUBLICFINALNAME)
|
||||
@Anno(ThisClass.FFF)
|
||||
public class ThisClass extends ArrayList<ThisClass.FF> {
|
||||
public static final String PUBLICFINALNAME = "stuff";
|
||||
public static class FF {}
|
||||
static class FF {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
||||
@interface Anno {
|
||||
Class<?> value() default String.class;
|
||||
}
|
||||
Reference in New Issue
Block a user