cleanup
This commit is contained in:
@@ -198,7 +198,7 @@ public class Converter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static List<Type> typesToNotNullableTypeList(PsiType[] types) {
|
private static List<Type> typesToNotNullableTypeList(PsiType[] types) {
|
||||||
List<Type> result = new LinkedList<Type>(typesToTypeList(types));
|
List<Type> result = new LinkedList<Type>(typesToTypeList(types));
|
||||||
for (Type p : result)
|
for (Type p : result)
|
||||||
p.setNullable(false);
|
p.setNullable(false);
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import java.util.List;
|
|||||||
public class Class extends Node {
|
public class Class extends Node {
|
||||||
String TYPE = "class";
|
String TYPE = "class";
|
||||||
final Identifier myName;
|
final Identifier myName;
|
||||||
final List<Element> myTypeParameters;
|
private final List<Element> myTypeParameters;
|
||||||
final List<Type> myExtendsTypes;
|
private final List<Type> myExtendsTypes;
|
||||||
final List<Type> myImplementsTypes;
|
private final List<Type> myImplementsTypes;
|
||||||
final List<Class> myInnerClasses;
|
final List<Class> myInnerClasses;
|
||||||
final List<Function> myMethods;
|
final List<Function> myMethods;
|
||||||
final List<Field> myFields;
|
final List<Field> myFields;
|
||||||
@@ -31,17 +31,17 @@ public class Class extends Node {
|
|||||||
|
|
||||||
private boolean hasWhere() {
|
private boolean hasWhere() {
|
||||||
for (Element t : myTypeParameters)
|
for (Element t : myTypeParameters)
|
||||||
if (t instanceof TypeParameter && ((TypeParameter)t).hasWhere())
|
if (t instanceof TypeParameter && ((TypeParameter) t).hasWhere())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String typeParameterWhereToKotlin() {
|
String typeParameterWhereToKotlin() {
|
||||||
if (hasWhere()) {
|
if (hasWhere()) {
|
||||||
List<String> wheres = new LinkedList<String >();
|
List<String> wheres = new LinkedList<String>();
|
||||||
for (Element t : myTypeParameters)
|
for (Element t : myTypeParameters)
|
||||||
if (t instanceof TypeParameter)
|
if (t instanceof TypeParameter)
|
||||||
wheres.add(((TypeParameter)t).getWhereToKotlin());
|
wheres.add(((TypeParameter) t).getWhereToKotlin());
|
||||||
return SPACE + "where" + SPACE + AstUtil.join(wheres, COMMA_WITH_SPACE) + SPACE;
|
return SPACE + "where" + SPACE + AstUtil.join(wheres, COMMA_WITH_SPACE) + SPACE;
|
||||||
}
|
}
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ClassType extends Type {
|
public class ClassType extends Type {
|
||||||
private final Identifier myType;
|
private final Identifier myType;
|
||||||
private List<Type> myParameters;
|
private final List<Type> myParameters;
|
||||||
|
|
||||||
public ClassType(Identifier type, List<Type> parameters) {
|
public ClassType(Identifier type, List<Type> parameters) {
|
||||||
myType = type;
|
myType = type;
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class ExpressionList extends Expression {
|
public class ExpressionList extends Expression {
|
||||||
private final List<Expression> myExpressions;
|
private final List<Expression> myExpressions;
|
||||||
private List<Type> myTypes; // TODO: add types to toKotlin
|
|
||||||
|
|
||||||
public ExpressionList(List<Expression> expressions, List<Type> types) {
|
public ExpressionList(List<Expression> expressions, List<Type> types) {
|
||||||
myExpressions = expressions;
|
myExpressions = expressions;
|
||||||
myTypes = types;
|
List<Type> types1 = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionList(List<Expression> expressions) {
|
public ExpressionList(List<Expression> expressions) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
public class Function extends Node {
|
public class Function extends Node {
|
||||||
private final Identifier myName;
|
private final Identifier myName;
|
||||||
private final Type myType;
|
private final Type myType;
|
||||||
private List<Element> myTypeParameters;
|
private final List<Element> myTypeParameters;
|
||||||
final Element myParams;
|
final Element myParams;
|
||||||
private final Block myBlock;
|
private final Block myBlock;
|
||||||
|
|
||||||
@@ -30,17 +30,17 @@ public class Function extends Node {
|
|||||||
|
|
||||||
private boolean hasWhere() {
|
private boolean hasWhere() {
|
||||||
for (Element t : myTypeParameters)
|
for (Element t : myTypeParameters)
|
||||||
if (t instanceof TypeParameter && ((TypeParameter)t).hasWhere())
|
if (t instanceof TypeParameter && ((TypeParameter) t).hasWhere())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String typeParameterWhereToKotlin() {
|
String typeParameterWhereToKotlin() {
|
||||||
if (hasWhere()) {
|
if (hasWhere()) {
|
||||||
List<String> wheres = new LinkedList<String >();
|
List<String> wheres = new LinkedList<String>();
|
||||||
for (Element t : myTypeParameters)
|
for (Element t : myTypeParameters)
|
||||||
if (t instanceof TypeParameter)
|
if (t instanceof TypeParameter)
|
||||||
wheres.add(((TypeParameter)t).getWhereToKotlin());
|
wheres.add(((TypeParameter) t).getWhereToKotlin());
|
||||||
return SPACE + "where" + SPACE + AstUtil.join(wheres, COMMA_WITH_SPACE) + SPACE;
|
return SPACE + "where" + SPACE + AstUtil.join(wheres, COMMA_WITH_SPACE) + SPACE;
|
||||||
}
|
}
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import java.util.Set;
|
|||||||
* @author ignatov
|
* @author ignatov
|
||||||
*/
|
*/
|
||||||
public abstract class Node implements INode {
|
public abstract class Node implements INode {
|
||||||
public static final String STAR = "*";
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Kind getKind() {
|
public Kind getKind() {
|
||||||
@@ -39,6 +37,7 @@ public abstract class Node implements INode {
|
|||||||
static final String IN = "in";
|
static final String IN = "in";
|
||||||
static final String AT = "@";
|
static final String AT = "@";
|
||||||
static final String BACKTICK = "`";
|
static final String BACKTICK = "`";
|
||||||
static final String QUESTION = "?";
|
static final String QUEST = "?";
|
||||||
static final String COMMA_WITH_SPACE = "," + SPACE;
|
static final String COMMA_WITH_SPACE = "," + SPACE;
|
||||||
|
static final String STAR = "*";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* @author ignatov
|
* @author ignatov
|
||||||
*/
|
*/
|
||||||
public abstract class Type extends Element {
|
public abstract class Type extends Element {
|
||||||
public static Type EMPTY_TYPE = new EmptyType();
|
public static final Type EMPTY_TYPE = new EmptyType();
|
||||||
protected boolean myNullable = true;
|
private boolean myNullable = true;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@@ -19,12 +19,12 @@ public abstract class Type extends Element {
|
|||||||
myNullable = nullable;
|
myNullable = nullable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNullable() {
|
boolean isNullable() {
|
||||||
return myNullable;
|
return myNullable;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String isNullableStr() {
|
String isNullableStr() {
|
||||||
return isNullable() ? QUESTION : EMPTY;
|
return isNullable() ? QUEST : EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package org.jetbrains.jet.j2k.ast;
|
package org.jetbrains.jet.j2k.ast;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.j2k.util.AstUtil;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -9,8 +8,8 @@ import java.util.List;
|
|||||||
* @author ignatov
|
* @author ignatov
|
||||||
*/
|
*/
|
||||||
public class TypeParameter extends Element {
|
public class TypeParameter extends Element {
|
||||||
private Identifier myName;
|
private final Identifier myName;
|
||||||
private List<Type> myExtendsTypes;
|
private final List<Type> myExtendsTypes;
|
||||||
|
|
||||||
public TypeParameter(Identifier name, List<Type> extendsTypes) {
|
public TypeParameter(Identifier name, List<Type> extendsTypes) {
|
||||||
myName = name;
|
myName = name;
|
||||||
|
|||||||
@@ -6,17 +6,12 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* @author ignatov
|
* @author ignatov
|
||||||
*/
|
*/
|
||||||
public class VarArg extends Type {
|
public class VarArg extends Type {
|
||||||
private Type myType;
|
private final Type myType;
|
||||||
|
|
||||||
public VarArg(Type type) {
|
public VarArg(Type type) {
|
||||||
myType = type;
|
myType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public Type getType() {
|
|
||||||
return myType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Kind getKind() {
|
public Kind getKind() {
|
||||||
|
|||||||
Reference in New Issue
Block a user