mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-185819 Operator ! cannot be applied to void: add a quick-fix
This commit is contained in:
+6
@@ -1430,6 +1430,12 @@ public class HighlightUtil extends HighlightUtilBase {
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parentExpr).descriptionAndTooltip(message).create();
|
||||
if (parentExpr instanceof PsiPrefixExpression && token.getTokenType() == JavaTokenType.EXCL) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createNegationBroadScopeFix((PsiPrefixExpression)parentExpr));
|
||||
if (expression instanceof PsiMethodCallExpression) {
|
||||
PsiMethod method = ((PsiMethodCallExpression)expression).resolveMethod();
|
||||
if (method != null) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.BOOLEAN, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
return highlightInfo;
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Make 'victim' return 'boolean'" "true"
|
||||
class Test {
|
||||
public void trigger() {
|
||||
if (!victim()) {
|
||||
System.out.println("***");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean victim() {
|
||||
final int something = 1;
|
||||
final boolean value = false;
|
||||
int another = 10;
|
||||
final boolean secondBoolean = another == something;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Make 'victim' return 'boolean'" "true"
|
||||
class Test {
|
||||
public void trigger() {
|
||||
if (!<caret>victim()) {
|
||||
System.out.println("***");
|
||||
}
|
||||
}
|
||||
|
||||
public void victim() {
|
||||
final int something = 1;
|
||||
final boolean value = false;
|
||||
int another = 10;
|
||||
final boolean secondBoolean = another == something;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user