author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 19 Jul 2017 09:42:32 +0200 | |
branch | jv |
changeset 17619 | edb119820fcb |
parent 12431 | 9f0c59c742d5 |
child 18532 | cccb41254edf |
permissions | -rw-r--r-- |
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 |
|
12123
4bde08cebd48
trunk branched into /branches/jv
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
9995
diff
changeset
|
98 |
^ '§Header: /cvs/stx/stx/libtool/Tools__ClassSorter.st,v 1.1 2011/07/01 13:28:45 cg Exp §' |
9995 | 99 |
! |
100 |
||
12431
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
101 |
version_HG |
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
102 |
|
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
103 |
^ '$Changeset: <not expanded> $' |
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
104 |
! |
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
105 |
|
9995 | 106 |
version_SVN |
12128
a7ff7d66ee85
Improvements in LintHighlighter, few fixes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12123
diff
changeset
|
107 |
^ '$Id: Tools__ClassSorter.st 7854 2012-01-30 17:49:41Z vranyj1 $' |
12431
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
108 |
! ! |
9f0c59c742d5
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
12128
diff
changeset
|
109 |