/**
  * Recursively adds the given {@link BundleDescription} and its dependents to the given {@link
  * Set}
  *
  * @param desc the {@link BundleDescription} to compute dependencies for
  * @param set the {@link Set} to collect results in
  * @param includeOptional if optional dependencies should be included
  * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from
  *     the dependency resolution
  */
 private static void addBundleAndDependencies(
     BundleDescription desc,
     Set<String> set,
     boolean includeOptional,
     Set<String> excludeFragments) {
   if (desc != null && set.add(desc.getSymbolicName())) {
     BundleSpecification[] required = desc.getRequiredBundles();
     for (int i = 0; i < required.length; i++) {
       if (includeOptional || !required[i].isOptional()) {
         addBundleAndDependencies(
             (BundleDescription) required[i].getSupplier(),
             set,
             includeOptional,
             excludeFragments);
       }
     }
     ImportPackageSpecification[] importedPkgs = desc.getImportPackages();
     for (int i = 0; i < importedPkgs.length; i++) {
       ExportPackageDescription exporter =
           (ExportPackageDescription) importedPkgs[i].getSupplier();
       // Continue if the Imported Package is unresolved of the package is optional and don't want
       // optional packages
       if (exporter == null
           || (!includeOptional
               && Constants.RESOLUTION_OPTIONAL.equals(
                   importedPkgs[i].getDirective(Constants.RESOLUTION_DIRECTIVE)))) {
         continue;
       }
       addBundleAndDependencies(exporter.getExporter(), set, includeOptional, excludeFragments);
     }
     BundleDescription[] fragments = desc.getFragments();
     for (int i = 0; i < fragments.length; i++) {
       if (!fragments[i].isResolved()) {
         continue;
       }
       String id = fragments[i].getSymbolicName();
       if (!excludeFragments.contains(id)) {
         addBundleAndDependencies(fragments[i], set, includeOptional, excludeFragments);
       }
     }
     HostSpecification host = desc.getHost();
     if (host != null) {
       addBundleAndDependencies(
           (BundleDescription) host.getSupplier(), set, includeOptional, excludeFragments);
     }
   }
 }
  protected Object[] findCallees(IPluginModelBase model) {
    BundleDescription desc = model.getBundleDescription();
    if (desc == null) return new Object[0];
    fFragmentDescription = null;
    HostSpecification spec = desc.getHost();
    if (spec != null) {
      fFragmentDescription = desc;
      Object[] fragmentDependencies = getDependencies(desc);
      BaseDescription host = spec.getSupplier();
      if (host instanceof BundleDescription) {
        BundleDescription hostDesc = (BundleDescription) host;
        // check to see if the host is already included as a dependency.  If so, we don't need to
        // include the host manually.
        for (int i = 0; i < fragmentDependencies.length; i++) {
          BundleDescription dependency = null;
          if (fragmentDependencies[i] instanceof BundleSpecification)
            dependency = ((BundleSpecification) fragmentDependencies[i]).getBundle();
          else if (fragmentDependencies[i] instanceof ImportPackageSpecification) {
            ExportPackageDescription epd =
                (ExportPackageDescription)
                    ((ImportPackageSpecification) fragmentDependencies[i]).getSupplier();
            if (epd != null) dependency = epd.getSupplier();
          }
          if (dependency != null && dependency.equals(hostDesc)) return fragmentDependencies;
        }

        // host not included as dependency, include it manually.
        Object[] result = new Object[fragmentDependencies.length + 1];
        result[0] = hostDesc;
        System.arraycopy(fragmentDependencies, 0, result, 1, fragmentDependencies.length);
        return result;
      }
      return fragmentDependencies;
    }
    return getDependencies(desc);
  }