PSI: Add parentheses around annotated expressions in returns
#KT-8260 Fixed
This commit is contained in:
@@ -549,9 +549,8 @@ public class JetPsiUtil {
|
|||||||
IElementType parentOperation = getOperation(parentExpression);
|
IElementType parentOperation = getOperation(parentExpression);
|
||||||
|
|
||||||
// 'return (@label{...})' case
|
// 'return (@label{...})' case
|
||||||
if (parentExpression instanceof JetReturnExpression && innerExpression instanceof JetLabeledExpression) {
|
if (parentExpression instanceof JetReturnExpression
|
||||||
return true;
|
&& (innerExpression instanceof JetLabeledExpression || innerExpression instanceof JetAnnotatedExpression)) return true;
|
||||||
}
|
|
||||||
|
|
||||||
// '(x: Int) < y' case
|
// '(x: Int) < y' case
|
||||||
if (innerExpression instanceof JetBinaryExpressionWithTypeRHS && parentOperation == JetTokens.LT) {
|
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);
|
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")
|
@TestMetadata("explicitlyNonUnitFun.kt")
|
||||||
public void testExplicitlyNonUnitFun() throws Exception {
|
public void testExplicitlyNonUnitFun() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/explicitlyNonUnitFun.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/explicitlyNonUnitFun.kt");
|
||||||
@@ -3589,6 +3595,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("nothingFun.kt")
|
||||||
public void testNothingFun() throws Exception {
|
public void testNothingFun() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/nothingFun.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/convertToBlockBody/nothingFun.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user