Search in sources :

Example 26 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class NamingTests method testoo.

@Test
public void testoo() throws Exception {
    final TypeDeclaration decl = findType("oo.ceylon", "oo.o");
    Assert.assertEquals("o_", naming.makeTypeDeclarationName(decl));
    Assert.assertEquals(QUAL + "oo_.o_", naming.makeTypeDeclarationName(decl, QUALIFIED));
    assertEquals("com.redhat.ceylon.compiler.java.codegen.oo_.o_.get_", CodegenUtil.getJavaNameOfDeclaration(decl));
}
Also used : TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 27 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class NamingTests method testfIC.

@Test
public void testfIC() throws Exception {
    final TypeDeclaration decl = findType("fIC.ceylon", "fIC.IC.C");
    Assert.assertEquals("C", naming.makeTypeDeclarationName(decl));
    Assert.assertEquals("IC$impl.C", naming.makeTypeDeclarationName(decl, QUALIFIED));
    try {
        CodegenUtil.getJavaNameOfDeclaration(decl);
        fail();
    } catch (IllegalArgumentException e) {
    }
}
Also used : TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 28 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class NamingTests method testfC.

@Test
public void testfC() throws Exception {
    final TypeDeclaration decl = findType("fC.ceylon", "fC.C");
    Assert.assertEquals("C", naming.makeTypeDeclarationName(decl));
    Assert.assertEquals("C$impl", naming.makeTypeDeclarationName(decl, COMPANION));
    Assert.assertEquals("C", naming.makeTypeDeclarationName(decl, QUALIFIED));
    Assert.assertEquals("C$impl", naming.makeTypeDeclarationName(decl, COMPANION, QUALIFIED));
    try {
        CodegenUtil.getJavaNameOfDeclaration(decl);
        fail();
    } catch (IllegalArgumentException e) {
    }
}
Also used : TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 29 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class NamingTests method testC.

@Test
public void testC() throws Exception {
    final TypeDeclaration decl = findType("C.ceylon", "C");
    Assert.assertEquals("C", naming.makeTypeDeclarationName(decl));
    Assert.assertEquals(QUAL + "C", naming.makeTypeDeclarationName(decl, QUALIFIED));
    assertEquals("com.redhat.ceylon.compiler.java.codegen.C", CodegenUtil.getJavaNameOfDeclaration(decl));
}
Also used : TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 30 with TypeDeclaration

use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.

the class TypeParserTests method assertTypeWithParameters.

private void assertTypeWithParameters(Type type) {
    Assert.assertNotNull(type);
    TypeDeclaration declaration = type.getDeclaration();
    Assert.assertNotNull(declaration);
    Assert.assertTrue(declaration instanceof Class);
    Assert.assertEquals("t2", declaration.getName());
    List<Type> tal = type.getTypeArgumentList();
    Assert.assertEquals(2, tal.size());
    Assert.assertEquals("b", tal.get(0).getDeclaration().getName());
    Assert.assertTrue(tal.get(0).getDeclaration() instanceof Class);
    Assert.assertEquals("c", tal.get(1).getDeclaration().getName());
    Assert.assertTrue(tal.get(1).getDeclaration() instanceof Class);
}
Also used : IntersectionType(com.redhat.ceylon.model.typechecker.model.IntersectionType) Type(com.redhat.ceylon.model.typechecker.model.Type) UnionType(com.redhat.ceylon.model.typechecker.model.UnionType) Class(com.redhat.ceylon.model.typechecker.model.Class) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Aggregations

TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)140 Type (com.redhat.ceylon.model.typechecker.model.Type)85 Test (org.junit.Test)51 Class (com.redhat.ceylon.model.typechecker.model.Class)40 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)37 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)36 IntersectionType (com.redhat.ceylon.model.typechecker.model.IntersectionType)33 UnionType (com.redhat.ceylon.model.typechecker.model.UnionType)33 TypeParser (com.redhat.ceylon.model.loader.TypeParser)32 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)32 Interface (com.redhat.ceylon.model.typechecker.model.Interface)27 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)24 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)20 ModelUtil.appliedType (com.redhat.ceylon.model.typechecker.model.ModelUtil.appliedType)19 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)19 Function (com.redhat.ceylon.model.typechecker.model.Function)18 ArrayList (java.util.ArrayList)17 JCTree (com.sun.tools.javac.tree.JCTree)16 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)14 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)14