extract method: allow to extract @NotNull code with missed branches which would be replaced with 'return null' with check on call site (IDEA-120076)

This commit is contained in:
Anna Kozlova
2014-11-27 18:12:53 +01:00
parent 6ff126e422
commit 83d3df6a95
6 changed files with 112 additions and 41 deletions
@@ -0,0 +1,32 @@
class Result {
private String _message;
public Result(String _message) {
this._message = _message;
}
}
class Main {
public static Result doIt(String name) {
Result result;
Result result = newMethod(name);
if (result != null) return result;
result = new Result("Name is " + name);
return result;
}
private static Result newMethod(String name) {
Result result;
if (name == null) {
result = new Result("Name is null");
return result;
}
if (name.length() == 0) {
result = new Result("Name is empty");
return result;
}
return null;
}
}