use of abs.frontend.ast.TypeSynDecl in project abstools by abstools.
the class PureExpressionBuilder method resolveTypeSynonym.
/**
* Resolve the type synonyms to its raw type (interface or data type)
* @param d
* @return
*/
Decl resolveTypeSynonym(TypeSynDecl d) {
TypeUse use = d.getValue();
Decl decl = getDecl(model, Decl.class, namePred(use.getName()));
if (decl instanceof TypeSynDecl) {
return resolveTypeSynonym((TypeSynDecl) decl);
}
return decl;
}
use of abs.frontend.ast.TypeSynDecl in project abstools by abstools.
the class PureExpressionBuilder method importType.
void importType(Decl decl) {
importModules.add(decl.getModuleDecl().getName());
if (decl instanceof TypeSynDecl) {
decl = resolveTypeSynonym((TypeSynDecl) decl);
importModules.add(decl.getModuleDecl().getName());
}
// import type parameters
if (decl instanceof ParametricDataTypeDecl) {
for (TypeParameterDecl t : ((ParametricDataTypeDecl) decl).getTypeParameters()) {
Decl type = getDecl(model, Decl.class, namePred(t.getName()));
if (type == null) {
// most likely a generic type
continue;
}
importType(type);
}
}
}
use of abs.frontend.ast.TypeSynDecl in project abstools by abstools.
the class TypeHierarchyContentProvider method getChildren.
@Override
public Object[] getChildren(Object node) {
if (node instanceof InterfaceDecl) {
InterfaceDecl interfaceDecl = (InterfaceDecl) node;
Collection<HasTypeHierarchy> subTypes = interfaceDecl.getDirectSubTypes();
return subTypes.toArray();
} else if (node instanceof DataTypeDecl) {
DataTypeDecl dataTypeDecl = (DataTypeDecl) node;
Object[] result = new Object[dataTypeDecl.getNumDataConstructor()];
int i = 0;
for (DataConstructor d : dataTypeDecl.getDataConstructors()) {
result[i] = d;
i++;
}
return result;
} else if (node instanceof TypeSynDecl) {
TypeSynDecl typeSynDecl = (TypeSynDecl) node;
return new Object[] { typeSynDecl.getType().getDecl() };
}
return nothing;
}
Aggregations