use of org.eclipse.ceylon.model.typechecker.model.ParameterList in project ceylon by eclipse.
the class AbstractModelLoader method loadFunctionalParameter.
private Function loadFunctionalParameter(Declaration decl, String paramName, Type type, String parameterNames) {
Function method = new Function();
method.setName(paramName);
method.setUnit(decl.getUnit());
if (parameterNames == null || parameterNames.isEmpty()) {
// This branch is broken, but it deals with old code which lacked
// the encoding of parameter names of functional parameters, so we'll keep it until 1.2
method.setType(getSimpleCallableReturnType(type));
ParameterList pl = new ParameterList();
int count = 0;
for (Type pt : getSimpleCallableArgumentTypes(type)) {
Parameter p = new Parameter();
Value v = new Value();
String name = "arg" + count++;
p.setName(name);
v.setName(name);
v.setType(pt);
v.setContainer(method);
v.setScope(method);
p.setModel(v);
v.setInitializerParameter(p);
pl.getParameters().add(p);
method.addMember(v);
}
method.addParameterList(pl);
} else {
try {
parameterNameParser.parse(parameterNames, type, method);
} catch (Exception x) {
logError(x.getClass().getSimpleName() + " while parsing parameter names of " + decl + ": " + x.getMessage());
return method;
}
}
return method;
}
use of org.eclipse.ceylon.model.typechecker.model.ParameterList in project ceylon by eclipse.
the class AbstractModelLoader method setEqualsParameters.
private void setEqualsParameters(Function decl, MethodMirror methodMirror) {
ParameterList parameters = new ParameterList();
decl.addParameterList(parameters);
Parameter parameter = new Parameter();
Value value = new Value();
parameter.setModel(value);
value.setInitializerParameter(parameter);
value.setUnit(decl.getUnit());
Scope scope = (Scope) decl;
value.setContainer(scope);
value.setScope(scope);
parameter.setName("that");
value.setName("that");
value.setType(getNonPrimitiveType(getLanguageModule(), CEYLON_OBJECT_TYPE, decl));
parameter.setDeclaration((Declaration) decl);
parameters.getParameters().add(parameter);
decl.addMember(value);
}
use of org.eclipse.ceylon.model.typechecker.model.ParameterList in project ceylon by eclipse.
the class AbstractModelLoader method complete.
private void complete(AnnotationProxyClass klass, LazyInterface iface) {
ParameterList classpl = new ParameterList();
klass.addParameterList(classpl);
for (Declaration member : iface.getMembers()) {
boolean isValue = member.getName().equals("value");
if (member instanceof JavaMethod) {
JavaMethod m = (JavaMethod) member;
Parameter klassParam = new Parameter();
Value value = new Value();
klassParam.setModel(value);
value.setInitializerParameter(klassParam);
klassParam.setDeclaration(klass);
value.setContainer(klass);
value.setScope(klass);
value.setName(member.getName());
klassParam.setName(member.getName());
value.setType(annotationParameterType(iface.getUnit(), m));
value.setUnboxed(true);
value.setUnit(iface.getUnit());
if (isValue)
classpl.getParameters().add(0, klassParam);
else
classpl.getParameters().add(klassParam);
klass.addMember(value);
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.ParameterList in project ceylon by eclipse.
the class ParameterNameParser method parse.
public void parse(String input, Type type, Function method) {
lexer.setup(input);
this.unit = method.getUnit();
boolean declaredVoid = false;
ArrayList<ParameterList> lists = new ArrayList<>();
if (lexer.lookingAt(BANG)) {
lexer.eat();
declaredVoid = true;
}
lists.add(parseNameList(type, method));
while (lexer.lookingAt(LEFT_PAREN)) {
// mpl
type = loader.getSimpleCallableReturnType(type);
lists.add(parseNameList(type, method));
}
for (ParameterList parameterList : lists) {
method.addParameterList(parameterList);
}
method.setDeclaredVoid(declaredVoid);
method.setType(loader.getSimpleCallableReturnType(type));
if (!lexer.lookingAt(EOI)) {
throw new ParameterNameParserException("Expected end of input" + System.lineSeparator() + input);
}
}
use of org.eclipse.ceylon.model.typechecker.model.ParameterList in project ceylon by eclipse.
the class ExpressionTransformer method transformFunctionalInterfaceBridge.
public JCExpression transformFunctionalInterfaceBridge(Tree.InvocationExpression expr, JCExpression primaryExpr, Type expectedType) {
ParameterList paramList = new ParameterList();
int i = 0;
Type callableType = expr.getTypeModel().getSupertype(typeFact().getCallableDeclaration());
for (Type type : typeFact().getCallableArgumentTypes(callableType)) {
Parameter param = new Parameter();
Value paramModel = new Value();
param.setModel(paramModel);
param.setName("arg" + i);
paramModel.setName("arg" + i);
paramModel.setType(type);
paramList.getParameters().add(param);
i++;
}
return CallableBuilder.callableToFunctionalInterface(gen(), expr, paramList, expectedType, expr.getTypeModel(), false, primaryExpr);
}
Aggregations