org.snapscript.tree.reference.GenericArgumentList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.reference;
import java.util.ArrayList;
import java.util.List;
import org.snapscript.core.constraint.Constraint;
import org.snapscript.core.error.InternalStateException;
import org.snapscript.core.scope.Scope;
import org.snapscript.core.type.Type;
import org.snapscript.tree.constraint.GenericList;
public class GenericArgumentList implements GenericList {
private final GenericArgument[] arguments;
public GenericArgumentList(GenericArgument... arguments) {
this.arguments = arguments;
}
public List getImports(Scope scope) throws Exception {
List result = new ArrayList();
for(GenericArgument argument : arguments) {
Constraint constraint = argument.getConstraint();
List imports = constraint.getImports(scope);
result.addAll(imports);
}
return result;
}
@Override
public List getGenerics(Scope scope) throws Exception {
List result = new ArrayList();
for(GenericArgument argument : arguments) {
Constraint constraint = argument.getConstraint();
Type type = constraint.getType(scope);
if(type == null) {
throw new InternalStateException("Could not find constraint");
}
result.add(constraint);
}
return result;
}
}