Search in sources :

Example 6 with Annotation

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

the class ClassOrPackageDoc method writeThrows.

protected final void writeThrows(Declaration decl) throws IOException {
    boolean first = true;
    for (Annotation annotation : decl.getAnnotations()) {
        if (annotation.getName().equals("throws")) {
            String excType = annotation.getPositionalArguments().get(0);
            String excDesc = annotation.getPositionalArguments().size() == 2 ? annotation.getPositionalArguments().get(1) : null;
            if (first) {
                first = false;
                open("div class='throws section'");
                around("span class='title'", "Throws ");
                open("ul");
            }
            open("li");
            linkRenderer().to(excType).withinText(true).useScope(decl).write();
            if (excDesc != null) {
                write(Util.wikiToHTML(excDesc, linkRenderer().useScope(decl)));
            }
            close("li");
        }
    }
    if (!first) {
        close("ul");
        close("div");
    }
    tool.warningMissingThrows(decl);
}
Also used : Annotation(org.eclipse.ceylon.model.typechecker.model.Annotation)

Example 7 with Annotation

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

the class ClassOrPackageDoc method writeDeprecated.

private void writeDeprecated(Declaration decl) throws IOException {
    Annotation deprecated = Util.findAnnotation(decl, "deprecated");
    if (deprecated != null) {
        open("div class='deprecated section'");
        String text = "<span class='title'>Deprecated: </span>";
        if (!deprecated.getPositionalArguments().isEmpty()) {
            String reason = deprecated.getPositionalArguments().get(0);
            if (reason != null) {
                text += reason;
            }
        }
        write(Util.wikiToHTML(text, linkRenderer().useScope(decl)));
        close("div");
    }
}
Also used : Annotation(org.eclipse.ceylon.model.typechecker.model.Annotation)

Example 8 with Annotation

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

the class ModuleDoc method writeLabel.

protected final void writeLabel(Module mod) throws IOException {
    Annotation annotation = Util.getAnnotation(mod.getUnit(), mod.getAnnotations(), "label");
    if (annotation == null)
        return;
    String label = annotation.getPositionalArguments().get(0);
    if (label == null || label.isEmpty())
        return;
    open("div class='modulelabel'");
    around("h1", label);
    close("div");
}
Also used : Annotation(org.eclipse.ceylon.model.typechecker.model.Annotation)

Example 9 with Annotation

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

the class Util method getTags.

public static <T extends Referenceable & Annotated> List<String> getTags(T decl) {
    List<String> tags = new ArrayList<String>();
    Annotation tagged = Util.getAnnotation(decl.getUnit(), decl.getAnnotations(), "tagged");
    if (tagged != null) {
        tags.addAll(tagged.getPositionalArguments());
    }
    return tags;
}
Also used : ArrayList(java.util.ArrayList) Annotation(org.eclipse.ceylon.model.typechecker.model.Annotation)

Example 10 with Annotation

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

the class Strategy method generateJpaCtor.

static boolean generateJpaCtor(ClassOrInterface declarationModel) {
    if (declarationModel instanceof Class && !(declarationModel instanceof ClassAlias) && declarationModel.isToplevel()) {
        Class cls = (Class) declarationModel;
        if (cls.getCaseValues() != null && !cls.getCaseValues().isEmpty()) {
            return false;
        }
        if (hasNullaryNonJpaConstructor(cls)) {
            // The class will already have a nullary ctor
            return false;
        }
        for (Annotation annotation : cls.getAnnotations()) {
            Declaration annoDecl = cls.getUnit().getImportedDeclaration(annotation.getName(), null, false);
            if (annoDecl != null && annoDecl.getQualifiedNameString().equals("java.lang::nonbean")) {
                return false;
            }
        }
        boolean hasDelegatableSuper = false;
        Class superClass = (Class) cls.getExtendedType().getDeclaration();
        if (superClass instanceof LazyClass && !((LazyClass) superClass).isCeylon()) {
            if (superClass.isAbstraction()) {
                for (Declaration s : superClass.getOverloads()) {
                    if (s instanceof Class && isNullary((Class) s)) {
                        hasDelegatableSuper = true;
                        break;
                    }
                }
            } else {
                // If the superclass is Java then generate a Jpa constructor
                // if there's a nullary superclass constructor we can call
                hasDelegatableSuper = isNullary(superClass);
            }
        } else {
            hasDelegatableSuper = hasNullaryNonJpaConstructor(superClass) || hasJpaConstructor(superClass);
        }
        boolean constrained = cls.getCaseValues() != null && !cls.getCaseValues().isEmpty() || cls.hasEnumerated() && Decl.hasOnlyValueConstructors(cls);
        return hasDelegatableSuper && !constrained;
    } else {
        return false;
    }
}
Also used : ClassAlias(org.eclipse.ceylon.model.typechecker.model.ClassAlias) LazyClass(org.eclipse.ceylon.model.loader.model.LazyClass) Class(org.eclipse.ceylon.model.typechecker.model.Class) TypeDeclaration(org.eclipse.ceylon.model.typechecker.model.TypeDeclaration) MethodDeclaration(org.eclipse.ceylon.compiler.typechecker.tree.Tree.MethodDeclaration) Declaration(org.eclipse.ceylon.model.typechecker.model.Declaration) LazyClass(org.eclipse.ceylon.model.loader.model.LazyClass) Annotation(org.eclipse.ceylon.model.typechecker.model.Annotation)

Aggregations

Annotation (org.eclipse.ceylon.model.typechecker.model.Annotation)30 ArrayList (java.util.ArrayList)10 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)7 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)6 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)6 ParameterList (org.eclipse.ceylon.model.typechecker.model.ParameterList)5 List (java.util.List)4 Tree (org.eclipse.ceylon.compiler.typechecker.tree.Tree)4 Package (org.eclipse.ceylon.model.typechecker.model.Package)4 Value (org.eclipse.ceylon.model.typechecker.model.Value)4 HashMap (java.util.HashMap)3 Class (org.eclipse.ceylon.model.typechecker.model.Class)3 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)3 FunctionOrValue (org.eclipse.ceylon.model.typechecker.model.FunctionOrValue)3 Module (org.eclipse.ceylon.model.typechecker.model.Module)3 NothingType (org.eclipse.ceylon.model.typechecker.model.NothingType)3 Map (java.util.Map)2 AnalyzerUtil.getTypedDeclaration (org.eclipse.ceylon.compiler.typechecker.analyzer.AnalyzerUtil.getTypedDeclaration)2 ExpressionVisitor.getRefinedMemberReference (org.eclipse.ceylon.compiler.typechecker.analyzer.ExpressionVisitor.getRefinedMemberReference)2 PhasedUnit (org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit)2