mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
report non-annotated constructor parameter for final @Nullable/@NotNull fields
This commit is contained in:
+5
-3
@@ -44,6 +44,7 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.Query;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -173,9 +174,9 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
new AddAnnotationFix(anno, parameter, ArrayUtil.toStringArray(annoToRemove)));
|
||||
}
|
||||
}
|
||||
if (containingClass == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (containingClass != null) {
|
||||
final PsiMethod[] constructors = containingClass.getConstructors();
|
||||
final Query<PsiReference> search = ReferencesSearch.search(field, new LocalSearchScope(constructors), false);
|
||||
search.forEach(new Processor<PsiReference>() {
|
||||
@@ -246,6 +247,7 @@ public class NullableStuffInspection extends BaseLocalInspectionTool {
|
||||
LOG.assertTrue(parameter.isPhysical(), setter.getText());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiAssignmentExpression getAssignmentExpressionIfOnAssignmentLefthand(PsiExpression expression) {
|
||||
PsiElement parent = PsiTreeUtil.skipParentsOfType(expression, PsiParenthesizedExpression.class);
|
||||
if (!(parent instanceof PsiAssignmentExpression)) {
|
||||
|
||||
@@ -62,4 +62,12 @@
|
||||
<description>Constructor parameter for @NotNull field might be annotated @NotNull itself</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>63</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@NotNull/@Nullable problems</problem_class>
|
||||
<description>Constructor parameter for @NotNull field might be annotated @NotNull itself</description>
|
||||
</problem>
|
||||
|
||||
|
||||
</problems>
|
||||
|
||||
+9
@@ -55,4 +55,13 @@ class D {
|
||||
D(long l) {
|
||||
myL = l;
|
||||
}
|
||||
}
|
||||
|
||||
class E {
|
||||
final @NotNull C c;
|
||||
|
||||
E(C c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user