Fix deleting of semicolon when it required to mark statement empty
#KT-18142 fixed #KT-18141 fixed
This commit is contained in:
@@ -69,6 +69,9 @@ class IfStatement(
|
|||||||
if (!elseStatement.isEmpty) {
|
if (!elseStatement.isEmpty) {
|
||||||
builder append br append "else" append brAfterElse append elseStatement.wrapToBlockIfRequired()
|
builder append br append "else" append brAfterElse append elseStatement.wrapToBlockIfRequired()
|
||||||
}
|
}
|
||||||
|
else if (thenStatement.isEmpty) {
|
||||||
|
builder append ";"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +82,9 @@ class WhileStatement(val condition: Expression, val body: Element, singleLine: B
|
|||||||
|
|
||||||
override fun generateCode(builder: CodeBuilder) {
|
override fun generateCode(builder: CodeBuilder) {
|
||||||
builder append "while (" append condition append ")" append br append body.wrapToBlockIfRequired()
|
builder append "while (" append condition append ")" append br append body.wrapToBlockIfRequired()
|
||||||
|
if (body.isEmpty) {
|
||||||
|
builder append ";"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +112,9 @@ class ForeachStatement(
|
|||||||
builder append ":" append explicitVariableType
|
builder append ":" append explicitVariableType
|
||||||
}
|
}
|
||||||
builder append " in " append collection append ")" append br append body.wrapToBlockIfRequired()
|
builder append " in " append collection append ")" append br append body.wrapToBlockIfRequired()
|
||||||
|
if (body.isEmpty) {
|
||||||
|
builder append ";"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
public class A {
|
||||||
|
public void aVoid() {
|
||||||
|
for (int i = 0; i < 10; i++);
|
||||||
|
System.out.println("Done");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class A {
|
||||||
|
fun aVoid() {
|
||||||
|
for (i in 0..9);
|
||||||
|
println("Done")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
public class A {
|
||||||
|
public void aVoid() {
|
||||||
|
int[] array = new int[10];
|
||||||
|
|
||||||
|
for (int i : array);
|
||||||
|
System.out.println("Done");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class A {
|
||||||
|
fun aVoid() {
|
||||||
|
val array = IntArray(10)
|
||||||
|
|
||||||
|
for (i in array);
|
||||||
|
println("Done")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
public class A {
|
||||||
|
public void aVoid() {
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
if (i > 10);
|
||||||
|
System.out.println("Done");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class A {
|
||||||
|
fun aVoid() {
|
||||||
|
val i = 0
|
||||||
|
|
||||||
|
if (i > 10);
|
||||||
|
println("Done")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
public class A {
|
||||||
|
public void aVoid() {
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while(i++ < 10);
|
||||||
|
System.out.println("Done");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class A {
|
||||||
|
fun aVoid() {
|
||||||
|
var i = 0
|
||||||
|
|
||||||
|
while (i++ < 10);
|
||||||
|
println("Done")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2288,6 +2288,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("forWithoutBody.java")
|
||||||
|
public void testForWithoutBody() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/for/forWithoutBody.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("indicesReversed.java")
|
@TestMetadata("indicesReversed.java")
|
||||||
public void testIndicesReversed() throws Exception {
|
public void testIndicesReversed() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/for/indicesReversed.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/for/indicesReversed.java");
|
||||||
@@ -2399,6 +2405,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("foreachWithoutBody.java")
|
||||||
|
public void testForeachWithoutBody() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/foreachStatement/foreachWithoutBody.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nullableIterable.java")
|
@TestMetadata("nullableIterable.java")
|
||||||
public void testNullableIterable() throws Exception {
|
public void testNullableIterable() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/foreachStatement/nullableIterable.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/foreachStatement/nullableIterable.java");
|
||||||
@@ -2723,6 +2735,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ifWithoutThen.java")
|
||||||
|
public void testIfWithoutThen() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/ifStatement/ifWithoutThen.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("multiLine.java")
|
@TestMetadata("multiLine.java")
|
||||||
public void testMultiLine() throws Exception {
|
public void testMultiLine() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/ifStatement/multiLine.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/ifStatement/multiLine.java");
|
||||||
@@ -5095,5 +5113,11 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/whileStatement/whileWithReturn.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/whileStatement/whileWithReturn.java");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("whileWithoutBody.java")
|
||||||
|
public void testWhileWithoutBody() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/whileStatement/whileWithoutBody.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2288,6 +2288,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("forWithoutBody.java")
|
||||||
|
public void testForWithoutBody() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/for/forWithoutBody.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("indicesReversed.java")
|
@TestMetadata("indicesReversed.java")
|
||||||
public void testIndicesReversed() throws Exception {
|
public void testIndicesReversed() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/for/indicesReversed.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/for/indicesReversed.java");
|
||||||
@@ -2399,6 +2405,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("foreachWithoutBody.java")
|
||||||
|
public void testForeachWithoutBody() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/foreachStatement/foreachWithoutBody.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nullableIterable.java")
|
@TestMetadata("nullableIterable.java")
|
||||||
public void testNullableIterable() throws Exception {
|
public void testNullableIterable() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/foreachStatement/nullableIterable.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/foreachStatement/nullableIterable.java");
|
||||||
@@ -2723,6 +2735,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ifWithoutThen.java")
|
||||||
|
public void testIfWithoutThen() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/ifStatement/ifWithoutThen.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("multiLine.java")
|
@TestMetadata("multiLine.java")
|
||||||
public void testMultiLine() throws Exception {
|
public void testMultiLine() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/ifStatement/multiLine.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/ifStatement/multiLine.java");
|
||||||
@@ -5095,5 +5113,11 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/whileStatement/whileWithReturn.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/whileStatement/whileWithReturn.java");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("whileWithoutBody.java")
|
||||||
|
public void testWhileWithoutBody() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/whileStatement/whileWithoutBody.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user