KT-19355 fix for "Variable expected" error after J2K for increment/decrement of an object field
This commit is contained in:
committed by
Ilya Kirillov
parent
748e458ad7
commit
b8cce67d2e
@@ -534,9 +534,16 @@ public class KtPsiUtil {
|
|||||||
return ((KtBinaryExpression) parentElement).getRight() == currentInner;
|
return ((KtBinaryExpression) parentElement).getRight() == currentInner;
|
||||||
}
|
}
|
||||||
|
|
||||||
//'-(-x)' case
|
|
||||||
if (parentElement instanceof KtPrefixExpression && innerExpression instanceof KtPrefixExpression) {
|
if (parentElement instanceof KtPrefixExpression && innerExpression instanceof KtPrefixExpression) {
|
||||||
return innerOperation == parentOperation && (innerOperation == KtTokens.PLUS || innerOperation == KtTokens.MINUS);
|
// +(++x) or +(+x) case
|
||||||
|
if (parentOperation == KtTokens.PLUS) {
|
||||||
|
return innerOperation == KtTokens.PLUS || innerOperation == KtTokens.PLUSPLUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -(--x) or -(-x) case
|
||||||
|
if (parentOperation == KtTokens.MINUS) {
|
||||||
|
return innerOperation == KtTokens.MINUS || innerOperation == KtTokens.MINUSMINUS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
var x = 0
|
||||||
|
+<caret>(++x)
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// IS_APPLICABLE: false
|
||||||
|
var x = 0
|
||||||
|
-<caret>(--x)
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo() {
|
||||||
|
var x = 0
|
||||||
|
+<caret>(--x)
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo() {
|
||||||
|
var x = 0
|
||||||
|
+--x
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo() {
|
||||||
|
var x = 0
|
||||||
|
-<caret>(++x)
|
||||||
|
}
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
fun foo() {
|
||||||
|
var x = 0
|
||||||
|
-++x
|
||||||
|
}
|
||||||
@@ -14004,11 +14004,26 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses5.kt");
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses5.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("necessaryParentheses6.kt")
|
||||||
|
public void testNecessaryParentheses6() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses6.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("necessaryParentheses7.kt")
|
||||||
|
public void testNecessaryParentheses7() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/necessaryParentheses7.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("unnecessaryParentheses1.kt")
|
@TestMetadata("unnecessaryParentheses1.kt")
|
||||||
public void testUnnecessaryParentheses1() throws Exception {
|
public void testUnnecessaryParentheses1() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses1.kt");
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses1.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unnecessaryParentheses10.kt")
|
||||||
|
public void testUnnecessaryParentheses10() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses10.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("unnecessaryParentheses2.kt")
|
@TestMetadata("unnecessaryParentheses2.kt")
|
||||||
public void testUnnecessaryParentheses2() throws Exception {
|
public void testUnnecessaryParentheses2() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses2.kt");
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses2.kt");
|
||||||
@@ -14044,6 +14059,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt");
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses8.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unnecessaryParentheses9.kt")
|
||||||
|
public void testUnnecessaryParentheses9() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParentheses9.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("unnecessaryParenthesesWithComment.kt")
|
@TestMetadata("unnecessaryParenthesesWithComment.kt")
|
||||||
public void testUnnecessaryParenthesesWithComment() throws Exception {
|
public void testUnnecessaryParenthesesWithComment() throws Exception {
|
||||||
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt");
|
runTest("idea/testData/intentions/removeUnnecessaryParentheses/unnecessaryParenthesesWithComment.kt");
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
//expression
|
||||||
|
-(++i)+(++i)-(--i)+(--i)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-++i + ++i - --i + --i
|
||||||
+5
@@ -4080,6 +4080,11 @@ public class NewJavaToKotlinConverterSingleFileTestGenerated extends AbstractNew
|
|||||||
public void testParenthesized2() throws Exception {
|
public void testParenthesized2() throws Exception {
|
||||||
runTest("nj2k/testData/newJ2k/parenthesizedExpression/parenthesized2.java");
|
runTest("nj2k/testData/newJ2k/parenthesizedExpression/parenthesized2.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("parenthesized3.java")
|
||||||
|
public void testParenthesized3() throws Exception {
|
||||||
|
runTest("nj2k/testData/newJ2k/parenthesizedExpression/parenthesized3.java");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("nj2k/testData/newJ2k/polyadicExpression")
|
@TestMetadata("nj2k/testData/newJ2k/polyadicExpression")
|
||||||
|
|||||||
Reference in New Issue
Block a user