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:
anna
2011-09-13 20:23:49 +02:00
parent 99413d2494
commit b9f48882af
3 changed files with 26 additions and 0 deletions
@@ -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();
@@ -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;
}
}
@@ -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();
}
}