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