J2K: convert comments inside qualified expression correctly
This commit is contained in:
@@ -10,3 +10,4 @@
|
||||
### Tools. J2K
|
||||
- Protected members used outside of inheritors are converted as public
|
||||
- Support conversion for annotation constructor calls
|
||||
- Place comments from the middle of the call to the end
|
||||
@@ -413,10 +413,17 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
}
|
||||
}
|
||||
|
||||
result = MethodCallExpression(codeConverter.convertExpression(methodExpr),
|
||||
/* We move prototypes from methodExpression to full expression because
|
||||
* it could contains comments inside, and then we paste them at the end of expression
|
||||
* In the case of call, we should paste them after parenthesis
|
||||
* ex. Foo./*comment*/bar() -> Foo.bar() /*comment*/
|
||||
*/
|
||||
val methodExpression = codeConverter.convertExpression(methodExpr)
|
||||
result = MethodCallExpression(methodExpression,
|
||||
convertArguments(expression),
|
||||
typeArguments,
|
||||
isNullable)
|
||||
isNullable).assignPrototypesFrom(methodExpression)
|
||||
methodExpression.assignNoPrototype()
|
||||
}
|
||||
|
||||
private fun KtLightMethod.isKotlinExtensionFunction(): Boolean {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package test;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
System.out
|
||||
// Comment
|
||||
.println();
|
||||
|
||||
Test
|
||||
// Comment1
|
||||
.foo()
|
||||
// Comment2
|
||||
.indexOf("s")
|
||||
}
|
||||
|
||||
public static String foo() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
object Test {
|
||||
@JvmStatic fun main(args: Array<String>) {
|
||||
println()// Comment
|
||||
|
||||
Test.foo()// Comment1
|
||||
.indexOf("s")// Comment2
|
||||
}
|
||||
|
||||
fun foo(): String {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
@@ -973,6 +973,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("j2k/testData/fileOrElement/comments"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("commentInsideCall.java")
|
||||
public void testCommentInsideCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/comments/commentInsideCall.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("comments.java")
|
||||
public void testComments() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/comments/comments.java");
|
||||
|
||||
@@ -973,6 +973,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("j2k/testData/fileOrElement/comments"), Pattern.compile("^(.+)\\.java$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("commentInsideCall.java")
|
||||
public void testCommentInsideCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/comments/commentInsideCall.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("comments.java")
|
||||
public void testComments() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/comments/comments.java");
|
||||
|
||||
Reference in New Issue
Block a user