9995
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
|
13 |
|
|
14 |
"{ NameSpace: Tools }"
|
|
15 |
|
|
16 |
Object subclass:#ClassSorter
|
|
17 |
instanceVariableNames:'indents order'
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Interface-Browsers-New'
|
|
21 |
!
|
|
22 |
|
|
23 |
!ClassSorter class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
|
37 |
! !
|
|
38 |
|
|
39 |
!ClassSorter class methodsFor:'sorting'!
|
|
40 |
|
|
41 |
sort: classes
|
|
42 |
|
|
43 |
^self new sort: classes
|
|
44 |
|
|
45 |
"Created: / 21-01-2008 / 19:40:19 / janfrog"
|
|
46 |
! !
|
|
47 |
|
|
48 |
!ClassSorter methodsFor:'filtering'!
|
|
49 |
|
|
50 |
sort: classes
|
|
51 |
"Sort nodes according to their position in the class hierarchy"
|
|
52 |
|
|
53 |
| supersChain |
|
|
54 |
self initializeResults.
|
|
55 |
classes do:
|
|
56 |
[:class |
|
|
57 |
supersChain := class withAllSuperclasses reversed.
|
|
58 |
supersChain removeAllSuchThat: [:cl | (classes includes: cl) not].
|
|
59 |
order add: supersChain "contents" -> class].
|
|
60 |
self buildIndentIndex.
|
|
61 |
^self collectSortedClasses
|
|
62 |
|
|
63 |
"Modified: / 21-01-2008 / 19:43:24 / janfrog"
|
|
64 |
! !
|
|
65 |
|
|
66 |
!ClassSorter methodsFor:'private'!
|
|
67 |
|
|
68 |
buildIndentIndex
|
|
69 |
indents := IdentityDictionary new.
|
|
70 |
order do: [:assoc | indents at: assoc value put: assoc key size - 1].
|
|
71 |
!
|
|
72 |
|
|
73 |
collectSortedClasses
|
|
74 |
^order asArray collect: [:assoc | assoc value]
|
|
75 |
|
|
76 |
"Created: / 21-01-2008 / 19:41:54 / janfrog"
|
|
77 |
!
|
|
78 |
|
|
79 |
initializeResults
|
|
80 |
| i chain2 chain1 result max |
|
|
81 |
order := SortedCollection sortBlock:
|
|
82 |
[:assoc1 :assoc2 |
|
|
83 |
result := nil.
|
|
84 |
chain1 := assoc1 key.
|
|
85 |
chain2 := assoc2 key.
|
|
86 |
max := chain1 size min: chain2 size.
|
|
87 |
i := 1.
|
|
88 |
[result isNil and: [i <= max]] whileTrue:
|
|
89 |
[(chain1 at: i) = (chain2 at: i)
|
|
90 |
ifTrue: [i := i + 1]
|
|
91 |
ifFalse: [result := (chain1 at: i) name < (chain2 at: i) name]].
|
|
92 |
result isNil ifTrue: [chain1 size < chain2 size] ifFalse: [result]]
|
|
93 |
! !
|
|
94 |
|
|
95 |
!ClassSorter class methodsFor:'documentation'!
|
|
96 |
|
|
97 |
version_CVS
|
|
98 |
^ '$Header: /cvs/stx/stx/libtool/Tools__ClassSorter.st,v 1.1 2011-07-01 13:28:45 cg Exp $'
|
|
99 |
!
|
|
100 |
|
|
101 |
version_SVN
|
|
102 |
^ '§Id: Tools__ClassSorter.st 7486 2009-10-26 22:06:24Z vranyj1 §'
|
|
103 |
! !
|