author | Claus Gittinger <cg@exept.de> |
Wed, 07 Apr 2010 15:32:18 +0200 | |
changeset 2258 | b976e8e2874e |
parent 2257 | 808be4648d12 |
child 2260 | fc4873beed5b |
permissions | -rw-r--r-- |
4 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
25 | 3 |
All Rights Reserved |
4 | 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 |
" |
|
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
12 |
"{ Package: 'stx:libbasic3' }" |
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
13 |
|
0 | 14 |
ClassChange subclass:#MethodChange |
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
15 |
instanceVariableNames:'selector methodCategory privacy previousVersion' |
235 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'System-Changes' |
|
0 | 19 |
! |
20 |
||
1325 | 21 |
MethodChange subclass:#NamedMethodChange |
22 |
instanceVariableNames:'changeName' |
|
23 |
classVariableNames:'' |
|
24 |
poolDictionaries:'' |
|
25 |
privateIn:MethodChange |
|
26 |
! |
|
27 |
||
25 | 28 |
!MethodChange class methodsFor:'documentation'! |
29 |
||
30 |
copyright |
|
31 |
" |
|
32 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
33 |
All Rights Reserved |
|
10 | 34 |
|
25 | 35 |
This software is furnished under a license and may be used |
36 |
only in accordance with the terms of that license and with the |
|
37 |
inclusion of the above copyright notice. This software may not |
|
38 |
be provided or otherwise made available to, or used by, any |
|
39 |
other person. No title to or ownership of the software is |
|
40 |
hereby transferred. |
|
41 |
" |
|
42 |
! |
|
43 |
||
45 | 44 |
documentation |
45 |
" |
|
46 |
instances represent method-changes (as done in the browser). |
|
47 |
They are typically held in a ChangeSet. |
|
235 | 48 |
|
49 |
[author:] |
|
50 |
Claus Gittinger |
|
45 | 51 |
" |
25 | 52 |
! ! |
10 | 53 |
|
0 | 54 |
!MethodChange class methodsFor:'instance creation'! |
55 |
||
2119 | 56 |
class:cls selector:sel category:cat |
57 |
^ self basicNew class:cls selector:sel category:cat |
|
58 |
||
59 |
||
60 |
! |
|
61 |
||
102
3f85fe87cc58
include category in methodChanges
Claus Gittinger <cg@exept.de>
parents:
85
diff
changeset
|
62 |
class:cls selector:sel source:src category:cat |
3f85fe87cc58
include category in methodChanges
Claus Gittinger <cg@exept.de>
parents:
85
diff
changeset
|
63 |
^ self basicNew class:cls selector:sel source:src category:cat |
1073 | 64 |
! |
65 |
||
2119 | 66 |
className:clsName selector:sel category:cat |
67 |
^ self basicNew className:clsName selector:sel category:cat |
|
68 |
||
69 |
"Created: / 12-11-2006 / 15:54:25 / cg" |
|
70 |
! |
|
71 |
||
1073 | 72 |
className:clsName selector:sel source:src category:cat |
73 |
^ self basicNew className:clsName selector:sel source:src category:cat |
|
0 | 74 |
! ! |
75 |
||
76 |
!MethodChange methodsFor:'accessing'! |
|
77 |
||
1073 | 78 |
category |
79 |
^ methodCategory |
|
80 |
! |
|
81 |
||
911 | 82 |
category: aCategory |
83 |
methodCategory := aCategory |
|
84 |
||
85 |
"Created: / 7.2.1998 / 19:47:53 / cg" |
|
86 |
! |
|
87 |
||
852 | 88 |
changeMethod |
89 |
|cls| |
|
90 |
||
91 |
cls := self changeClass. |
|
92 |
cls isNil ifTrue:[^ nil]. |
|
93 |
^ cls compiledMethodAt:selector |
|
94 |
||
95 |
"Created: / 7.2.1998 / 19:47:53 / cg" |
|
96 |
! |
|
97 |
||
850 | 98 |
changeSelector |
99 |
^ selector |
|
100 |
||
101 |
"Created: / 6.2.1998 / 13:29:25 / cg" |
|
102 |
! |
|
103 |
||
102
3f85fe87cc58
include category in methodChanges
Claus Gittinger <cg@exept.de>
parents:
85
diff
changeset
|
104 |
class:cls selector:sel source:src category:cat |
1288 | 105 |
self className:(cls name) selector:sel source:src category:cat |
648 | 106 |
! |
107 |
||
654 | 108 |
className:clsName selector:sel source:src category:cat |
1288 | 109 |
self className:clsName selector:sel source:src category:cat privacy:nil |
654 | 110 |
! |
111 |
||
112 |
className:clsName selector:sel source:src category:cat privacy:priv |
|
2258
b976e8e2874e
comment/format in: #selector:
Claus Gittinger <cg@exept.de>
parents:
2257
diff
changeset
|
113 |
self assert:(src isString). |
b976e8e2874e
comment/format in: #selector:
Claus Gittinger <cg@exept.de>
parents:
2257
diff
changeset
|
114 |
self assert:(sel isString or:[sel isSymbol]). |
1288 | 115 |
|
654 | 116 |
className := clsName. |
117 |
selector := sel. |
|
118 |
source := src. |
|
119 |
methodCategory := cat. |
|
120 |
privacy := priv. |
|
121 |
||
122 |
"Created: / 16.2.1998 / 12:29:49 / cg" |
|
123 |
"Modified: / 16.2.1998 / 14:28:12 / cg" |
|
124 |
! |
|
125 |
||
652 | 126 |
methodCategory |
1234 | 127 |
|
652 | 128 |
^ methodCategory |
129 |
||
130 |
"Created: / 7.2.1998 / 19:47:53 / cg" |
|
131 |
! |
|
132 |
||
1234 | 133 |
previousPackage |
134 |
| isNewMethod | |
|
135 |
isNewMethod := self previousVersion isNil. |
|
136 |
isNewMethod ifFalse:[ |
|
137 |
^ self previousVersion package. |
|
138 |
]. |
|
139 |
||
140 |
^ nil |
|
141 |
! |
|
142 |
||
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
143 |
previousVersion |
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
144 |
"return the value of the instance variable 'previousVersion' (automatically generated)" |
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
145 |
|
1073 | 146 |
^ previousVersion |
147 |
! |
|
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
148 |
|
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
149 |
previousVersion:something |
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
150 |
"set the value of the instance variable 'previousVersion' (automatically generated)" |
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
151 |
|
1073 | 152 |
previousVersion := something. |
153 |
! |
|
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
154 |
|
1234 | 155 |
previousVersionSource |
156 |
"return the value of the instance variable 'previousVersion' (automatically generated)" |
|
157 |
||
158 |
previousVersion isNil ifTrue:[^ nil]. |
|
159 |
^ previousVersion source |
|
160 |
! |
|
161 |
||
648 | 162 |
selector |
163 |
^ selector |
|
164 |
||
165 |
"Created: / 6.2.1998 / 13:29:25 / cg" |
|
911 | 166 |
! |
167 |
||
168 |
selector:aSymbol |
|
2257 | 169 |
self assert:(aSymbol isSymbol). |
170 |
||
911 | 171 |
selector := aSymbol |
172 |
||
173 |
"Created: / 6.2.1998 / 13:29:25 / cg" |
|
0 | 174 |
! ! |
175 |
||
849 | 176 |
!MethodChange methodsFor:'applying'! |
177 |
||
178 |
apply |
|
179 |
"apply the change" |
|
180 |
||
2020
5b3af99a4829
changed #apply: use #applyChange
Stefan Vogel <sv@exept.de>
parents:
1845
diff
changeset
|
181 |
|class| |
1322 | 182 |
|
2020
5b3af99a4829
changed #apply: use #applyChange
Stefan Vogel <sv@exept.de>
parents:
1845
diff
changeset
|
183 |
class := self changeClass. |
1196 | 184 |
class isNil ifTrue:[ |
2077 | 185 |
self error:('Cannot apply change for missing class: ' , className) mayProceed:true. |
186 |
^ self |
|
1196 | 187 |
]. |
849 | 188 |
class compile:source classified:methodCategory logged:true. |
189 |
! ! |
|
190 |
||
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
191 |
!MethodChange methodsFor:'comparing'! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
192 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
193 |
isForSameAs:changeB |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
194 |
"return true, if the given change represents a change for the same |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
195 |
thingy as the receiver (i.e. same method, same definition etc.)." |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
196 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
197 |
"/ I am a methodChange - B must be as well. |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
198 |
changeB isMethodChange ifFalse:[^ false]. |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
199 |
|
1199 | 200 |
selector ~= changeB selector ifTrue:[^ false]. |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
201 |
className ~= changeB className ifTrue:[^ false]. |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
202 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
203 |
^ true |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
204 |
! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
205 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
206 |
sameAs:changeB |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
207 |
"return true, if the given change represents the same change as the receiver." |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
208 |
|
798 | 209 |
(self isForSameAs:changeB) ifFalse:[^ false]. |
1509 | 210 |
(self sameSourceAs:changeB) ifTrue:[^ true]. |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
211 |
|
1509 | 212 |
^ false. |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
213 |
|
1509 | 214 |
"Modified: / 25-07-2006 / 11:23:27 / cg" |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
215 |
! ! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
216 |
|
1325 | 217 |
!MethodChange methodsFor:'converting'! |
218 |
||
219 |
asNamedMethodChange |
|
220 |
^ NamedMethodChange fromMethodChange:self |
|
221 |
! ! |
|
222 |
||
963 | 223 |
!MethodChange methodsFor:'printing & storing'! |
0 | 224 |
|
7 | 225 |
printOn:aStream |
800 | 226 |
"append a user printed representation of the receiver to aStream. |
227 |
The format is suitable for a human - not meant to be read back." |
|
228 |
||
2170 | 229 |
aStream |
230 |
nextPutAll:(self className ? 'unnamed'); |
|
231 |
nextPutAll:'>>'; |
|
232 |
nextPutAll:(selector ? '?'); |
|
233 |
nextPutAll:' {'; |
|
234 |
nextPutAll:(methodCategory ? '?'); |
|
235 |
nextPutAll:'}' |
|
1512 | 236 |
|
1833
cf60e3c0087e
care for bad (nil) methodCategory
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
237 |
"Modified: / 04-10-2006 / 16:46:01 / cg" |
2170 | 238 |
"Modified: / 07-11-2008 / 08:29:03 / Jan Vrany <vranyj1@fel.cvut.cz>" |
779 | 239 |
! |
240 |
||
896 | 241 |
printWithoutClassNameOn:aStream |
242 |
(className endsWith:' class') ifTrue:[ |
|
243 |
aStream nextPutAll:'class ' |
|
244 |
]. |
|
245 |
aStream nextPutAll:selector |
|
246 |
! |
|
247 |
||
248 |
printWithoutOwningClassOn:aStream |
|
2022
a498c70c0aac
changed #printWithoutOwningClassOn:
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
249 |
self breakPoint:#cg. |
779 | 250 |
(className endsWith:' class') ifTrue:[ |
251 |
aStream nextPutAll:'class ' |
|
252 |
]. |
|
253 |
aStream nextPutAll:selector |
|
1845 | 254 |
! |
255 |
||
256 |
sourceForMethod |
|
2157 | 257 |
^ '(' , className , ' compiledMethodAt:' , selector asSymbol storeString, ')' |
1845 | 258 |
|
259 |
"Created: / 09-10-2006 / 13:58:09 / cg" |
|
0 | 260 |
! ! |
235 | 261 |
|
2130 | 262 |
!MethodChange methodsFor:'testing'! |
652 | 263 |
|
264 |
isMethodChange |
|
2130 | 265 |
"true if this is a method related change" |
266 |
||
652 | 267 |
^ true |
268 |
||
269 |
"Created: / 7.2.1998 / 19:26:59 / cg" |
|
2130 | 270 |
! |
271 |
||
2187 | 272 |
isMethodChangeForVersionMethod |
273 |
^ self isMethodCodeChange |
|
274 |
and:[ AbstractSourceCodeManager isVersionMethodSelector:self selector ] |
|
275 |
! |
|
276 |
||
2130 | 277 |
isMethodCodeChange |
278 |
"true if this is a method's code change (not package, category etc.)" |
|
279 |
||
280 |
^ self class == MethodChange |
|
652 | 281 |
! ! |
282 |
||
1325 | 283 |
!MethodChange::NamedMethodChange class methodsFor:'instance creation'! |
284 |
||
285 |
fromMethodChange:aMethodChange |
|
286 |
^ self new cloneInstanceVariablesFrom:aMethodChange |
|
287 |
! ! |
|
288 |
||
289 |
!MethodChange::NamedMethodChange methodsFor:'accessing'! |
|
290 |
||
291 |
changeName:something |
|
292 |
changeName := something. |
|
293 |
! ! |
|
294 |
||
295 |
!MethodChange::NamedMethodChange methodsFor:'printing & storing'! |
|
296 |
||
297 |
printOn:aStream |
|
298 |
changeName notNil ifTrue:[ |
|
299 |
changeName printOn:aStream. |
|
300 |
^ self. |
|
301 |
]. |
|
302 |
super printOn:aStream |
|
303 |
! ! |
|
304 |
||
235 | 305 |
!MethodChange class methodsFor:'documentation'! |
306 |
||
307 |
version |
|
2258
b976e8e2874e
comment/format in: #selector:
Claus Gittinger <cg@exept.de>
parents:
2257
diff
changeset
|
308 |
^ '$Header: /cvs/stx/stx/libbasic3/MethodChange.st,v 1.54 2010-04-07 13:32:18 cg Exp $' |
2187 | 309 |
! |
310 |
||
311 |
version_CVS |
|
2258
b976e8e2874e
comment/format in: #selector:
Claus Gittinger <cg@exept.de>
parents:
2257
diff
changeset
|
312 |
^ '$Header: /cvs/stx/stx/libbasic3/MethodChange.st,v 1.54 2010-04-07 13:32:18 cg Exp $' |
235 | 313 |
! ! |