Search in sources :

Example 86 with Declaration

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

the class NamingTests method findDecl.

protected Declaration findDecl(String resource, String declName) throws Exception {
    List<Declaration> members = getDecls(resource);
    Declaration found = null;
    outer: for (String name : declName.split("\\.")) {
        for (Declaration decl : members) {
            if (name.equals(decl.getName())) {
                found = decl;
                members = found.getMembers();
                continue outer;
            }
        }
        break;
    }
    if (found == null) {
        throw new RuntimeException("Unable to find declaration");
    }
    return found;
}
Also used : Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 87 with Declaration

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

the class NamingTests method testCa.

@Test
public void testCa() throws Exception {
    final Declaration decl = findDecl("Ca.ceylon", "Ca.a");
    assertEquals("com.redhat.ceylon.compiler.java.codegen.Ca.getA", CodegenUtil.getJavaNameOfDeclaration(decl));
}
Also used : Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 88 with Declaration

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

the class NamingTests method testg.

@Test
public void testg() throws Exception {
    final Declaration decl = findDecl("g.ceylon", "g");
    assertEquals("com.redhat.ceylon.compiler.java.codegen.g_.get_", CodegenUtil.getJavaNameOfDeclaration(decl));
}
Also used : Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 89 with Declaration

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

the class NamingTests method testv.

@Test
public void testv() throws Exception {
    final Declaration decl = findDecl("v.ceylon", "v");
    assertEquals("com.redhat.ceylon.compiler.java.codegen.v_.get_", CodegenUtil.getJavaNameOfDeclaration(decl));
}
Also used : Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Test(org.junit.Test)

Example 90 with Declaration

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

the class ClassTransformer method makeLocalContainerPath.

private List<JCAnnotation> makeLocalContainerPath(Interface model) {
    List<String> path = List.nil();
    Scope container = model.getContainer();
    while (container != null && container instanceof Package == false) {
        if (container instanceof Declaration)
            path = path.prepend(((Declaration) container).getPrefixedName());
        container = container.getContainer();
    }
    return makeAtLocalContainer(path, model.isCompanionClassNeeded() ? model.getJavaCompanionClassName() : null);
}
Also used : Scope(com.redhat.ceylon.model.typechecker.model.Scope) Package(com.redhat.ceylon.model.typechecker.model.Package) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) MethodDeclaration(com.redhat.ceylon.compiler.typechecker.tree.Tree.MethodDeclaration) AttributeDeclaration(com.redhat.ceylon.compiler.typechecker.tree.Tree.AttributeDeclaration)

Aggregations

Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)107 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)95 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)80 Type (com.redhat.ceylon.model.typechecker.model.Type)34 Function (com.redhat.ceylon.model.typechecker.model.Function)33 ClassOrInterface (com.redhat.ceylon.model.typechecker.model.ClassOrInterface)30 Class (com.redhat.ceylon.model.typechecker.model.Class)28 Value (com.redhat.ceylon.model.typechecker.model.Value)28 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)27 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)27 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)24 AttributeDeclaration (com.redhat.ceylon.compiler.typechecker.tree.Tree.AttributeDeclaration)22 JCTree (com.sun.tools.javac.tree.JCTree)22 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)21 MethodDeclaration (com.redhat.ceylon.compiler.typechecker.tree.Tree.MethodDeclaration)20 Interface (com.redhat.ceylon.model.typechecker.model.Interface)20 Scope (com.redhat.ceylon.model.typechecker.model.Scope)20 Package (com.redhat.ceylon.model.typechecker.model.Package)17 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)17 ArrayList (java.util.ArrayList)16