Fix for KT-14248 J2K: Invalid constructor formatting after conversion
Caused by `\n\n long mLong = 0;` leading line breaks
This commit is contained in:
@@ -660,7 +660,7 @@ class Converter private constructor(
|
||||
result = Identifier.toKotlin(codeRefElement.referenceName!!) + "." + result
|
||||
qualifier = codeRefElement.qualifier
|
||||
}
|
||||
return ReferenceElement(Identifier.withNoPrototype(result), typeArgs).assignPrototype(element)
|
||||
return ReferenceElement(Identifier.withNoPrototype(result), typeArgs).assignPrototype(element, CommentsAndSpacesInheritance.NO_SPACES)
|
||||
}
|
||||
else {
|
||||
if (!hasExternalQualifier) {
|
||||
@@ -668,12 +668,12 @@ class Converter private constructor(
|
||||
if (targetClass != null) {
|
||||
val identifier = constructNestedClassReferenceIdentifier(targetClass, specialContext ?: element)
|
||||
if (identifier != null) {
|
||||
return ReferenceElement(identifier, typeArgs).assignPrototype(element)
|
||||
return ReferenceElement(identifier, typeArgs).assignPrototype(element, CommentsAndSpacesInheritance.NO_SPACES)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ReferenceElement(Identifier.withNoPrototype(element.referenceName!!), typeArgs).assignPrototype(element)
|
||||
return ReferenceElement(Identifier.withNoPrototype(element.referenceName!!), typeArgs).assignPrototype(element, CommentsAndSpacesInheritance.NO_SPACES)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class TypeConverter(val converter: Converter) {
|
||||
else {
|
||||
convertType(variable.type, variableNullability(variable), variableMutability(variable))
|
||||
}
|
||||
return result.assignPrototype(variable.typeElement)
|
||||
return result.assignPrototype(variable.typeElement, CommentsAndSpacesInheritance.NO_SPACES)
|
||||
}
|
||||
|
||||
fun convertMethodReturnType(method: PsiMethod): Type
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
public class AppInfo {
|
||||
|
||||
long mLastUpdateTime;
|
||||
|
||||
String mName;
|
||||
|
||||
String mIcon;
|
||||
|
||||
public AppInfo(String name, String icon, long lastUpdateTime) {
|
||||
mName = name;
|
||||
mIcon = icon;
|
||||
mLastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
class AppInfo(internal var mName: String, internal var mIcon: String, internal var mLastUpdateTime: Long)
|
||||
|
||||
@@ -2860,6 +2860,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt-14248.java")
|
||||
public void testKt_14248() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-14248.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt-5294.java")
|
||||
public void testKt_5294() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-5294.java");
|
||||
|
||||
@@ -2860,6 +2860,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt-14248.java")
|
||||
public void testKt_14248() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-14248.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt-5294.java")
|
||||
public void testKt_5294() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/issues/kt-5294.java");
|
||||
|
||||
Reference in New Issue
Block a user