use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.
the class AnnotationLoader method loadAnnotationConstructorDefaultedParameters.
private void loadAnnotationConstructorDefaultedParameters(LazyFunction method, MethodMirror meth, AnnotationInvocation ai) {
for (Parameter ctorParam : method.getFirstParameterList().getParameters()) {
AnnotationConstructorParameter acp = new AnnotationConstructorParameter();
acp.setParameter(ctorParam);
if (ctorParam.isDefaulted()) {
acp.setDefaultArgument(loadAnnotationConstructorDefaultedParameter(method, meth, ctorParam, acp));
}
ai.getConstructorParameters().add(acp);
}
}
use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.
the class AnnotationLoader method makeInterorAnnotationConstructorInvocation.
public void makeInterorAnnotationConstructorInvocation(AnnotationProxyMethod ctor, AnnotationProxyClass klass, java.util.List<Parameter> ctorParams) {
AnnotationInvocation ai = new AnnotationInvocation();
ai.setConstructorDeclaration(ctor);
ai.setPrimary(klass);
ai.setInterop(true);
ctor.setAnnotationConstructor(ai);
java.util.List<AnnotationArgument> annotationArgs = new ArrayList<AnnotationArgument>();
for (Parameter ctorParam : ctorParams) {
boolean isValue = ctorParam.getName().equals("value");
ParameterAnnotationTerm term = new ParameterAnnotationTerm();
AnnotationArgument argument = new AnnotationArgument();
argument.setTerm(term);
argument.setParameter(klass.getParameter(ctorParam.getName()));
term.setSourceParameter(ctorParam);
AnnotationConstructorParameter acp = new AnnotationConstructorParameter();
acp.setParameter(ctorParam);
if (isValue)
ai.getConstructorParameters().add(0, acp);
else
ai.getConstructorParameters().add(acp);
annotationArgs.add(argument);
}
ai.getAnnotationArguments().addAll(annotationArgs);
}
use of com.redhat.ceylon.model.typechecker.model.Parameter 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.Parameter 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.Parameter in project ceylon-compiler by ceylon.
the class ParameterDefinitionBuilder method functionalParameters.
static void functionalParameters(StringBuilder sb, ParameterList pl) {
sb.append('(');
Iterator<Parameter> parameters = pl.getParameters().iterator();
while (parameters.hasNext()) {
Parameter p = parameters.next();
FunctionOrValue pm = p.getModel();
sb.append(pm.getName());
if (p.isSequenced()) {
if (p.isAtLeastOne()) {
sb.append('+');
} else {
sb.append('*');
}
}
if (pm instanceof Function) {
Function meth = (Function) pm;
functionalName(sb, (Function) pm);
}
if (parameters.hasNext()) {
sb.append(',');
}
}
sb.append(')');
}
Aggregations