Search in sources :

Example 16 with Declaration

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

the class ExpressionTransformer method isRecursiveReference.

//
// Helper functions
private boolean isRecursiveReference(Tree.StaticMemberOrTypeExpression expr) {
    Declaration decl = expr.getDeclaration();
    Scope s = expr.getScope();
    // do we have decl as our container anywhere in the scope?
    while (s != null && !Decl.equalScopeDecl(s, decl)) {
        s = s.getContainer();
    }
    return Decl.equalScopeDecl(s, decl);
}
Also used : Scope(com.redhat.ceylon.model.typechecker.model.Scope) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 17 with Declaration

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

the class MethodOrValueReferenceVisitor method visit.

@Override
public void visit(Tree.Declaration that) {
    Declaration dm = that.getDeclarationModel();
    if (dm == declaration.getContainer() || (Decl.equal(dm, declaration) && !isClassWithConstructorMember(declaration)) || (dm instanceof Setter && ((Setter) dm).getGetter() == declaration)) {
        if (!isCapturableMplParameter(declaration)) {
            this.inCapturingScope = false;
        }
    }
    super.visit(that);
}
Also used : Setter(com.redhat.ceylon.model.typechecker.model.Setter) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 18 with Declaration

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

the class MethodOrValueReferenceVisitor method isCapturableMplParameter.

/**
     * Because methods with MPL use nested anonymous AbstractCallables
     * if the declaration is a parameter in all but the last parameter list
     * it should be captured.
     */
private boolean isCapturableMplParameter(Declaration d) {
    if (!(d instanceof FunctionOrValue)) {
        return false;
    }
    com.redhat.ceylon.model.typechecker.model.Parameter param = ((FunctionOrValue) d).getInitializerParameter();
    if (param == null) {
        return false;
    }
    Declaration paramDecl = param.getDeclaration();
    if (paramDecl instanceof Functional) {
        List<com.redhat.ceylon.model.typechecker.model.ParameterList> parameterLists = ((Functional) paramDecl).getParameterLists();
        for (int i = 0; i < parameterLists.size() - 1; i++) {
            if (parameterLists.get(i).getParameters().contains(param)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Functional(com.redhat.ceylon.model.typechecker.model.Functional) TypedDeclaration(com.redhat.ceylon.model.typechecker.model.TypedDeclaration) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) FunctionOrValue(com.redhat.ceylon.model.typechecker.model.FunctionOrValue)

Example 19 with Declaration

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

the class UnknownTypeCollector method visit.

public void visit(Tree.BaseMemberOrTypeExpression that) {
    super.visit(that);
    Declaration declaration = that.getDeclaration();
    if (declaration == null)
        return;
    if (declaration instanceof Functional) {
        Functional m = (Functional) declaration;
        collectUnknownTypes(m.getType());
        for (ParameterList pl : m.getParameterLists()) {
            for (Parameter p : pl.getParameters()) {
                collectUnknownTypes(p.getType());
            }
        }
    } else if (declaration instanceof Value) {
        Value v = (Value) declaration;
        collectUnknownTypes(v.getType());
    }
}
Also used : Functional(com.redhat.ceylon.model.typechecker.model.Functional) Value(com.redhat.ceylon.model.typechecker.model.Value) ParameterList(com.redhat.ceylon.model.typechecker.model.ParameterList) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 20 with Declaration

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

the class NamingTests method testCm.

@Test
public void testCm() throws Exception {
    final Declaration decl = findDecl("Cm.ceylon", "Cm.m");
    assertEquals("com.redhat.ceylon.compiler.java.codegen.Cm.m", 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)

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