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) {
|
||||
printedTokens += this
|
||||
|
||||
// hack till #KT-16845 is fixed
|
||||
if (!isSingleline && text.endsWith("/*/")) {
|
||||
text.replaceRange(text.length - "/*/".length, text.length, "/ */")
|
||||
// hack till #KT-16845, #KT-23333 are fixed
|
||||
if (!isSingleline && text.lastIndexOf("/*") != text.indexOf("/*")) {
|
||||
text.replace("/*", "/ *")
|
||||
.replaceFirst("/ *", "/*")
|
||||
} else text
|
||||
} 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);
|
||||
}
|
||||
|
||||
@TestMetadata("beginningOfCommentInsideMultilineOne.java")
|
||||
public void testBeginningOfCommentInsideMultilineOne() throws Exception {
|
||||
runTest("nj2k/testData/newJ2k/comments/beginningOfCommentInsideMultilineOne.java");
|
||||
}
|
||||
|
||||
@TestMetadata("commentInsideCall.java")
|
||||
public void testCommentInsideCall() throws Exception {
|
||||
runTest("nj2k/testData/newJ2k/comments/commentInsideCall.java");
|
||||
|
||||
Reference in New Issue
Block a user