cleanup
This commit is contained in:
@@ -6,10 +6,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* @author ignatov
|
* @author ignatov
|
||||||
*/
|
*/
|
||||||
public class ForeachWithRangeStatement extends Statement {
|
public class ForeachWithRangeStatement extends Statement {
|
||||||
private Expression myStart;
|
private final Expression myStart;
|
||||||
private IdentifierImpl myIdentifier;
|
private final IdentifierImpl myIdentifier;
|
||||||
private Expression myEnd;
|
private final Expression myEnd;
|
||||||
private Statement myBody;
|
private final Statement myBody;
|
||||||
|
|
||||||
public ForeachWithRangeStatement(IdentifierImpl identifier, Expression start, Expression end, Statement body) {
|
public ForeachWithRangeStatement(IdentifierImpl identifier, Expression start, Expression end, Statement body) {
|
||||||
myStart = start;
|
myStart = start;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class IdentifierImpl extends Expression implements Identifier {
|
|||||||
return myIsNullable;
|
return myIsNullable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String ifNeedQuote(String name) {
|
private static String ifNeedQuote(String name) {
|
||||||
if (ONLY_KOTLIN_KEYWORDS.contains(name) || name.contains("$"))
|
if (ONLY_KOTLIN_KEYWORDS.contains(name) || name.contains("$"))
|
||||||
return quote(name);
|
return quote(name);
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ import java.util.List;
|
|||||||
* @author ignatov
|
* @author ignatov
|
||||||
*/
|
*/
|
||||||
public class AstUtil {
|
public class AstUtil {
|
||||||
private static String join(final String array[], final String delimiter) {
|
private AstUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String join(final String[] array, final String delimiter) {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
boolean haveDelimiter = (delimiter != null);
|
boolean haveDelimiter = (delimiter != null);
|
||||||
|
|
||||||
|
|||||||
@@ -92,18 +92,18 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
|
|||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void configureFromText(String text) throws IOException {
|
private static void configureFromText(String text) throws IOException {
|
||||||
configureFromFileText("test.java", text);
|
configureFromFileText("test.java", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
static String fileToKotlin(String text) throws IOException {
|
private 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
|
||||||
static String methodToKotlin(String text) throws IOException {
|
private 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
|
||||||
static String statementToKotlin(String text) throws Exception {
|
private 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("fun main\\(\\) : Unit \\{", "");
|
result = result.substring(0, pos).replaceFirst("fun main\\(\\) : Unit \\{", "");
|
||||||
@@ -119,7 +119,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
static String expressionToKotlin(String code) throws Exception {
|
private 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user