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);
}
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");
}
}
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");
}
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;
}
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;
}
}
Aggregations