mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-178172 Good code is yellow: Inspection "@NotNull/@Nullable problems": @NotNull field with non-trivial setter
This commit is contained in:
+1
-1
@@ -407,7 +407,7 @@ public class NullableStuffInspectionBase extends BaseJavaBatchLocalInspectionToo
|
||||
|
||||
final PsiClass containingClass = field.getContainingClass();
|
||||
final PsiMethod setter = PropertyUtil.findPropertySetter(containingClass, propName, isStatic, false);
|
||||
if (setter != null && setter.isPhysical()) {
|
||||
if (setter != null && setter.isPhysical() && PropertyUtil.isSimpleSetter(setter)) {
|
||||
final PsiParameter[] parameters = setter.getParameterList().getParameters();
|
||||
assert parameters.length == 1 : setter.getText();
|
||||
final PsiParameter parameter = parameters[0];
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class Foo {
|
||||
private static final Long DEFAULT_ID = -1L;
|
||||
|
||||
@NotNull
|
||||
private Long id = DEFAULT_ID;
|
||||
|
||||
public Long getId() {
|
||||
return id > 0 ? id : 42;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id != null ? id : DEFAULT_ID;
|
||||
}
|
||||
}
|
||||
+2
@@ -98,6 +98,8 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase
|
||||
public void testNotNullAnnotationChecksInChildClassMethods() { doTest(); }
|
||||
|
||||
public void testGetterSetterProblems() { doTest(); }
|
||||
public void testNonTrivialGettersSetters() { doTest(); }
|
||||
|
||||
public void testOverriddenMethods() {
|
||||
myInspection.REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = true;
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user