Menu

#5 List of super interfaces only includes direct interfaces

open
nobody
None
5
2005-10-17
2005-10-17
Anonymous
No

The list of implemented/super interfaces only includes
interfaces that are directly implemented/inherited.
It should include the transitive closure of parent
interfaces

(rian.wouters@philips.com)

Discussion

  • Nobody/Anonymous

    Logged In: NO

    fix:

    XMLGenerator.java,

    method XMLGenerator.buildInterfaceList

    replace

    // build the list
    Object[] sorted = sortList(interfaces.toArray());

    by

    // add transitive closure of super interfaces
    {
    int i = 0;
    while (i < interfaces.size()) {
    ClassDoc cd = (ClassDoc)
    interfaces.get(i);
    ClassDoc[] interfaceInterfaces =
    cd.interfaces();
    append(interfaces, interfaceInterfaces);
    i++;
    } }

    // build the list
    Object[] sorted = sortList(interfaces.toArray());

    // remove duplicate values
    {
    // precondition: sorted does not contain null values
    Object o = null;
    int j = 0;
    for (int i = 0; i < sorted.length; i++) {
    if (sorted[i] != o && (o == null || !
    o.equals(sorted[i]))) {
    sorted[j] = sorted[i];
    j++;
    }
    o = sorted[j];
    }
    Object[] tmp = new Object[j];
    System.arraycopy(sorted, 0, tmp, 0, j);
    sorted = tmp;
    }

    this also fixes the problem of duplicate interfaces in the
    interface list

     
  • Nobody/Anonymous

    Logged In: NO

    oops, there is a bug in the fix:

    "o = sorted[j];" should be before "j++"

     
  • Nobody/Anonymous

    Logged In: NO

    Since the sorted array is only used once,
    a much easier fix to remove the duplicate values:

    replace:

    if (interfaceDoc == null) {

    by

    if (interfaceDoc == null || i > 0 && (interfaceDoc == sorted[i-1]
    || interfaceDoc.equals(sorted[i-1]))) {

    (rian.wouters@philips.com)

     

Log in to post a comment.

MongoDB Logo MongoDB