Post-review fixes, added support for octal escaping definition for char
This commit is contained in:
@@ -312,11 +312,12 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
|||||||
val toIntIsNeeded = value != null && value.toString().toInt() < 0 && !isLongField(expression.parent)
|
val toIntIsNeeded = value != null && value.toString().toInt() < 0 && !isLongField(expression.parent)
|
||||||
text = if (value != null && !isHexLiteral(text)) value.toString() else text + (if (toIntIsNeeded) ".toInt()" else "")
|
text = if (value != null && !isHexLiteral(text)) value.toString() else text + (if (toIntIsNeeded) ".toInt()" else "")
|
||||||
}
|
}
|
||||||
|
if (typeStr == "java.lang.String" || typeStr == "char")
|
||||||
|
text = text.replace("\\\\([0-3]?[0-7]{1,2})".toRegex()) {
|
||||||
|
String.format("\\u%04x", Integer.parseInt(it.groupValues[1], 8))
|
||||||
|
}
|
||||||
|
|
||||||
if (typeStr == "java.lang.String") {
|
if (typeStr == "java.lang.String") {
|
||||||
text = text.replace("\\\\([0-3]?[0-7]{1,2})".toRegex(), {
|
|
||||||
String.format("\\u%04x", Integer.parseInt(it.groupValues[1], 8))
|
|
||||||
})
|
|
||||||
text = text.replace("\\$([A-Za-z]+|\\{)".toRegex(), "\\\\$0")
|
text = text.replace("\\$([A-Za-z]+|\\{)".toRegex(), "\\\\$0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
public class A {
|
||||||
|
public char a = '\77';
|
||||||
|
public char b = '\111';
|
||||||
|
public char c = '\377';
|
||||||
|
public char d = '\000';
|
||||||
|
public char f = '\0';
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class A {
|
||||||
|
var a = '\u003f'
|
||||||
|
var b = '\u0049'
|
||||||
|
var c = '\u00ff'
|
||||||
|
var d = '\u0000'
|
||||||
|
var f = '\u0000'
|
||||||
|
}
|
||||||
@@ -3178,6 +3178,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("charOctal.java")
|
||||||
|
public void testCharOctal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/literalExpression/charOctal.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("dollarInsideString.java")
|
@TestMetadata("dollarInsideString.java")
|
||||||
public void testDollarInsideString() throws Exception {
|
public void testDollarInsideString() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/literalExpression/dollarInsideString.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/literalExpression/dollarInsideString.java");
|
||||||
|
|||||||
@@ -3178,6 +3178,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("charOctal.java")
|
||||||
|
public void testCharOctal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/literalExpression/charOctal.java");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("dollarInsideString.java")
|
@TestMetadata("dollarInsideString.java")
|
||||||
public void testDollarInsideString() throws Exception {
|
public void testDollarInsideString() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/literalExpression/dollarInsideString.java");
|
String fileName = KotlinTestUtils.navigationMetadata("j2k/testData/fileOrElement/literalExpression/dollarInsideString.java");
|
||||||
|
|||||||
Reference in New Issue
Block a user