package de.dhbwstuttgart.typeinference.assumptions;

import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericDeclarationList;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;


import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public class FunNClass extends ClassOrInterface {
    public FunNClass(List<GenericRefType> funNParams) {
        super(0, new JavaClassName("Fun" + (funNParams.size() - 1)), new ArrayList<>(), Optional.empty(), Optional.empty() /* eingefuegt PL 2018-11-24 */, createMethods(funNParams), new ArrayList<>(), createGenerics(funNParams), ASTFactory.createObjectType(), true, false, new ArrayList<>(), new ArrayList<>(), new NullToken(), null);

    }

    private static GenericDeclarationList createGenerics(List<GenericRefType> funNParams) {
        // PL 2018-06-22: so geaendert, dass generierte Generics den Namen der funParams entsprechen.
        List<GenericTypeVar> generics = new ArrayList<>();
        for (GenericRefType param : funNParams) {
            generics.add(new GenericTypeVar(param.getParsedName(), // NameGenerator.makeNewName(),
                    new ArrayList<>(), new NullToken(), new NullToken()));
        }
        return new GenericDeclarationList(generics, new NullToken());
    }

    private static List<Method> createMethods(List<GenericRefType> funNParams) {
        return null;
    }
}
