Search in sources :

Example 1 with Annotation

use of com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation in project ceylon-compiler by ceylon.

the class ForcedCaptureVisitor method isForcedCapture.

private boolean isForcedCapture(Tree.TypedDeclaration that) {
    if (that.getAnnotationList() == null)
        return false;
    for (Annotation anno : that.getAnnotationList().getAnnotations()) {
        Type type = anno.getTypeModel();
        if (type == null || !type.isClassOrInterface())
            continue;
        TypeDeclaration decl = type.getDeclaration();
        if (decl == null)
            continue;
        Module module = Decl.getModule(decl);
        if (module == null)
            continue;
        if (module.getLanguageModule() == module)
            continue;
        // does not come from the language module
        return true;
    }
    return false;
}
Also used : Type(com.redhat.ceylon.model.typechecker.model.Type) Module(com.redhat.ceylon.model.typechecker.model.Module) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration) Annotation(com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation)

Example 2 with Annotation

use of com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation in project ceylon-compiler by ceylon.

the class UnsupportedVisitor method interopAnnotationTargeting.

private void interopAnnotationTargeting(EnumSet<OutputElement> outputs, Tree.AnnotationList annotationList) {
    List<Annotation> annotations = annotationList.getAnnotations();
    for (Tree.Annotation annotation : annotations) {
        AnnotationUtil.interopAnnotationTargeting(outputs, annotation, true);
    }
    AnnotationUtil.duplicateInteropAnnotation(outputs, annotations);
}
Also used : Tree(com.redhat.ceylon.compiler.typechecker.tree.Tree) Annotation(com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation) Annotation(com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation)

Example 3 with Annotation

use of com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation in project ceylon-compiler by ceylon.

the class AnnotationUtil method duplicateInteropAnnotation.

public static void duplicateInteropAnnotation(EnumSet<OutputElement> outputs, List<Annotation> annotations) {
    for (int i = 0; i < annotations.size(); i++) {
        Tree.Annotation ann = annotations.get(i);
        Type t = ann.getTypeModel();
        EnumSet<OutputElement> mainTargets = interopAnnotationTargeting(outputs, ann, false);
        if (t != null && mainTargets != null) {
            TypeDeclaration td = t.getDeclaration();
            if (!ModelUtil.isCeylonDeclaration(td)) {
                for (int j = 0; j < i; j++) {
                    Tree.Annotation other = annotations.get(j);
                    Type ot = other.getTypeModel();
                    if (ot != null) {
                        TypeDeclaration otd = ot.getDeclaration();
                        if (otd.equals(td)) {
                            // check if they have the same targets (if not that's fine)
                            EnumSet<OutputElement> dupeTargets = interopAnnotationTargeting(outputs, other, false);
                            if (dupeTargets != null) {
                                EnumSet<OutputElement> sameTargets = intersection(mainTargets, dupeTargets);
                                if (!sameTargets.isEmpty()) {
                                    ann.addError("duplicate annotation: there are multiple annotations of type '" + td.getName() + "' for targets: '" + sameTargets + "'");
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Type(com.redhat.ceylon.model.typechecker.model.Type) OutputElement(com.redhat.ceylon.model.loader.model.OutputElement) Tree(com.redhat.ceylon.compiler.typechecker.tree.Tree) Annotation(com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Aggregations

Annotation (com.redhat.ceylon.compiler.typechecker.tree.Tree.Annotation)3 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)2 Type (com.redhat.ceylon.model.typechecker.model.Type)2 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)2 OutputElement (com.redhat.ceylon.model.loader.model.OutputElement)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1