use of com.redhat.ceylon.model.typechecker.model.Function in project ceylon-compiler by ceylon.
the class ClassOrPackageDoc method writeParameters.
protected final void writeParameters(Declaration decl) throws IOException {
if (decl instanceof Functional) {
Map<Parameter, Map<Tree.Assertion, List<Tree.Condition>>> parametersAssertions = getParametersAssertions(decl);
boolean first = true;
List<ParameterList> parameterLists = ((Functional) decl).getParameterLists();
for (ParameterList parameterList : parameterLists) {
for (Parameter parameter : parameterList.getParameters()) {
ParameterDocData parameterDocData = getParameterDocData(parameter, parametersAssertions);
if (!parameterDocData.isEmpty()) {
if (first) {
first = false;
open("div class='parameters section'");
around("span class='title'", "Parameters: ");
open("ul");
}
open("li");
open("code");
around("span class='parameter' id='" + decl.getName() + "-" + parameter.getName() + "'", parameter.getName());
// if parameter is function, we need to produce links to its parameters
if (parameter.getModel() instanceof Function) {
writeParameterLinksIfRequired((Function) parameter.getModel(), false, decl.getName() + "-");
}
if (!isEmpty(parameterDocData.defaultValue)) {
around("span class='parameter-default-value' title='Parameter default value'", " = " + parameterDocData.defaultValue);
}
close("code");
if (!isEmpty(parameterDocData.doc)) {
around("div class='doc section'", parameterDocData.doc);
}
writeParameterAssertions(decl, parameterDocData.parameterAssertions);
close("li");
}
}
}
if (!first) {
close("ul");
close("div");
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Function in project ceylon-compiler by ceylon.
the class CeylonDocTool method collectAnnotationConstructors.
private void collectAnnotationConstructors() {
for (Module module : modules) {
for (Package pkg : getPackages(module)) {
for (Declaration decl : pkg.getMembers()) {
if (decl instanceof Function && decl.isAnnotation() && shouldInclude(decl)) {
Function annotationCtor = (Function) decl;
TypeDeclaration annotationType = annotationCtor.getTypeDeclaration();
List<Function> annotationConstructorList = annotationConstructors.get(annotationType);
if (annotationConstructorList == null) {
annotationConstructorList = new ArrayList<Function>();
annotationConstructors.put(annotationType, annotationConstructorList);
}
annotationConstructorList.add(annotationCtor);
}
}
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Function in project ceylon-compiler by ceylon.
the class ClassDoc method loadMembers.
private void loadMembers() {
constructors = new TreeMap<String, Declaration>();
methods = new TreeMap<String, Function>();
attributes = new TreeMap<String, TypedDeclaration>();
innerInterfaces = new TreeMap<String, Interface>();
innerClasses = new TreeMap<String, Class>();
innerExceptions = new TreeMap<String, Class>();
innerAliases = new TreeMap<String, TypeAlias>();
superClasses = getAncestors(klass);
superInterfaces = getSuperInterfaces(klass);
for (Declaration m : klass.getMembers()) {
if (tool.shouldInclude(m)) {
if (ModelUtil.isConstructor(m)) {
addTo(constructors, m);
} else if (m instanceof Value) {
addTo(attributes, (Value) m);
} else if (m instanceof Function) {
addTo(methods, (Function) m);
} else if (m instanceof Interface) {
addTo(innerInterfaces, (Interface) m);
} else if (m instanceof Class) {
Class c = (Class) m;
if (Util.isThrowable(c)) {
addTo(innerExceptions, c);
} else {
addTo(innerClasses, c);
}
} else if (m instanceof TypeAlias) {
addTo(innerAliases, (TypeAlias) m);
}
}
}
Collections.sort(superInterfaces, ReferenceableComparatorByName.INSTANCE);
loadInheritedMembers(attributeSpecification, superClasses, superclassInheritedMembers);
loadInheritedMembers(methodSpecification, superClasses, superclassInheritedMembers);
loadInheritedMembers(attributeSpecification, superInterfaces, interfaceInheritedMembers);
loadInheritedMembers(methodSpecification, superInterfaces, interfaceInheritedMembers);
}
use of com.redhat.ceylon.model.typechecker.model.Function in project ceylon-compiler by ceylon.
the class AbstractTransformer method getTypedReference.
TypedReference getTypedReference(TypedDeclaration decl) {
java.util.List<Type> typeArgs = Collections.<Type>emptyList();
if (decl instanceof Function) {
// For methods create type arguments for any type parameters it might have
Function m = (Function) decl;
if (!m.getTypeParameters().isEmpty()) {
typeArgs = new ArrayList<Type>(m.getTypeParameters().size());
for (TypeParameter p : m.getTypeParameters()) {
Type pt = p.getType();
typeArgs.add(pt);
}
}
}
if (decl.getContainer() instanceof TypeDeclaration) {
TypeDeclaration containerDecl = (TypeDeclaration) decl.getContainer();
return containerDecl.getType().getTypedMember(decl, typeArgs);
}
return decl.appliedTypedReference(null, typeArgs);
}
use of com.redhat.ceylon.model.typechecker.model.Function in project ceylon-compiler by ceylon.
the class AnnotationModelVisitor method visit.
@Override
public void visit(Tree.BaseMemberExpression bme) {
if (annotationConstructor != null) {
Declaration declaration = bme.getDeclaration();
if (checkingInvocationPrimary && isAnnotationConstructor(bme.getDeclaration())) {
Function ctor = (Function) bme.getDeclaration();
instantiation.setPrimary(ctor);
if (ctor.getAnnotationConstructor() != null) {
instantiation.getConstructorParameters().addAll(((AnnotationInvocation) ctor.getAnnotationConstructor()).getConstructorParameters());
}
} else if (checkingArguments || checkingDefaults) {
if (declaration instanceof Value && ((Value) declaration).isParameter()) {
Value constructorParameter = (Value) declaration;
ParameterAnnotationTerm a = new ParameterAnnotationTerm();
a.setSpread(spread);
// XXX Is this right?
a.setSourceParameter(constructorParameter.getInitializerParameter());
this.term = a;
} else if (isBooleanTrue(declaration)) {
LiteralAnnotationTerm argument = new BooleanLiteralAnnotationTerm(true);
appendLiteralArgument(bme, argument);
} else if (isBooleanFalse(declaration)) {
LiteralAnnotationTerm argument = new BooleanLiteralAnnotationTerm(false);
appendLiteralArgument(bme, argument);
} else if (bme.getUnit().isEmptyType(bme.getTypeModel()) && bme.getUnit().isIterableType(bme.getTypeModel()) && elements == null) {
// If we're dealing with an iterable, empty means empty collection, not object
endCollection(startCollection(bme), bme);
} else if (Decl.isAnonCaseOfEnumeratedType(bme)) {
LiteralAnnotationTerm argument = new ObjectLiteralAnnotationTerm(bme.getTypeModel());
appendLiteralArgument(bme, argument);
} else {
bme.addError("compiler bug: unsupported base member expression in annotation constructor", Backend.Java);
}
} else {
bme.addError("compiler bug: unsupported base member expression in annotation constructor", Backend.Java);
}
}
}
Aggregations