@@ -43,9 +43,9 @@ final class MutableState {
4343
4444 def result (): Array [String ] = synchronized {
4545 // Because - comes before . in ASCII this little hack affects the ordering so that A[X] comes before A.B[X]
46- val sortHack = " -OMG- "
46+ val sortHack = " -"
4747
48- val b = SortedSet .newBuilder[String ]
48+ val b = SortedSet .newBuilder[Result ]
4949
5050 // Pass 1
5151 for (root <- scopes.valuesIterator) {
@@ -55,30 +55,30 @@ final class MutableState {
5555
5656 // Pass 2
5757 for (root <- scopes.valuesIterator) {
58- val name = root.symbol.value.stripSuffix(" #" ).stripSuffix(" ." )
59- val prefix = {
60- val lang = if ( root.isJsType) " J " else " S "
61- val typ = root.scopeType.id
62- s " $name$sortHack [ $lang$typ ] "
63- }
58+ val scopeName = root.symbol.value.stripSuffix(" #" ).stripSuffix(" ." )
59+ val flagLang = if (root.isJsType) " J " else " S "
60+ val flagTyp = root.scopeType.id
61+ val flags = flagLang + flagTyp
62+ val prefix = s " $scopeName [ $flags ] "
63+ val scopeKey = s " $scopeName$sortHack [ $flags "
6464
6565 var membersFound = false
6666 for {
6767 s <- root :: scopeParents(root)
6868 v <- s.directMembers
6969 } {
7070 membersFound = true
71- b += prefix + v
71+ val key = (scopeKey, v.name, v.desc)
72+ b += Result (key, prefix + v.desc)
7273 }
7374
74- if (! membersFound && ! name.endsWith(" /package" ))
75- b += prefix.trim
75+ if (! membersFound && ! scopeName.endsWith(" /package" )) {
76+ val key = (scopeKey, " " , " " )
77+ b += Result (key, prefix.trim)
78+ }
7679 }
7780
78- val array = b.result().toArray
79- for (i <- array.indices)
80- array(i) = array(i).replace(sortHack, " " )
81- array
81+ b.result().iterator.map(_.value).toArray
8282 }
8383}
8484
@@ -96,13 +96,19 @@ object MutableState {
9696 (val scopeType : ScopeType ,
9797 val parents : Set [Symbol ]) {
9898
99- private [MutableState ] val directMembers = mutable.Set .empty[String ]
99+ private [MutableState ] val directMembers = mutable.Set .empty[Member ]
100100 private [MutableState ] var isJsType = false
101101
102- def add (ov : Option [String ]): Unit =
103- ov.foreach(add(_))
104-
105- def add (v : String ): Unit =
102+ def add (v : Member ): Unit =
106103 synchronized (directMembers += v)
107104 }
105+
106+ final case class Member (name : String , desc : String )
107+
108+ private [MutableState ] final case class Result (sortKey : Result .SortKey , value : String )
109+
110+ private [MutableState ] object Result {
111+ type SortKey = (String , String , String ) // prefix, name, desc
112+ implicit val ordering : Ordering [Result ] = Ordering .by(_.sortKey)
113+ }
108114}
0 commit comments