J2K: preserving line breaks between parameters
This commit is contained in:
@@ -214,7 +214,11 @@ class ConstructorConverter(
|
||||
if (isVal(converter.referenceSearcher, field)) Parameter.VarValModifier.Val else Parameter.VarValModifier.Var,
|
||||
converter.convertAnnotations(parameter) + converter.convertAnnotations(field),
|
||||
accessModifiers,
|
||||
default).assignPrototypes(listOf(parameter, field), CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
|
||||
default)
|
||||
.assignPrototypes(
|
||||
PrototypeInfo(parameter, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS)),
|
||||
PrototypeInfo(field, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
|
||||
)
|
||||
}
|
||||
},
|
||||
correctCodeConverter = { correct() })
|
||||
|
||||
@@ -545,7 +545,7 @@ class Converter private constructor(
|
||||
Nullability.Nullable -> type = type.toNullableType()
|
||||
}
|
||||
return Parameter(parameter.declarationIdentifier(), type, varValModifier,
|
||||
convertAnnotations(parameter), modifiers, defaultValue).assignPrototype(parameter)
|
||||
convertAnnotations(parameter), modifiers, defaultValue).assignPrototype(parameter, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS))
|
||||
}
|
||||
|
||||
public fun convertIdentifier(identifier: PsiIdentifier?): Identifier {
|
||||
|
||||
@@ -24,8 +24,8 @@ fun <TElement: Element> TElement.assignPrototype(prototype: PsiElement?, inherit
|
||||
return this
|
||||
}
|
||||
|
||||
fun <TElement: Element> TElement.assignPrototypes(prototypes: List<PsiElement>, inheritance: CommentsAndSpacesInheritance): TElement {
|
||||
this.prototypes = prototypes.map { PrototypeInfo(it, inheritance) }
|
||||
fun <TElement: Element> TElement.assignPrototypes(vararg prototypes: PrototypeInfo): TElement {
|
||||
this.prototypes = prototypes.asList()
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
class C1 {
|
||||
C1(int arg1,
|
||||
int arg2,
|
||||
int arg3) {
|
||||
}
|
||||
|
||||
C1(int x,
|
||||
int y) {
|
||||
this(x, x + y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
class C2 {
|
||||
private int arg1;
|
||||
private int arg2;
|
||||
|
||||
C2(int arg1,
|
||||
int arg2,
|
||||
int arg3) {
|
||||
this.arg1 = arg1;
|
||||
this.arg2 = arg2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class C1(arg1: Int,
|
||||
arg2: Int,
|
||||
arg3: Int) {
|
||||
|
||||
constructor(x: Int,
|
||||
y: Int) : this(x, x + y, 0) {
|
||||
}
|
||||
}
|
||||
|
||||
class C2(private val arg1: Int,
|
||||
private val arg2: Int,
|
||||
arg3: Int)
|
||||
@@ -0,0 +1,19 @@
|
||||
class C {
|
||||
public void foo1(int p1, int p2) {
|
||||
}
|
||||
|
||||
public void foo2(
|
||||
int p1,
|
||||
int p2) {
|
||||
}
|
||||
|
||||
public void foo3(int p1,
|
||||
int p2) {
|
||||
}
|
||||
|
||||
public void foo4(
|
||||
int p1, int p2,
|
||||
int p3, int p4
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class C {
|
||||
public fun foo1(p1: Int, p2: Int) {
|
||||
}
|
||||
|
||||
public fun foo2(
|
||||
p1: Int,
|
||||
p2: Int) {
|
||||
}
|
||||
|
||||
public fun foo3(p1: Int,
|
||||
p2: Int) {
|
||||
}
|
||||
|
||||
public fun foo4(
|
||||
p1: Int, p2: Int,
|
||||
p3: Int, p4: Int) {
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
import java.util.*
|
||||
|
||||
class A<T> {
|
||||
fun foo(nonMutableCollection: Collection<String>, mutableCollection: MutableCollection<String>, mutableSet: MutableSet<T>, mutableMap: MutableMap<String, T>) {
|
||||
fun foo(nonMutableCollection: Collection<String>,
|
||||
mutableCollection: MutableCollection<String>,
|
||||
mutableSet: MutableSet<T>,
|
||||
mutableMap: MutableMap<String, T>) {
|
||||
mutableCollection.addAll(nonMutableCollection)
|
||||
mutableSet.add(mutableMap.remove("a"))
|
||||
}
|
||||
|
||||
@@ -1162,6 +1162,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lineBreaksBetweenParameters.java")
|
||||
public void testLineBreaksBetweenParameters() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("methodCallInFactoryFun.java")
|
||||
public void testMethodCallInFactoryFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/methodCallInFactoryFun.java");
|
||||
@@ -2224,6 +2230,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lineBreaksBetweenParameters.java")
|
||||
public void testLineBreaksBetweenParameters() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("main.java")
|
||||
public void testMain() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/main.java");
|
||||
|
||||
@@ -1162,6 +1162,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lineBreaksBetweenParameters.java")
|
||||
public void testLineBreaksBetweenParameters() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("methodCallInFactoryFun.java")
|
||||
public void testMethodCallInFactoryFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/methodCallInFactoryFun.java");
|
||||
@@ -2224,6 +2230,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lineBreaksBetweenParameters.java")
|
||||
public void testLineBreaksBetweenParameters() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("main.java")
|
||||
public void testMain() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/main.java");
|
||||
|
||||
Reference in New Issue
Block a user