New J2K: fix converting multiline comment with /* inside
#KT-18001 fixed #KT-35081 fixed
This commit is contained in:
@@ -21,9 +21,10 @@ internal class JKCommentPrinter(val printer: JKPrinter) {
|
|||||||
if (this !in printedTokens) {
|
if (this !in printedTokens) {
|
||||||
printedTokens += this
|
printedTokens += this
|
||||||
|
|
||||||
// hack till #KT-16845 is fixed
|
// hack till #KT-16845, #KT-23333 are fixed
|
||||||
if (!isSingleline && text.endsWith("/*/")) {
|
if (!isSingleline && text.lastIndexOf("/*") != text.indexOf("/*")) {
|
||||||
text.replaceRange(text.length - "/*/".length, text.length, "/ */")
|
text.replace("/*", "/ *")
|
||||||
|
.replaceFirst("/ *", "/*")
|
||||||
} else text
|
} else text
|
||||||
} else null
|
} else null
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
/* comment
|
||||||
|
*/
|
||||||
|
class A
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
/** / B
|
||||||
|
*/
|
||||||
|
class B
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
/** / C
|
||||||
|
/*/
|
||||||
|
class C
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* / * comment
|
||||||
|
*/
|
||||||
|
internal class A
|
||||||
|
|
||||||
|
/**
|
||||||
|
* / ** / B
|
||||||
|
*/
|
||||||
|
internal class B
|
||||||
|
|
||||||
|
/**
|
||||||
|
* / ** / C
|
||||||
|
* / */
|
||||||
|
internal class C
|
||||||
+5
@@ -1030,6 +1030,11 @@ public class NewJavaToKotlinConverterSingleFileTestGenerated extends AbstractNew
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("nj2k/testData/newJ2k/comments"), Pattern.compile("^([^\\.]+)\\.java$"), null, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("nj2k/testData/newJ2k/comments"), Pattern.compile("^([^\\.]+)\\.java$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("beginningOfCommentInsideMultilineOne.java")
|
||||||
|
public void testBeginningOfCommentInsideMultilineOne() throws Exception {
|
||||||
|
runTest("nj2k/testData/newJ2k/comments/beginningOfCommentInsideMultilineOne.java");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("commentInsideCall.java")
|
@TestMetadata("commentInsideCall.java")
|
||||||
public void testCommentInsideCall() throws Exception {
|
public void testCommentInsideCall() throws Exception {
|
||||||
runTest("nj2k/testData/newJ2k/comments/commentInsideCall.java");
|
runTest("nj2k/testData/newJ2k/comments/commentInsideCall.java");
|
||||||
|
|||||||
Reference in New Issue
Block a user