Search in sources :

Example 1 with FunctionOrValueDeclaration

use of ceylon.language.meta.declaration.FunctionOrValueDeclaration in project ceylon by eclipse.

the class FunctionalUtil method getParameters.

@SuppressWarnings({ "unchecked", "rawtypes" })
public static Sequential<FunctionOrValueDeclaration> getParameters(Functional declaration) {
    ParameterList parameterList = ((Functional) declaration).getFirstParameterList();
    if (parameterList == null)
        return (Sequential) empty_.get_();
    List<Parameter> modelParameters = parameterList.getParameters();
    ceylon.language.meta.declaration.FunctionOrValueDeclaration[] parameters = new ceylon.language.meta.declaration.FunctionOrValueDeclaration[modelParameters.size()];
    int i = 0;
    for (Parameter modelParameter : modelParameters) {
        parameters[i] = (ceylon.language.meta.declaration.FunctionOrValueDeclaration) Metamodel.getOrCreateMetamodel(modelParameter.getModel());
        i++;
    }
    return Util.sequentialWrapper(ceylon.language.meta.declaration.FunctionOrValueDeclaration.$TypeDescriptor$, parameters);
}
Also used : Functional(org.eclipse.ceylon.model.typechecker.model.Functional) ParameterList(org.eclipse.ceylon.model.typechecker.model.ParameterList) Parameter(org.eclipse.ceylon.model.typechecker.model.Parameter) FunctionOrValueDeclaration(ceylon.language.meta.declaration.FunctionOrValueDeclaration)

Example 2 with FunctionOrValueDeclaration

use of ceylon.language.meta.declaration.FunctionOrValueDeclaration in project ceylon by eclipse.

the class FunctionalUtil method getParameterDeclaration.

public static FunctionOrValueDeclaration getParameterDeclaration(Sequential<? extends FunctionOrValueDeclaration> parameterList, String name) {
    Iterator<?> iterator = parameterList.iterator();
    Object o;
    while ((o = iterator.next()) != finished_.get_()) {
        ceylon.language.meta.declaration.FunctionOrValueDeclaration pd = (ceylon.language.meta.declaration.FunctionOrValueDeclaration) o;
        if (((Declaration) pd).getName().equals(name))
            return pd;
    }
    return null;
}
Also used : FunctionOrValueDeclaration(ceylon.language.meta.declaration.FunctionOrValueDeclaration) FunctionOrValueDeclaration(ceylon.language.meta.declaration.FunctionOrValueDeclaration)

Aggregations

FunctionOrValueDeclaration (ceylon.language.meta.declaration.FunctionOrValueDeclaration)2 Functional (org.eclipse.ceylon.model.typechecker.model.Functional)1 Parameter (org.eclipse.ceylon.model.typechecker.model.Parameter)1 ParameterList (org.eclipse.ceylon.model.typechecker.model.ParameterList)1