This commit is contained in:
Sergey Ignatov
2011-11-23 13:30:07 +04:00
parent 75a4d34da7
commit f8aa6c727b
@@ -92,18 +92,18 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
return suite; return suite;
} }
void configureFromText(String text) throws IOException { static void configureFromText(String text) throws IOException {
configureFromFileText("test.java", text); configureFromFileText("test.java", text);
} }
@NotNull @NotNull
String fileToKotlin(String text) throws IOException { static String fileToKotlin(String text) throws IOException {
configureFromText(text); configureFromText(text);
return prettify(Converter.fileToFile((PsiJavaFile) myFile).toKotlin()); return prettify(Converter.fileToFile((PsiJavaFile) myFile).toKotlin());
} }
@NotNull @NotNull
String methodToKotlin(String text) throws IOException { static String methodToKotlin(String text) throws IOException {
String result = fileToKotlin("final class C {" + text + "}") String result = fileToKotlin("final class C {" + text + "}")
.replaceAll("class C\\(\\) \\{", ""); .replaceAll("class C\\(\\) \\{", "");
result = result.substring(0, result.lastIndexOf("}")); result = result.substring(0, result.lastIndexOf("}"));
@@ -111,7 +111,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
} }
@NotNull @NotNull
String statementToKotlin(String text) throws Exception { static String statementToKotlin(String text) throws Exception {
String result = methodToKotlin("void main() {" + text + "}"); String result = methodToKotlin("void main() {" + text + "}");
int pos = result.lastIndexOf("}"); int pos = result.lastIndexOf("}");
result = result.substring(0, pos).replaceFirst("open fun main\\(\\) : Unit \\{", ""); result = result.substring(0, pos).replaceFirst("open fun main\\(\\) : Unit \\{", "");
@@ -119,7 +119,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
} }
@NotNull @NotNull
String expressionToKotlin(String code) throws Exception { static String expressionToKotlin(String code) throws Exception {
String result = statementToKotlin("Object o =" + code + "}"); String result = statementToKotlin("Object o =" + code + "}");
result = result.replaceFirst("var o : Any\\? =", ""); result = result.replaceFirst("var o : Any\\? =", "");
return prettify(result); return prettify(result);