Remove unnecessary parentheses: don't suggest when parentheses are for lambda
This commit is contained in:
committed by
Mikhail Glukhikh
parent
05d8932fa6
commit
2010b1756e
@@ -448,7 +448,7 @@ public class KtPsiUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (innerExpression instanceof KtLambdaExpression) {
|
if (innerExpression instanceof KtLambdaExpression || innerExpression.getFirstChild() instanceof KtLambdaExpression) {
|
||||||
PsiElement prevSibling = PsiTreeUtil.skipWhitespacesAndCommentsBackward(currentInner);
|
PsiElement prevSibling = PsiTreeUtil.skipWhitespacesAndCommentsBackward(currentInner);
|
||||||
if (prevSibling != null && prevSibling.getText().endsWith(KtTokens.RPAR.getValue())) return true;
|
if (prevSibling != null && prevSibling.getText().endsWith(KtTokens.RPAR.getValue())) return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
foo()
|
||||||
|
<caret>({ foo() } )
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
foo()
|
||||||
|
<caret>({ foo() } as? () -> Unit)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
foo()
|
||||||
|
<caret>({ foo() }.invoke())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {}
|
||||||
@@ -14274,6 +14274,21 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/elvisRhsEmptyReturn.kt");
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/elvisRhsEmptyReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lambda.kt")
|
||||||
|
public void testLambda() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/lambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lambda2.kt")
|
||||||
|
public void testLambda2() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/lambda2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("lambda3.kt")
|
||||||
|
public void testLambda3() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/lambda3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("necessaryParentheses1.kt")
|
@TestMetadata("necessaryParentheses1.kt")
|
||||||
public void testNecessaryParentheses1() throws Exception {
|
public void testNecessaryParentheses1() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses1.kt");
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses1.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user