200
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCClassDefinition subclass:#MCTraitDefinition
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
693
|
7 |
category:'SCM-Monticello-Modeling'
|
200
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!MCTraitDefinition class methodsFor:'as yet unclassified'!
|
|
12 |
|
|
13 |
name: classNameString traitComposition: traitCompositionString category: categoryString comment: commentString commentStamp: commentStamp
|
|
14 |
^ self instanceLike:
|
|
15 |
(self new initializeWithName: classNameString
|
|
16 |
traitComposition: traitCompositionString
|
|
17 |
category: categoryString
|
|
18 |
comment: commentString
|
|
19 |
commentStamp: commentStamp)
|
|
20 |
|
|
21 |
! !
|
|
22 |
|
|
23 |
!MCTraitDefinition methodsFor:'accessing'!
|
|
24 |
|
|
25 |
classTraitCompositionString
|
|
26 |
^self traitComposition ifNil: ['{}'].
|
|
27 |
! !
|
|
28 |
|
|
29 |
!MCTraitDefinition methodsFor:'comparing'!
|
|
30 |
|
|
31 |
hash
|
|
32 |
| hash |
|
|
33 |
hash := String stringHash: name initialHash: 0.
|
|
34 |
hash := String stringHash: self traitCompositionString initialHash: hash.
|
|
35 |
hash := String stringHash: (category ifNil: ['']) initialHash: hash.
|
|
36 |
^ hash
|
|
37 |
|
|
38 |
!
|
|
39 |
|
|
40 |
requirements
|
725
|
41 |
"Assuming that traits in a composition can be identified by
|
|
42 |
testing for the first character beeing an uppercase character
|
|
43 |
(and thus not a special character such as {, # etc.)"
|
200
|
44 |
|
725
|
45 |
| tokens traitNames |
|
|
46 |
self hasTraitComposition ifFalse: [ ^Array new ].
|
|
47 |
tokens := Scanner new scanTokens: self traitComposition.
|
|
48 |
traitNames := tokens select: [:each | each isString and:[each first isUppercase]].
|
|
49 |
^traitNames asArray
|
200
|
50 |
! !
|
|
51 |
|
774
|
52 |
!MCTraitDefinition methodsFor:'converting'!
|
|
53 |
|
|
54 |
asChange
|
|
55 |
^TraitDefinitionChange new
|
776
|
56 |
mcDefinition: self;
|
774
|
57 |
baseTrait: superclassName;
|
|
58 |
traitComposition: traitComposition;
|
|
59 |
className: name;
|
|
60 |
category: category;
|
|
61 |
yourself
|
|
62 |
! !
|
|
63 |
|
200
|
64 |
!MCTraitDefinition methodsFor:'initializing'!
|
|
65 |
|
|
66 |
initializeWithName: classNameString
|
|
67 |
traitComposition: traitCompositionString
|
|
68 |
category: categoryString
|
|
69 |
comment: commentString
|
|
70 |
commentStamp: commentStampString
|
|
71 |
|
|
72 |
name := classNameString asSymbol.
|
|
73 |
traitComposition := traitCompositionString.
|
|
74 |
category := categoryString.
|
|
75 |
comment := commentString asStringWithSqueakLineEndings.
|
|
76 |
commentStamp := commentStampString ifNil: [self defaultCommentStamp]
|
|
77 |
|
|
78 |
"Modified: / 12-09-2010 / 16:06:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
79 |
! !
|
|
80 |
|
|
81 |
!MCTraitDefinition methodsFor:'installing'!
|
|
82 |
|
|
83 |
load
|
|
84 |
| trait |
|
|
85 |
(trait := self createClass) ifNotNil: [
|
|
86 |
self hasComment ifTrue: [trait classComment: comment stamp: commentStamp]]
|
|
87 |
! !
|
|
88 |
|
|
89 |
!MCTraitDefinition methodsFor:'printing'!
|
|
90 |
|
|
91 |
printDefinitionOn: stream
|
|
92 |
stream nextPutAll: 'Trait named: #', self className;
|
|
93 |
cr;
|
|
94 |
tab;
|
|
95 |
nextPutAll: 'uses: ';
|
|
96 |
nextPutAll: self traitCompositionString;
|
|
97 |
cr;
|
|
98 |
tab;
|
|
99 |
nextPutAll: 'category: ';
|
|
100 |
store: self category asString
|
|
101 |
|
|
102 |
! !
|
|
103 |
|
|
104 |
!MCTraitDefinition methodsFor:'testing'!
|
|
105 |
|
|
106 |
hasClassInstanceVariables
|
|
107 |
^ false
|
|
108 |
|
|
109 |
|
|
110 |
! !
|
|
111 |
|
|
112 |
!MCTraitDefinition methodsFor:'visiting'!
|
|
113 |
|
|
114 |
= aDefinition
|
|
115 |
"/self flag: #traits. "Ugly we harcoded the super superclass method. We will have to refactor the definition hierarchy"
|
|
116 |
|
|
117 |
^ (self isRevisionOf: aDefinition)
|
|
118 |
and: [self traitCompositionString = aDefinition traitCompositionString]
|
|
119 |
and: [category = aDefinition category]
|
|
120 |
and: [comment = aDefinition comment]
|
|
121 |
|
|
122 |
"Modified: / 14-09-2010 / 20:48:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
123 |
!
|
|
124 |
|
|
125 |
accept: aVisitor
|
|
126 |
^ aVisitor visitTraitDefinition: self
|
|
127 |
|
|
128 |
!
|
|
129 |
|
|
130 |
createClass
|
|
131 |
^Trait
|
|
132 |
named: name
|
|
133 |
uses: (Compiler evaluate: self traitCompositionString)
|
|
134 |
category: category
|
|
135 |
|
|
136 |
|
|
137 |
! !
|
|
138 |
|
|
139 |
!MCTraitDefinition class methodsFor:'documentation'!
|
|
140 |
|
|
141 |
version
|
776
|
142 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCTraitDefinition.st,v 1.6 2013-04-02 19:24:41 cg Exp $'
|
200
|
143 |
!
|
|
144 |
|
|
145 |
version_CVS
|
776
|
146 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCTraitDefinition.st,v 1.6 2013-04-02 19:24:41 cg Exp $'
|
200
|
147 |
!
|
|
148 |
|
|
149 |
version_SVN
|
|
150 |
^ '§Id: MCTraitDefinition.st 17 2010-10-13 12:07:52Z vranyj1 §'
|
|
151 |
! !
|
725
|
152 |
|