use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.TypeArguments in project ceylon by eclipse.
the class BmeGenerator method createTypeArguments.
/**
* Create a map with type arguments from the type parameter list in the expression's declaration and the
* type argument list in the expression itself.
*/
static Map<TypeParameter, Type> createTypeArguments(final Tree.StaticMemberOrTypeExpression expr) {
List<TypeParameter> tparams = null;
Declaration declaration = expr.getDeclaration();
if (declaration instanceof Generic) {
tparams = declaration.getTypeParameters();
} else if (declaration instanceof TypedDeclaration && ((TypedDeclaration) declaration).getType() != null && ((TypedDeclaration) declaration).getType().isTypeConstructor()) {
tparams = ((TypedDeclaration) declaration).getType().getDeclaration().getTypeParameters();
} else {
expr.addUnexpectedError("Getting type parameters from unidentified declaration type " + declaration, Backend.JavaScript);
return null;
}
final HashMap<TypeParameter, Type> targs = new HashMap<>();
TypeArguments typeArguments = expr.getTypeArguments();
if (typeArguments != null) {
List<Type> typeModels = typeArguments.getTypeModels();
if (typeModels != null) {
final Iterator<Type> iter = typeModels.iterator();
for (TypeParameter tp : tparams) {
Type pt = iter.hasNext() ? iter.next() : tp.getDefaultTypeArgument();
targs.put(tp, pt);
}
}
}
return targs;
}
Aggregations