This commit is contained in:
Sergey Ignatov
2011-11-24 13:15:27 +04:00
parent a3c91abd4d
commit 7d117471e9
4 changed files with 14 additions and 11 deletions
@@ -6,10 +6,10 @@ import org.jetbrains.annotations.NotNull;
* @author ignatov
*/
public class ForeachWithRangeStatement extends Statement {
private Expression myStart;
private IdentifierImpl myIdentifier;
private Expression myEnd;
private Statement myBody;
private final Expression myStart;
private final IdentifierImpl myIdentifier;
private final Expression myEnd;
private final Statement myBody;
public ForeachWithRangeStatement(IdentifierImpl identifier, Expression start, Expression end, Statement body) {
myStart = start;
@@ -39,7 +39,7 @@ public class IdentifierImpl extends Expression implements Identifier {
return myIsNullable;
}
private String ifNeedQuote(String name) {
private static String ifNeedQuote(String name) {
if (ONLY_KOTLIN_KEYWORDS.contains(name) || name.contains("$"))
return quote(name);
return name;
+4 -1
View File
@@ -9,7 +9,10 @@ import java.util.List;
* @author ignatov
*/
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();
boolean haveDelimiter = (delimiter != null);
@@ -92,18 +92,18 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
return suite;
}
static void configureFromText(String text) throws IOException {
private static void configureFromText(String text) throws IOException {
configureFromFileText("test.java", text);
}
@NotNull
static String fileToKotlin(String text) throws IOException {
private static String fileToKotlin(String text) throws IOException {
configureFromText(text);
return prettify(Converter.fileToFile((PsiJavaFile) myFile).toKotlin());
}
@NotNull
static String methodToKotlin(String text) throws IOException {
private static String methodToKotlin(String text) throws IOException {
String result = fileToKotlin("final class C {" + text + "}")
.replaceAll("class C\\(\\) \\{", "");
result = result.substring(0, result.lastIndexOf("}"));
@@ -111,7 +111,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
}
@NotNull
static String statementToKotlin(String text) throws Exception {
private static String statementToKotlin(String text) throws Exception {
String result = methodToKotlin("void main() {" + text + "}");
int pos = result.lastIndexOf("}");
result = result.substring(0, pos).replaceFirst("fun main\\(\\) : Unit \\{", "");
@@ -119,7 +119,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
}
@NotNull
static String expressionToKotlin(String code) throws Exception {
private static String expressionToKotlin(String code) throws Exception {
String result = statementToKotlin("Object o =" + code + "}");
result = result.replaceFirst("var o : Any\\? =", "");
return prettify(result);