mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-168343 Suggest to change called method return type when used in return statement
This commit is contained in:
+5
-1
@@ -231,11 +231,15 @@ public class HighlightFixUtil {
|
||||
for (IntentionAction action : getChangeVariableTypeFixes(parameter, itemType)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, action);
|
||||
}
|
||||
registerChangeReturnTypeFix(highlightInfo, expr, parameter.getType());
|
||||
}
|
||||
|
||||
static void registerChangeReturnTypeFix(@NotNull HighlightInfo highlightInfo, @Nullable PsiExpression expr, @NotNull PsiType toType) {
|
||||
if (expr instanceof PsiMethodCallExpression) {
|
||||
final PsiMethod method = ((PsiMethodCallExpression)expr).resolveMethod();
|
||||
if (method != null) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, PriorityActionWrapper
|
||||
.lowPriority(method, QUICK_FIX_FACTORY.createMethodReturnFix(method, parameter.getType(), true)));
|
||||
.lowPriority(method, QUICK_FIX_FACTORY.createMethodReturnFix(method, toType, true)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -499,6 +499,7 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createWrapWithAdapterFix(lType, expression));
|
||||
AddTypeArgumentsConditionalFix.register(highlightInfo, expression, lType);
|
||||
HighlightFixUtil.registerCollectionToArrayFixAction(highlightInfo, rType, lType, expression);
|
||||
HighlightFixUtil.registerChangeReturnTypeFix(highlightInfo, expression, lType);
|
||||
}
|
||||
ChangeNewOperatorTypeFix.register(highlightInfo, expression, lType);
|
||||
return highlightInfo;
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Make 'bar' return 'java.lang.String'" "true"
|
||||
public class Foo {
|
||||
String foo() {
|
||||
return bar();
|
||||
}
|
||||
|
||||
String bar() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Make 'bar' return 'java.lang.String'" "true"
|
||||
public class Foo {
|
||||
String foo() {
|
||||
return <caret>bar();
|
||||
}
|
||||
|
||||
void bar() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user