This commit is contained in:
Sergey Ignatov
2011-11-02 14:18:49 +04:00
parent 2e6a65c0cd
commit a54d55e5df
9 changed files with 23 additions and 31 deletions
+1 -1
View File
@@ -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);
+6 -6
View File
@@ -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;
+1 -1
View File
@@ -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) {
+4 -4
View File
@@ -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;
+2 -3
View File
@@ -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 = "*";
} }
+5 -5
View File
@@ -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;
+1 -6
View File
@@ -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() {