use of com.redhat.ceylon.model.typechecker.model.ParameterList in project ceylon-compiler by ceylon.
the class ClassOrPackageDoc method writeParameterList.
protected final void writeParameterList(Functional f, Referenceable scope) throws IOException {
for (ParameterList lists : f.getParameterLists()) {
write("(");
boolean first = true;
for (Parameter param : lists.getParameters()) {
if (!first) {
write(", ");
} else {
first = false;
}
if (param.getModel() instanceof Function) {
writeFunctionalParameter(param, scope);
} else {
linkRenderer().to(param.getType()).useScope(scope).write();
write(" ");
around("span class='parameter'", param.getName());
}
if (param.isDefaulted()) {
String defaultValue = getParameterDefaultValue(param);
if (defaultValue != null) {
around("span class='parameter-default-value'", " = ");
if (simpleDefaultValues.contains(defaultValue)) {
around("span class='parameter-default-value' title='Parameter default value'", defaultValue);
} else {
around("a class='parameter-default-value' href='#" + f.getName() + "-" + param.getName() + "' title='Go to parameter default value'", "...");
}
}
}
}
write(")");
}
}
use of com.redhat.ceylon.model.typechecker.model.ParameterList in project ceylon-compiler by ceylon.
the class MethodDefinitionBuilder method mpl.
public void mpl(java.util.List<ParameterList> parameterLists) {
StringBuilder sb = new StringBuilder();
for (int ii = 1; ii < parameterLists.size(); ii++) {
ParameterList parameterList = parameterLists.get(ii);
ParameterDefinitionBuilder.functionalParameters(sb, parameterList);
}
modelAnnotations(gen.makeAtFunctionalParameter(sb.toString()));
}
use of com.redhat.ceylon.model.typechecker.model.ParameterList in project ceylon-compiler by ceylon.
the class Strategy method hasNoRequiredParameters.
/**
* Returns true if the given functional takes no parameters or accepts only defaulted params
*/
private static boolean hasNoRequiredParameters(Functional model) {
List<ParameterList> parameterLists = model.getParameterLists();
if (parameterLists == null || parameterLists.size() != 1)
return false;
ParameterList parameterList = parameterLists.get(0);
if (parameterList == null)
return false;
List<Parameter> parameters = parameterList.getParameters();
if (parameters == null)
return false;
if (parameters.isEmpty())
return true;
// if the first one is optional, all others have to be too
return parameters.get(0).isDefaulted();
}
use of com.redhat.ceylon.model.typechecker.model.ParameterList in project ceylon-compiler by ceylon.
the class ClassTransformer method transformMplBody.
/**
* Constructs all but the outer-most method of a {@code Function} with
* multiple parameter lists
* @param model The {@code Function} model
* @param body The inner-most body
*/
List<JCStatement> transformMplBody(java.util.List<Tree.ParameterList> parameterListsTree, Function model, List<JCStatement> body) {
Type resultType = model.getType();
for (int index = model.getParameterLists().size() - 1; index > 0; index--) {
ParameterList pl = model.getParameterLists().get(index);
resultType = gen().typeFact().getCallableType(List.of(resultType, typeFact().getParameterTypesAsTupleType(pl.getParameters(), model.getReference())));
CallableBuilder cb = CallableBuilder.mpl(gen(), resultType, pl, parameterListsTree.get(index), body);
body = List.<JCStatement>of(make().Return(cb.build()));
}
return body;
}
use of com.redhat.ceylon.model.typechecker.model.ParameterList in project ceylon-compiler by ceylon.
the class ClassTransformer method generateInstantiators.
private void generateInstantiators(ClassDefinitionBuilder classBuilder, Class cls, Constructor ctor, ClassDefinitionBuilder instantiatorDeclCb, ClassDefinitionBuilder instantiatorImplCb, Tree.Declaration node, Tree.ParameterList pl) {
// TODO Instantiators on companion classes
if (Decl.isEnumeratedConstructor(ctor)) {
return;
}
ParameterList parameterList = ctor != null ? ctor.getFirstParameterList() : cls.getParameterList();
if (Decl.withinInterface(cls)) {
DefaultedArgumentOverload overloaded = new DefaultedArgumentInstantiator(daoAbstract, cls, ctor, instantiatorDeclCb.isCompanionBuilder());
MethodDefinitionBuilder instBuilder = overloaded.makeOverload(parameterList, null, cls.getTypeParameters());
instantiatorDeclCb.method(instBuilder);
}
if (!Decl.withinInterface(cls) || !cls.isFormal()) {
DefaultedArgumentOverload overloaded = new DefaultedArgumentInstantiator(!cls.isFormal() ? new DaoThis(node, pl) : daoAbstract, cls, ctor, instantiatorImplCb.isCompanionBuilder());
MethodDefinitionBuilder instBuilder = overloaded.makeOverload(parameterList, null, cls.getTypeParameters());
instantiatorImplCb.method(instBuilder);
}
}
Aggregations