mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
BoolUtils: fixed for erroneous but parseable expression !()
This commit is contained in:
+4
-4
@@ -58,7 +58,8 @@ public class BoolUtils {
|
||||
return null;
|
||||
}
|
||||
final PsiExpression operand = prefixExpression.getOperand();
|
||||
return ParenthesesUtils.stripParentheses(operand);
|
||||
PsiExpression stripped = ParenthesesUtils.stripParentheses(operand);
|
||||
return stripped == null ? operand : stripped;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -95,10 +96,9 @@ public class BoolUtils {
|
||||
}
|
||||
if (isNegation(expression)) {
|
||||
final PsiExpression negated = getNegated(expression);
|
||||
if (negated == null) {
|
||||
return "";
|
||||
if (negated != null) {
|
||||
return ParenthesesUtils.getText(tracker.markUnchanged(negated), precedence);
|
||||
}
|
||||
return ParenthesesUtils.getText(tracker.markUnchanged(negated), precedence);
|
||||
}
|
||||
if (expression instanceof PsiPolyadicExpression) {
|
||||
final PsiPolyadicExpression polyadicExpression = (PsiPolyadicExpression)expression;
|
||||
|
||||
+13
@@ -15,4 +15,17 @@ public class FlipConditionalIntentionTest extends IPPTestCase {
|
||||
"class X { void test(boolean foo, boolean bar) { boolean c = false; boolean b = !foo ? c || bar : true;//comment at the end\n" +
|
||||
" }}");
|
||||
}
|
||||
|
||||
public void testIncomplete() {
|
||||
doTest("class X {\n" +
|
||||
" void test() {\n" +
|
||||
" System.out.println(/*_Flip '?:'*/!()?\"foo\":\"bar\");\n" +
|
||||
" }\n" +
|
||||
"}",
|
||||
"class X {\n" +
|
||||
" void test() {\n" +
|
||||
" System.out.println(() ? \"bar\" : \"foo\");\n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user