summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-03-05 09:58:27 +0000
committerpaltherr <paltherr@epfl.ch>2004-03-05 09:58:27 +0000
commit2d8126de26bad4d886012a1c666391948d8a6e71 (patch)
treef7f4bae93ab2018173d9a9567cf141985c9c4159
parent50f5fcf7d65d0764d8704632e7429b5665a56739 (diff)
downloadscala-2d8126de26bad4d886012a1c666391948d8a6e71.tar.gz
scala-2d8126de26bad4d886012a1c666391948d8a6e71.tar.bz2
scala-2d8126de26bad4d886012a1c666391948d8a6e71.zip
- Fixed ordering of symPathOrder
-rw-r--r--sources/scala/tools/scaladoc/ScalaSearch.java38
1 files changed, 23 insertions, 15 deletions
diff --git a/sources/scala/tools/scaladoc/ScalaSearch.java b/sources/scala/tools/scaladoc/ScalaSearch.java
index 32c1ca4b64..38b927b296 100644
--- a/sources/scala/tools/scaladoc/ScalaSearch.java
+++ b/sources/scala/tools/scaladoc/ScalaSearch.java
@@ -234,25 +234,33 @@ public class ScalaSearch {
*/
public static Comparator symPathOrder = new Comparator() {
public int compare(Object o1, Object o2) {
- Symbol symbol1 = (Symbol) o1;
- Symbol symbol2 = (Symbol) o2;
- if (symbol1 == symbol2) return 0;
- if (symbol1.isRoot()) return -1;
- if (symbol2.isRoot()) return +1;
- if (symbol1.isNone()) return -1;
- if (symbol2.isNone()) return +1;
- if (symbol1.isError()) return -1;
- if (symbol2.isError()) return +1;
- int owners = compare(symbol1.owner(), symbol2.owner());
- if (owners < 0) return -1;
- if (owners > 0) return +1;
- String name1 = symbol1.nameString();
- String name2 = symbol2.nameString();
- return name1.compareTo(name2);
+ LinkedList l1 = getOwners((Symbol)o1);
+ LinkedList l2 = getOwners((Symbol)o2);
+ for (int i = 0; true; i++) {
+ if (i == l1.size() || i == l2.size())
+ return l1.size() - l2.size();
+ Symbol s1 = (Symbol)l1.get(i);
+ Symbol s2 = (Symbol)l2.get(i);
+ if (s1 == s2) continue;
+ int c = s1.nameString().compareTo(s2.nameString());
+ if (c != 0) return c;
+ return s1.id - s2.id;
+ }
}
public boolean equals(Object o) {
return false;
}
+ public LinkedList getOwners(Symbol symbol) {
+ LinkedList owners = new LinkedList();
+ while (true) {
+ owners.addFirst(symbol);
+ if (symbol.isRoot()) break;
+ if (symbol.isNone()) break;
+ if (symbol.isError()) break;
+ symbol = symbol.owner();
+ }
+ return owners;
+ }
};
///////////////////////// COLLECTORS ////////////////////////////