use of org.eclipse.ceylon.model.typechecker.model.Parameter in project ceylon by eclipse.
the class AnalyzerUtil method getUnspecifiedParameter.
static Parameter getUnspecifiedParameter(Reference pr, ParameterList pl, Set<Parameter> foundParameters) {
for (Parameter p : pl.getParameters()) {
Type t = pr == null ? p.getType() : pr.getTypedParameter(p).getFullType();
if (t != null) {
t = t.resolveAliases();
Unit unit = p.getDeclaration().getUnit();
if (!foundParameters.contains(p) && unit.isIterableParameterType(t)) {
return p;
}
}
}
return null;
}
use of org.eclipse.ceylon.model.typechecker.model.Parameter in project ceylon by eclipse.
the class AnnotationVisitor method checkServiceImplementation.
private void checkServiceImplementation(Class clazz, Declaration d, Node that) {
if (d instanceof ClassOrInterface) {
ClassOrInterface service = (ClassOrInterface) d;
ParameterList pl = clazz.getParameterList();
if (pl == null) {
that.addError("service class must have a parameter list or default constructor");
} else {
List<Parameter> params = pl.getParameters();
if (!params.isEmpty() && !params.get(0).isDefaulted()) {
that.addError("service class must be instantiable with an empty argument list");
}
}
if (clazz.inherits(service)) {
ModelUtil.getModule(clazz).addService(service, clazz);
} else {
that.addError("service class does not implement service '" + service + "'");
}
} else {
that.addError("service must be an interface or class");
}
}
use of org.eclipse.ceylon.model.typechecker.model.Parameter in project ceylon by eclipse.
the class AnnotationVisitor method checkPositionalArguments.
private void checkPositionalArguments(Functional a, List<Tree.PositionalArgument> pal) {
for (Tree.PositionalArgument pa : pal) {
if (pa != null) {
Parameter p = pa.getParameter();
if (p != null) {
if (pa instanceof Tree.ListedArgument) {
Tree.ListedArgument la = (Tree.ListedArgument) pa;
checkAnnotationArgument(a, la.getExpression());
} else if (pa instanceof Tree.SpreadArgument) {
Tree.SpreadArgument sa = (Tree.SpreadArgument) pa;
checkAnnotationArgument(a, sa.getExpression());
} else {
pa.addError("illegal annotation argument");
}
}
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Parameter in project ceylon by eclipse.
the class ExpressionVisitor method setupTargetParametersDirectly.
/**
* Sets references from arguments back to parameters
* in a direct invocation with positional arguments,
* special casing "coercion points" generated by the
* model loader.
*/
private void setupTargetParametersDirectly(Tree.PositionalArgumentList pal, Tree.MemberOrTypeExpression mte, Declaration dec, boolean error) {
// coercion point and use that instead
if (!error && isOverloadedVersion(dec) && !dec.isCoercionPoint()) {
Declaration abstraction = dec.getContainer().getDirectMember(dec.getName(), null, false);
if (abstraction.isAbstraction()) {
List<Declaration> overloads = abstraction.getOverloads();
if (overloads.size() == 2) {
for (Declaration overload : overloads) {
if (overload.isCoercionPoint()) {
dec = overload;
break;
}
}
}
}
}
List<Tree.PositionalArgument> args = pal.getPositionalArguments();
int argCount = args.size();
Functional fun = (Functional) dec;
List<ParameterList> pls = fun.getParameterLists();
if (!pls.isEmpty()) {
List<Parameter> params = pls.get(0).getParameters();
Reference reference = getInvokedProducedReference(dec, mte);
int paramsSize = params.size();
for (int i = 0, j = 0; i < argCount && j < paramsSize; i++) {
Parameter param = params.get(j);
Tree.PositionalArgument arg = args.get(i);
arg.setParameter(param);
if (arg instanceof Tree.ListedArgument) {
Tree.ListedArgument la = (Tree.ListedArgument) arg;
setupTargetParameters(reference, param, la.getExpression());
}
if (!param.isSequenced()) {
j++;
}
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Parameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.FunctionalParameterDeclaration that) {
Parameter p = new Parameter();
p.setDeclaration(declaration);
p.setDefaulted(getSpecifier(that) != null);
Tree.TypedDeclaration td = that.getTypedDeclaration();
Tree.Type type = td.getType();
p.setDeclaredAnything(type instanceof Tree.VoidModifier);
that.setParameterModel(p);
super.visit(that);
Function m = (Function) td.getDeclarationModel();
p.setModel(m);
p.setName(m.getName());
m.setInitializerParameter(p);
parameterList.getParameters().add(p);
if (type instanceof Tree.SequencedType) {
type.addError("functional parameter type may not be variadic");
}
if (m.isFormal()) {
that.addError("parameter may not be annotated 'formal'", 1312);
}
}
Aggregations