cleanup
This commit is contained in:
@@ -585,6 +585,7 @@
|
||||
<words>
|
||||
<w>kotlin</w>
|
||||
<w>nullable</w>
|
||||
<w>ushr</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
||||
|
||||
@@ -622,7 +622,7 @@ public class Converter {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String createConversionForExpression(@Nullable PsiExpression expression, @NotNull PsiType expectedType) {
|
||||
private static String createConversionForExpression(@Nullable PsiExpression expression, @NotNull PsiType expectedType) {
|
||||
String conversion = "";
|
||||
if (expression != null) {
|
||||
PsiType actualType = expression.getType();
|
||||
@@ -638,7 +638,7 @@ public class Converter {
|
||||
return conversion;
|
||||
}
|
||||
|
||||
public static boolean isConversionNeeded(@Nullable final PsiType actual, @Nullable final PsiType expected) {
|
||||
private static boolean isConversionNeeded(@Nullable final PsiType actual, @Nullable final PsiType expected) {
|
||||
if (actual == null || expected == null)
|
||||
return false;
|
||||
Map<String, String> typeMap = new HashMap<String, String>();
|
||||
@@ -657,7 +657,7 @@ public class Converter {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getPrimitiveTypeConversion(@NotNull String type) {
|
||||
private static String getPrimitiveTypeConversion(@NotNull String type) {
|
||||
Map<String, String> conversions = new HashMap<String, String>();
|
||||
conversions.put("byte", "byt");
|
||||
conversions.put("short", "sht");
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.*;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ArrayInitializerExpression extends Expression {
|
||||
private Type myType;
|
||||
private final Type myType;
|
||||
private final List<Expression> myInitializers;
|
||||
|
||||
public ArrayInitializerExpression(final Type type, List<Expression> initializers) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ArrayWithoutInitializationExpression extends Expression {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getConstructorName(@NotNull Type type) {
|
||||
private static String getConstructorName(@NotNull Type type) {
|
||||
return AstUtil.replaceLastQuest(type.toKotlin());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import java.util.List;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class CaseContainer extends Statement {
|
||||
private List<Statement> myCaseStatement;
|
||||
private Block myBlock;
|
||||
private final List<Statement> myCaseStatement;
|
||||
private final Block myBlock;
|
||||
|
||||
public CaseContainer(final List<Statement> caseStatement, @NotNull final List<Statement> statements) {
|
||||
myCaseStatement = caseStatement;
|
||||
|
||||
@@ -4,7 +4,7 @@ package org.jetbrains.jet.j2k.ast;
|
||||
* @author ignatov
|
||||
*/
|
||||
public interface IMember extends INode {
|
||||
public boolean isStatic();
|
||||
boolean isStatic();
|
||||
|
||||
boolean isAbstract();
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public interface INode {
|
||||
@NotNull
|
||||
public String toKotlin();
|
||||
String toKotlin();
|
||||
|
||||
@NotNull
|
||||
public Kind getKind();
|
||||
Kind getKind();
|
||||
|
||||
public enum Kind {
|
||||
enum Kind {
|
||||
UNDEFINED, TYPE, CONSTRUCTOR, BREAK, CONTINUE, VARARG, TRAIT, ASSIGNMENT_EXPRESSION, CALL_CHAIN, LITERAL, ARRAY_TYPE,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public interface Identifier extends INode {
|
||||
@NotNull
|
||||
public static Identifier EMPTY_IDENTIFIER = new IdentifierImpl("");
|
||||
Identifier EMPTY_IDENTIFIER = new IdentifierImpl("");
|
||||
|
||||
public boolean isEmpty();
|
||||
boolean isEmpty();
|
||||
|
||||
String getName();
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ import java.util.List;
|
||||
public class MethodCallExpression extends Expression {
|
||||
private final Expression myMethodCall;
|
||||
private final List<Expression> myArguments;
|
||||
private List<String> myConversions;
|
||||
private final List<String> myConversions;
|
||||
private final boolean myIsResultNullable;
|
||||
private final List<Type> myTypeParameters;
|
||||
|
||||
public MethodCallExpression(Expression methodCall, List<Expression> arguments, boolean nullable, List<Type> typeParameters) {
|
||||
this(methodCall, arguments, AstUtil.createListWithEmptyString(arguments), nullable, typeParameters);
|
||||
public MethodCallExpression(Expression methodCall, List<Expression> arguments, List<Type> typeParameters) {
|
||||
this(methodCall, arguments, AstUtil.createListWithEmptyString(arguments), false, typeParameters);
|
||||
}
|
||||
|
||||
public MethodCallExpression(Expression methodCall, List<Expression> arguments, List<String> conversions, boolean nullable, List<Type> typeParameters) {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class NewClassExpression extends Expression {
|
||||
@Nullable
|
||||
private AnonymousClass myAnonymousClass = null;
|
||||
|
||||
public NewClassExpression(Element name, List<Expression> arguments) {
|
||||
private NewClassExpression(Element name, List<Expression> arguments) {
|
||||
myName = name;
|
||||
myQualifier = EMPTY_EXPRESSION;
|
||||
myArguments = arguments;
|
||||
|
||||
@@ -54,5 +54,5 @@ public abstract class Node implements INode {
|
||||
@NotNull
|
||||
static final String STAR = "*";
|
||||
@NotNull
|
||||
public static final String ZERO = "0";
|
||||
protected static final String ZERO = "0";
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import java.util.List;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class SwitchContainer extends Statement {
|
||||
private Expression myExpression;
|
||||
private List<CaseContainer> myCaseContainers;
|
||||
private final Expression myExpression;
|
||||
private final List<CaseContainer> myCaseContainers;
|
||||
|
||||
public SwitchContainer(final Expression expression, final List<CaseContainer> caseContainers) {
|
||||
myExpression = expression;
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class SwitchLabelStatement extends Statement {
|
||||
private Expression myExpression;
|
||||
private final Expression myExpression;
|
||||
|
||||
public SwitchLabelStatement(final Expression expression) {
|
||||
myExpression = expression;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Set;
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ClassVisitor extends JavaRecursiveElementVisitor {
|
||||
private Set<String> myClassIdentifiers;
|
||||
private final Set<String> myClassIdentifiers;
|
||||
|
||||
public ClassVisitor() {
|
||||
myClassIdentifiers = new HashSet<String>();
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ElementVisitor extends JavaElementVisitor {
|
||||
@Nullable
|
||||
private Element myResult = Element.EMPTY_ELEMENT;
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public Element getResult() {
|
||||
return myResult;
|
||||
}
|
||||
|
||||
@@ -139,8 +139,9 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
public void visitConditionalExpression(@NotNull PsiConditionalExpression expression) {
|
||||
super.visitConditionalExpression(expression);
|
||||
PsiExpression condition = expression.getCondition();
|
||||
Expression e = condition.getType() != null ?
|
||||
createSureCallOnlyForChain(condition, condition.getType()) :
|
||||
PsiType type = condition.getType();
|
||||
Expression e = type != null ?
|
||||
createSureCallOnlyForChain(condition, type) :
|
||||
expressionToExpression(condition);
|
||||
myResult = new ParenthesizedExpression(
|
||||
new IfStatement(
|
||||
@@ -250,7 +251,6 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
new MethodCallExpression(
|
||||
new IdentifierImpl("init"),
|
||||
expressionsToExpressionList(arguments),
|
||||
false,
|
||||
typeParameters));
|
||||
}
|
||||
|
||||
@@ -303,7 +303,6 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
super.visitReferenceExpression(expression);
|
||||
|
||||
final boolean isFieldReference = isFieldReference(expression, getContainingClass(expression));
|
||||
final boolean hasDollar = isFieldReference && isInsidePrimaryConstructor(expression);
|
||||
final boolean insideSecondaryConstructor = isInsideSecondaryConstructor(expression);
|
||||
final boolean hasReceiver = isFieldReference && insideSecondaryConstructor;
|
||||
final boolean isThis = isThisExpression(expression);
|
||||
@@ -325,7 +324,7 @@ public class ExpressionVisitor extends StatementVisitor {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static String getClassNameWithConstructor(@NotNull PsiReferenceExpression expression) {
|
||||
private static String getClassNameWithConstructor(@NotNull PsiReferenceExpression expression) {
|
||||
PsiElement context = expression.getContext();
|
||||
while (context != null) {
|
||||
if (context instanceof PsiMethod && ((PsiMethod) context).isConstructor()) {
|
||||
|
||||
@@ -80,6 +80,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
public void visitDoWhileStatement(@NotNull PsiDoWhileStatement statement) {
|
||||
super.visitDoWhileStatement(statement);
|
||||
PsiExpression condition = statement.getCondition();
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
Expression expression = condition != null && condition.getType() != null ?
|
||||
createSureCallOnlyForChain(condition, condition.getType()) :
|
||||
expressionToExpression(condition);
|
||||
@@ -179,6 +180,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
public void visitIfStatement(@NotNull PsiIfStatement statement) {
|
||||
super.visitIfStatement(statement);
|
||||
PsiExpression condition = statement.getCondition();
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
Expression expression = condition != null && condition.getType() != null ?
|
||||
createSureCallOnlyForChain(condition, condition.getType()) :
|
||||
expressionToExpression(condition);
|
||||
@@ -334,6 +336,7 @@ public class StatementVisitor extends ElementVisitor {
|
||||
public void visitWhileStatement(@NotNull PsiWhileStatement statement) {
|
||||
super.visitWhileStatement(statement);
|
||||
PsiExpression condition = statement.getCondition();
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
Expression expression = condition != null && condition.getType() != null ?
|
||||
createSureCallOnlyForChain(condition, condition.getType()) :
|
||||
expressionToExpression(condition);
|
||||
|
||||
@@ -23,11 +23,11 @@ public class TypeVisitor extends PsiTypeVisitor<Type> {
|
||||
public static final String JAVA_LANG_INTEGER = "java.lang.Integer";
|
||||
public static final String JAVA_LANG_LONG = "java.lang.Long";
|
||||
public static final String JAVA_LANG_SHORT = "java.lang.Short";
|
||||
public static final String JAVA_LANG_BOOLEAN = "java.lang.Boolean";
|
||||
private static final String JAVA_LANG_BOOLEAN = "java.lang.Boolean";
|
||||
public static final String JAVA_LANG_OBJECT = "java.lang.Object";
|
||||
public static final String JAVA_LANG_STRING = "java.lang.String";
|
||||
public static final String JAVA_LANG_ITERABLE = "java.lang.Iterable";
|
||||
public static final String JAVA_UTIL_ITERATOR = "java.util.Iterator";
|
||||
private static final String JAVA_LANG_ITERABLE = "java.lang.Iterable";
|
||||
private static final String JAVA_UTIL_ITERATOR = "java.util.Iterator";
|
||||
private Type myResult = Type.EMPTY_TYPE;
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -88,7 +88,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
|
||||
@NotNull
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTest(TestCaseBuilder.suiteForDirectory(getTestDataPathBase(), "/ast", true, new TestCaseBuilder.NamedTestFactory() {
|
||||
suite.addTest(TestCaseBuilder.suiteForDirectory(getTestDataPathBase(), "/ast", new TestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
|
||||
@@ -39,8 +39,8 @@ abstract class TestCaseBuilder {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, @NotNull NamedTestFactory factory) {
|
||||
return suiteForDirectory(baseDataDir, dataPath, recursive, emptyFilter, factory);
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, @NotNull NamedTestFactory factory) {
|
||||
return suiteForDirectory(baseDataDir, dataPath, true, emptyFilter, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user