/**
   * Returns the package of the specified completion.
   *
   * @param c The completion.
   * @param desc The description text being parsed. Used for errors if we cannot determine the
   *     package.
   * @return The package.
   */
  private String getPackage(Completion c, String desc) {

    String pkg = null;

    if (c instanceof JSClassCompletion) {
      pkg = ((JSClassCompletion) c).getPackageName();
    }
    if (c instanceof JSCompletion) {
      String definedIn = ((JSCompletion) c).getEnclosingClassName(true);
      if (definedIn != null) {
        int lastDot = definedIn.lastIndexOf('.');
        if (lastDot > -1) {
          pkg = definedIn.substring(0, lastDot);
        }
      }
    } else {
      Logger.logError(
          "Can't determine package from completion type: "
              + c.getClass()
              + " ("
              + c.toString()
              + ") - href: "
              + desc);
    }

    return pkg;
  }
  /**
   * Returns the class for a completion (class completions return the class itself, member
   * completions return the enclosing class).
   */
  private String getClass(Completion c, String desc) {

    String clazz = null;

    if (c instanceof JSClassCompletion) {
      clazz = ((JSClassCompletion) c).getClassName(true);
    } else if (c instanceof JSCompletion) {
      JSCompletion jsc = (JSCompletion) c;
      clazz = jsc.getEnclosingClassName(true);
    } else {
      Logger.logError(
          "Can't determine class from completion type: "
              + c.getClass()
              + " ("
              + c.toString()
              + ") - href: "
              + desc);
    }

    return clazz;
  }