All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.redhat.ceylon.compiler.java.runtime.metamodel.FunctionalUtil Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
package com.redhat.ceylon.compiler.java.runtime.metamodel;

import java.util.List;

import ceylon.language.Iterator;
import ceylon.language.Sequential;
import ceylon.language.finished_;
import ceylon.language.meta.declaration.Declaration;
import ceylon.language.meta.declaration.FunctionOrValueDeclaration;

import com.redhat.ceylon.compiler.java.Util;
import com.redhat.ceylon.model.typechecker.model.Functional;
import com.redhat.ceylon.model.typechecker.model.Parameter;
import com.redhat.ceylon.model.typechecker.model.ParameterList;

public class FunctionalUtil {
    public static Sequential getParameters(Functional declaration) {
        ParameterList parameterList = ((Functional)declaration).getFirstParameterList();
        List 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);
    }
    
    public static FunctionOrValueDeclaration getParameterDeclaration(Sequential 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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy