private Object[] getChildren(IType type) throws JavaScriptModelException {
    IParent parent;
    if (type.isBinary()) parent = type.getClassFile();
    else {
      parent = type.getJavaScriptUnit();
    }
    if (type.getDeclaringType() != null) return type.getChildren();

    // Add import declarations
    IJavaScriptElement[] members = parent.getChildren();
    ArrayList tempResult = new ArrayList(members.length);
    for (int i = 0; i < members.length; i++)
      if ((members[i] instanceof IImportContainer)) tempResult.add(members[i]);
    tempResult.addAll(Arrays.asList(type.getChildren()));
    return tempResult.toArray();
  }
  /**
   * Returns all of the openables defined in the region of this type hierarchy. Returns a map from
   * IJavaScriptProject to ArrayList of Openable
   */
  private HashMap determineOpenablesInRegion(IProgressMonitor monitor) {

    try {
      HashMap allOpenables = new HashMap();
      IJavaScriptElement[] roots = ((RegionBasedTypeHierarchy) this.hierarchy).region.getElements();
      int length = roots.length;
      if (monitor != null) monitor.beginTask("", length); // $NON-NLS-1$
      for (int i = 0; i < length; i++) {
        IJavaScriptElement root = roots[i];
        IJavaScriptProject javaProject = root.getJavaScriptProject();
        ArrayList openables = (ArrayList) allOpenables.get(javaProject);
        if (openables == null) {
          openables = new ArrayList();
          allOpenables.put(javaProject, openables);
        }
        switch (root.getElementType()) {
          case IJavaScriptElement.JAVASCRIPT_PROJECT:
            injectAllOpenablesForJavaProject((IJavaScriptProject) root, openables);
            break;
          case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT:
            injectAllOpenablesForPackageFragmentRoot((IPackageFragmentRoot) root, openables);
            break;
          case IJavaScriptElement.PACKAGE_FRAGMENT:
            injectAllOpenablesForPackageFragment((IPackageFragment) root, openables);
            break;
          case IJavaScriptElement.CLASS_FILE:
          case IJavaScriptElement.JAVASCRIPT_UNIT:
            openables.add(root);
            break;
          case IJavaScriptElement.TYPE:
            IType type = (IType) root;
            if (type.isBinary()) {
              openables.add(type.getClassFile());
            } else {
              openables.add(type.getJavaScriptUnit());
            }
            break;
          default:
            break;
        }
        worked(monitor, 1);
      }
      return allOpenables;
    } finally {
      if (monitor != null) monitor.done();
    }
  }