mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
create field from parameter: when field would be final and parameter is NotNull then the field should be also @NotNull (IDEA-74136)
This commit is contained in:
+2
@@ -218,6 +218,8 @@ public class CreateFieldFromParameterAction implements IntentionAction {
|
||||
final NullableNotNullManager manager = NullableNotNullManager.getInstance(project);
|
||||
if (manager.isNullable(myParameter, false)) {
|
||||
modifierList.addAfter(factory.createAnnotationFromText("@" + manager.getDefaultNullable(), field), null);
|
||||
} else if (isFinal && manager.isNotNull(myParameter, false)) {
|
||||
modifierList.addAfter(factory.createAnnotationFromText("@" + manager.getDefaultNotNull(), field), null);
|
||||
}
|
||||
|
||||
PsiCodeBlock methodBody = method.getBody();
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Create Field For Parameter 'name'" "true"
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TestBefore {
|
||||
|
||||
@NotNull
|
||||
private final String myName;
|
||||
|
||||
public TestBefore(@NotNull String name) {
|
||||
super();
|
||||
myName = name;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Create Field For Parameter 'name'" "true"
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TestBefore {
|
||||
|
||||
public TestBefore(@NotNull String name<caret>) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user