Search in sources :

Example 66 with TypedDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.

the class DeclarationVisitor method visit.

@Override
public void visit(Tree.AnyClass that) {
    Class c = that.getDeclarationModel();
    visitDeclaration(that, c);
    Scope o = enterScope(c);
    super.visit(that);
    exitScope(o);
    Tree.ParameterList pl = that.getParameterList();
    if (pl != null) {
        pl.getModel().setFirst(true);
        c.addParameterList(pl.getModel());
    }
    // TODO: is this still necessary??
    if (c.isClassOrInterfaceMember() && c.getContainer() instanceof TypedDeclaration) {
        that.addUnsupportedError("nested classes of inner classes are not yet supported");
    }
    Tree.Identifier identifier = that.getIdentifier();
    if (c.isAbstract() && c.isFinal()) {
        that.addError("class may not be both 'abstract' and 'final': '" + name(identifier) + "'");
    }
    if (c.isFormal() && c.isFinal()) {
        that.addError("class may not be both 'formal' and 'final': '" + name(identifier) + "'");
    }
    if (hasAnnotation(that.getAnnotationList(), "service", that.getUnit())) {
        if (!c.getTypeParameters().isEmpty()) {
            that.addError("service class may not be generic");
        }
    }
}
Also used : TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) Scope(org.eclipse.ceylon.model.typechecker.model.Scope) ConditionScope(org.eclipse.ceylon.model.typechecker.model.ConditionScope) ModelUtil.getRealScope(org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope) CustomTree(org.eclipse.ceylon.compiler.typechecker.tree.CustomTree) Tree(org.eclipse.ceylon.compiler.typechecker.tree.Tree) Class(org.eclipse.ceylon.model.typechecker.model.Class) AnalyzerUtil.isVeryAbstractClass(org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.isVeryAbstractClass) ModelUtil.isAnonymousClass(org.eclipse.ceylon.model.typechecker.model.ModelUtil.isAnonymousClass)

Example 67 with TypedDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.

the class TypeArgumentVisitor method visit.

@Override
public void visit(Tree.TypedDeclaration that) {
    TypedDeclaration dec = that.getDeclarationModel();
    if (!(that instanceof Tree.Variable)) {
        check(that.getType(), dec.isVariable() || dec.isLate(), dec);
    }
    if (dec.isParameter()) {
        flip();
        boolean topLevel = // i.e. toplevel parameter in a parameter declaration
        parameterizedDeclaration == null;
        if (topLevel) {
            // TODO: to fix #1378 don't do this when the
            // parameter dec occurs in any parameter
            // list other than the first parameter
            // list of the function
            FunctionOrValue fov = (FunctionOrValue) dec;
            parameterizedDeclaration = fov.getInitializerParameter().getDeclaration();
        }
        check(that.getType(), false, parameterizedDeclaration);
        super.visit(that);
        if (topLevel) {
            parameterizedDeclaration = null;
        }
        flip();
    } else {
        super.visit(that);
    }
}
Also used : TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) FunctionOrValue(org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)

Example 68 with TypedDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.

the class AnnotationVisitor method visit.

@Override
public void visit(Tree.AnyMethod that) {
    super.visit(that);
    Function a = that.getDeclarationModel();
    if (a.isAnnotation()) {
        checkAnnotationConstructor(that, a);
    }
    TypedDeclaration m = that.getDeclarationModel();
    Unit unit = that.getUnit();
    checkAnnotations(that.getAnnotationList(), unit.getFunctionDeclarationType(), unit.getFunctionMetatype(m.getTypedReference()), that);
}
Also used : Function(org.eclipse.ceylon.model.typechecker.model.Function) TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Example 69 with TypedDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.

the class AnnotationVisitor method visit.

@Override
public void visit(Tree.AnyAttribute that) {
    super.visit(that);
    TypedDeclaration a = that.getDeclarationModel();
    Unit unit = that.getUnit();
    checkAnnotations(that.getAnnotationList(), unit.getValueDeclarationType(), unit.getValueMetatype(a.getTypedReference()), that);
}
Also used : TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Example 70 with TypedDeclaration

use of org.eclipse.ceylon.model.typechecker.model.TypedDeclaration in project ceylon by eclipse.

the class AnnotationVisitor method visit.

@Override
public void visit(Tree.ObjectDefinition that) {
    super.visit(that);
    TypedDeclaration o = that.getDeclarationModel();
    Unit unit = that.getUnit();
    checkAnnotations(that.getAnnotationList(), unit.getValueDeclarationType(), unit.getValueMetatype(o.getTypedReference()), that);
}
Also used : TypedDeclaration(org.eclipse.ceylon.model.typechecker.model.TypedDeclaration) Unit(org.eclipse.ceylon.model.typechecker.model.Unit)

Aggregations

TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)110 Type (org.eclipse.ceylon.model.typechecker.model.Type)58 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)51 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)50 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)47 Function (org.eclipse.ceylon.model.typechecker.model.Function)34 Value (org.eclipse.ceylon.model.typechecker.model.Value)28 Class (org.eclipse.ceylon.model.typechecker.model.Class)26 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)26 AnalyzerUtil.getTypedDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypedDeclaration)25 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)22 ModelUtil.appliedType (org.eclipse.ceylon.model.typechecker.model.ModelUtil.appliedType)21 TypeParameter (org.eclipse.ceylon.model.typechecker.model.TypeParameter)21 AnalyzerUtil.getPackageTypedDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getPackageTypedDeclaration)20 Scope (org.eclipse.ceylon.model.typechecker.model.Scope)19 JCExpression (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression)18 JCTree (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree)17 Parameter (org.eclipse.ceylon.model.typechecker.model.Parameter)17 Constructor (org.eclipse.ceylon.model.typechecker.model.Constructor)16 CustomTree (org.eclipse.ceylon.compiler.typechecker.tree.CustomTree)15