Search in sources :

Example 1 with DataTypeDecl

use of abs.frontend.ast.DataTypeDecl 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;
}
Also used : InterfaceDecl(abs.frontend.ast.InterfaceDecl) HasTypeHierarchy(abs.frontend.ast.HasTypeHierarchy) DataConstructor(abs.frontend.ast.DataConstructor) DataTypeDecl(abs.frontend.ast.DataTypeDecl) TypeSynDecl(abs.frontend.ast.TypeSynDecl)

Aggregations

DataConstructor (abs.frontend.ast.DataConstructor)1 DataTypeDecl (abs.frontend.ast.DataTypeDecl)1 HasTypeHierarchy (abs.frontend.ast.HasTypeHierarchy)1 InterfaceDecl (abs.frontend.ast.InterfaceDecl)1 TypeSynDecl (abs.frontend.ast.TypeSynDecl)1