author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 14 Nov 2018 12:57:13 +0100 | |
branch | jv |
changeset 1095 | 87f223484bc3 |
parent 619 | 12fc8c0ad5c8 |
permissions | -rw-r--r-- |
1095
87f223484bc3
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
619
diff
changeset
|
1 |
"{ Encoding: utf8 }" |
87f223484bc3
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
619
diff
changeset
|
2 |
|
69 | 3 |
"{ Package: 'stx:goodies/monticello' }" |
4 |
||
5 |
Object subclass:#MCDependencySorter |
|
6 |
instanceVariableNames:'required provided orderedItems' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
619 | 9 |
category:'SCM-Monticello-Loading' |
69 | 10 |
! |
11 |
||
12 |
||
236 | 13 |
!MCDependencySorter class methodsFor:'initialization'! |
14 |
||
15 |
new |
|
16 |
^self basicNew initialize |
|
17 |
! ! |
|
18 |
||
69 | 19 |
!MCDependencySorter class methodsFor:'as yet unclassified'! |
20 |
||
21 |
items: aCollection |
|
22 |
^ self new addAll: aCollection |
|
23 |
! |
|
24 |
||
25 |
sortItems: aCollection |
|
26 |
| sorter | |
|
236 | 27 |
sorter := self items: aCollection. |
69 | 28 |
sorter externalRequirements do: [:req | sorter addProvision: req]. |
29 |
^ sorter orderedItems. |
|
30 |
! ! |
|
31 |
||
32 |
!MCDependencySorter methodsFor:'accessing'! |
|
33 |
||
34 |
externalRequirements |
|
35 |
| unloaded providedByUnloaded | |
|
36 |
unloaded := self itemsWithMissingRequirements. |
|
37 |
providedByUnloaded := (unloaded gather: [:e | e provisions]) asSet. |
|
38 |
^ required keys reject: [:ea | providedByUnloaded includes: ea ] |
|
39 |
! |
|
40 |
||
41 |
itemsWithMissingRequirements |
|
42 |
| items | |
|
236 | 43 |
items := Set new. |
69 | 44 |
required do: [:ea | items addAll: ea]. |
45 |
^ items |
|
236 | 46 |
|
69 | 47 |
! ! |
48 |
||
49 |
!MCDependencySorter methodsFor:'building'! |
|
50 |
||
51 |
add: anItem |
|
52 |
| requirements | |
|
236 | 53 |
requirements := self unresolvedRequirementsFor: anItem. |
69 | 54 |
requirements isEmpty |
55 |
ifTrue: [self addToOrder: anItem] |
|
56 |
ifFalse: [self addRequirements: requirements for: anItem] |
|
57 |
! |
|
58 |
||
59 |
addAll: aCollection |
|
60 |
aCollection asArray sort do: [:ea | self add: ea] |
|
61 |
! |
|
62 |
||
63 |
addExternalProvisions: aCollection |
|
64 |
(aCollection intersection: self externalRequirements) |
|
65 |
do: [:ea | self addProvision: ea] |
|
66 |
! ! |
|
67 |
||
236 | 68 |
!MCDependencySorter methodsFor:'initialization'! |
69 | 69 |
|
70 |
initialize |
|
236 | 71 |
super initialize. |
72 |
provided := Set new. |
|
73 |
required := Dictionary new. |
|
74 |
orderedItems := OrderedCollection new. |
|
69 | 75 |
! ! |
76 |
||
77 |
!MCDependencySorter methodsFor:'private'! |
|
78 |
||
79 |
addProvision: anObject |
|
80 |
| newlySatisfied | |
|
81 |
provided add: anObject. |
|
236 | 82 |
newlySatisfied := required removeKey: anObject ifAbsent: [#()]. |
69 | 83 |
self addAll: newlySatisfied. |
84 |
! |
|
85 |
||
86 |
addRequirement: reqObject for: itemObject |
|
87 |
(self itemsRequiring: reqObject) add: itemObject |
|
88 |
! |
|
89 |
||
90 |
addRequirements: aCollection for: anObject |
|
91 |
aCollection do: [:ea | self addRequirement: ea for: anObject] |
|
92 |
! |
|
93 |
||
94 |
addToOrder: anItem |
|
95 |
orderedItems add: anItem. |
|
96 |
anItem provisions do: [:ea | self addProvision: ea]. |
|
97 |
! |
|
98 |
||
99 |
itemsRequiring: anObject |
|
100 |
^ required at: anObject ifAbsentPut: [Set new] |
|
101 |
! |
|
102 |
||
103 |
unresolvedRequirementsFor: anItem |
|
104 |
^ anItem requirements difference: provided |
|
105 |
! ! |
|
106 |
||
107 |
!MCDependencySorter methodsFor:'sorting'! |
|
108 |
||
109 |
orderedItems |
|
110 |
^ orderedItems |
|
111 |
! ! |
|
112 |
||
113 |
!MCDependencySorter class methodsFor:'documentation'! |
|
114 |
||
115 |
version |
|
619 | 116 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCDependencySorter.st,v 1.4 2012-09-11 21:21:20 cg Exp $' |
236 | 117 |
! |
118 |
||
119 |
version_CVS |
|
619 | 120 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCDependencySorter.st,v 1.4 2012-09-11 21:21:20 cg Exp $' |
236 | 121 |
! |
122 |
||
123 |
version_SVN |
|
1095
87f223484bc3
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
Patrik Svestka <patrik.svestka@gmail.com>
parents:
619
diff
changeset
|
124 |
^ '§Id: MCDependencySorter.st 7 2010-09-12 07:18:55Z vranyj1 §' |
69 | 125 |
! ! |