boxed types supported
This commit is contained in:
@@ -34,7 +34,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> implements Visitor {
|
||||
else if (Node.PRIMITIVE_TYPES.contains(name))
|
||||
myResult = new PrimitiveType(new IdentifierImpl(AstUtil.upperFirstCharacter(name)));
|
||||
else
|
||||
myResult = new PrimitiveType(identifier);
|
||||
myResult = new PrimitiveType(identifier);
|
||||
return super.visitPrimitiveType(primitiveType);
|
||||
}
|
||||
|
||||
@@ -48,12 +48,26 @@ public class TypeVisitor extends PsiTypeVisitor<Type> implements Visitor {
|
||||
@Override
|
||||
public Type visitClassType(PsiClassType classType) {
|
||||
myResult = new ClassType(
|
||||
new IdentifierImpl(classType.getClassName()),
|
||||
new IdentifierImpl(getClassTypeName(classType)),
|
||||
typesToTypeList(classType.getParameters())
|
||||
);
|
||||
return super.visitClassType(classType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getClassTypeName(@NotNull PsiClassType classType) {
|
||||
String canonicalTypeStr = classType.getCanonicalText();
|
||||
if (canonicalTypeStr.equals("java.lang.Byte")) return "Byte";
|
||||
if (canonicalTypeStr.equals("java.lang.Character")) return "Char";
|
||||
if (canonicalTypeStr.equals("java.lang.Double")) return "Double";
|
||||
if (canonicalTypeStr.equals("java.lang.Float")) return "Float";
|
||||
if (canonicalTypeStr.equals("java.lang.Integer")) return "Int";
|
||||
if (canonicalTypeStr.equals("java.lang.Long")) return "Long";
|
||||
if (canonicalTypeStr.equals("java.lang.Short")) return "Short";
|
||||
if (canonicalTypeStr.equals("java.lang.Boolean")) return "Boolean";
|
||||
return classType.getClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitWildcardType(PsiWildcardType wildcardType) {
|
||||
if (wildcardType.isExtends())
|
||||
@@ -71,10 +85,10 @@ public class TypeVisitor extends PsiTypeVisitor<Type> implements Visitor {
|
||||
return super.visitEllipsisType(ellipsisType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) {
|
||||
return super.visitCapturedWildcardType(capturedWildcardType);
|
||||
}
|
||||
@Override
|
||||
public Type visitCapturedWildcardType(PsiCapturedWildcardType capturedWildcardType) {
|
||||
return super.visitCapturedWildcardType(capturedWildcardType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type visitDisjunctionType(PsiDisjunctionType disjunctionType) {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.jet.j2k.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public class BoxedTypeTest extends JetTestCaseBase {
|
||||
public void testBoolean() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Boolean i = 10;"), "var i : Boolean? = 10");
|
||||
}
|
||||
|
||||
public void testByte() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Byte i = 10;"), "var i : Byte? = 10");
|
||||
}
|
||||
|
||||
public void testCharacter() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Character i = 10;"), "var i : Char? = 10");
|
||||
}
|
||||
|
||||
public void testDouble() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Double i = 10;"), "var i : Double? = 10");
|
||||
}
|
||||
|
||||
public void testFloat() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Float i = 10;"), "var i : Float? = 10");
|
||||
}
|
||||
|
||||
public void testInteger() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Integer i = 10;"), "var i : Int? = 10");
|
||||
}
|
||||
|
||||
public void testLong() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Long i = 10;"), "var i : Long? = 10");
|
||||
}
|
||||
|
||||
public void testShort() throws Exception {
|
||||
Assert.assertEquals(statementToKotlin("Short i = 10;"), "var i : Short? = 10");
|
||||
}
|
||||
|
||||
// public void testNewInteger() throws Exception {
|
||||
// Assert.assertEquals(
|
||||
// statementToKotlin("Integer i = new Integer(10);"),
|
||||
// "var i : Int? = Integer(10).toInt()"
|
||||
// );
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user