PSI: Add parentheses around annotated expressions in returns

#KT-8260 Fixed
This commit is contained in:
Alexey Sedunov
2015-06-26 14:19:25 +03:00
parent 8c9863e759
commit f6965b5004
6 changed files with 26 additions and 3 deletions
@@ -549,9 +549,8 @@ public class JetPsiUtil {
IElementType parentOperation = getOperation(parentExpression);
// 'return (@label{...})' case
if (parentExpression instanceof JetReturnExpression && innerExpression instanceof JetLabeledExpression) {
return true;
}
if (parentExpression instanceof JetReturnExpression
&& (innerExpression instanceof JetLabeledExpression || innerExpression instanceof JetAnnotatedExpression)) return true;
// '(x: Int) < y' case
if (innerExpression instanceof JetBinaryExpressionWithTypeRHS && parentOperation == JetTokens.LT) {
@@ -0,0 +1,3 @@
annotation class ann
fun foo(): Int = <caret>@ann 1
@@ -0,0 +1,5 @@
annotation class ann
fun foo(): Int {
return (@ann 1)
}
@@ -0,0 +1 @@
fun foo(): Int = <caret>ann@ 1
@@ -0,0 +1,3 @@
fun foo(): Int {
return (ann@ 1)
}
@@ -3523,6 +3523,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/convertToBlockBody"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("annotatedExpr.kt")
public void testAnnotatedExpr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/annotatedExpr.kt");
doTest(fileName);
}
@TestMetadata("explicitlyNonUnitFun.kt")
public void testExplicitlyNonUnitFun() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/explicitlyNonUnitFun.kt");
@@ -3589,6 +3595,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
doTest(fileName);
}
@TestMetadata("labeledExpr.kt")
public void testLabeledExpr() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/labeledExpr.kt");
doTest(fileName);
}
@TestMetadata("nothingFun.kt")
public void testNothingFun() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/nothingFun.kt");