make method return: do not add return statement when control flow found a problem (IDEA-95738)

(cherry picked from commit b4e5b7d23c22f692da029a95d6718359fac577cc)
This commit is contained in:
anna
2012-11-23 21:14:46 +01:00
parent 5e713e4fd6
commit 0586625266
3 changed files with 33 additions and 1 deletions
@@ -167,7 +167,7 @@ public class MethodReturnTypeFix extends LocalQuickFixAndIntentionActionOnPsiEle
controlFlow = HighlightControlFlowUtil.getControlFlowNoConstantEvaluate(method.getBody());
}
catch (AnalysisCanceledException e) {
controlFlow = null; //must be an error
return null; //must be an error
}
PsiReturnStatement returnStatement;
if (controlFlow != null && ControlFlowUtil.processReturns(controlFlow, visitor)) {
@@ -0,0 +1,16 @@
// "Make 'getDrawerAppsList' return 'java.util.ArrayList<ResolveInfo>'" "true"
import java.util.*;
class Test {
public static ArrayList<ResolveInfo> getDrawerAppsList(ArrayList<ResolveInfo> appsList) {
for (ResolveInfo appInfo : appsList) {
if () {
appsList.remove(appInfo);
}
}
return appsList;
}
}
@@ -0,0 +1,16 @@
// "Make 'getDrawerAppsList' return 'java.util.ArrayList<ResolveInfo>'" "true"
import java.util.*;
class Test {
public static List<AppInfo> getDrawerAppsList(ArrayList<ResolveInfo> appsList) {
for (ResolveInfo appInfo : appsList) {
if () {
appsList.remove(appInfo);
}
}
return <caret>appsList;
}
}