Example usage for org.eclipse.jdt.core IType getInitializers

List of usage examples for org.eclipse.jdt.core IType getInitializers

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IType getInitializers.

Prototype

IInitializer[] getInitializers() throws JavaModelException;

Source Link

Document

Returns the initializers declared by this type.

Usage

From source file:net.sourceforge.c4jplugin.internal.ui.contracthierarchy.MethodsContentProvider.java

License:Open Source License

public Object[] getElements(Object element) {
    if (element instanceof IType) {
        IType type = (IType) element;/*from w w w  .  ja  v a 2 s .c om*/

        List<Object> res = new ArrayList<Object>();
        try {
            IContractHierarchy hierarchy = fHierarchyLifeCycle.getContractHierarchy();
            if (fShowInheritedMethods && hierarchy != null) {
                IType[] allSupertypes = hierarchy.getAllSupercontracts(type);
                // sort in from last to first: elements with same name
                // will show up in hierarchy order 
                for (int i = allSupertypes.length - 1; i >= 0; i--) {
                    IType superType = allSupertypes[i];
                    if (superType.exists()) {
                        addAll(superType.getMethods(), res);
                        addAll(superType.getInitializers(), res);
                        addAll(superType.getFields(), res);
                    }
                }
            }
            if (type.exists()) {
                addAll(type.getMethods(), res);
                addAll(type.getInitializers(), res);
                addAll(type.getFields(), res);
            }
        } catch (JavaModelException e) {
            C4JActivator.log(e);
        }
        return res.toArray();
    }
    return NO_ELEMENTS;
}

From source file:org.eclipse.gmf.internal.codegen.HideGeneratedFilter.java

License:Open Source License

private boolean allGenerated(IType type) throws JavaModelException {
    for (IField field : type.getFields()) {
        if (!hasGeneratedTag(field)) {
            return false;
        }/*from  www .java  2s  . c o m*/
    }
    for (IMethod method : type.getMethods()) {
        if (!hasGeneratedTag(method)) {
            return false;
        }
    }
    for (IInitializer initializer : type.getInitializers()) {
        if (!hasGeneratedTag(initializer)) {
            return false;
        }
    }
    for (IType subtype : type.getTypes()) {
        if (!allGenerated(subtype)) {
            return false;
        }
    }
    return true;
}