author | vrany |
Mon, 25 Jul 2011 12:40:48 +0200 | |
changeset 2470 | 47bec7c32db6 |
parent 2414 | 571f0daaef72 |
child 2503 | bbdc31516652 |
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 |
||
2369 | 126 |
delta |
127 |
||
128 |
| mth | |
|
129 |
||
130 |
self isMethodCodeChange ifFalse:[^super delta]. |
|
131 |
mth := self changeMethod. |
|
132 |
mth ifNil:[^#+]. |
|
133 |
^(self class isSource: self source sameSourceAs: mth source) |
|
134 |
ifTrue:[#=] |
|
135 |
ifFalse:[#~] |
|
136 |
! |
|
137 |
||
2470 | 138 |
imageSource |
139 |
||
140 |
| mth | |
|
141 |
||
142 |
self isMethodCodeChange ifFalse:[^super imageSource]. |
|
143 |
mth := self changeMethod. |
|
144 |
^mth isNil ifTrue: [nil] ifFalse:[mth source] |
|
145 |
||
146 |
"Created: / 19-07-2011 / 12:02:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
147 |
! |
|
148 |
||
652 | 149 |
methodCategory |
1234 | 150 |
|
652 | 151 |
^ methodCategory |
152 |
||
153 |
"Created: / 7.2.1998 / 19:47:53 / cg" |
|
154 |
! |
|
155 |
||
1234 | 156 |
previousPackage |
157 |
| isNewMethod | |
|
158 |
isNewMethod := self previousVersion isNil. |
|
159 |
isNewMethod ifFalse:[ |
|
160 |
^ self previousVersion package. |
|
161 |
]. |
|
162 |
||
163 |
^ nil |
|
164 |
! |
|
165 |
||
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
166 |
previousVersion |
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
167 |
"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
|
168 |
|
1073 | 169 |
^ previousVersion |
170 |
! |
|
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
171 |
|
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
172 |
previousVersion:something |
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
173 |
"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
|
174 |
|
1073 | 175 |
previousVersion := something. |
176 |
! |
|
956
0c6c209df4e9
keep previousVersion of method in changeSet
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
177 |
|
1234 | 178 |
previousVersionSource |
179 |
"return the value of the instance variable 'previousVersion' (automatically generated)" |
|
180 |
||
181 |
previousVersion isNil ifTrue:[^ nil]. |
|
182 |
^ previousVersion source |
|
183 |
! |
|
184 |
||
648 | 185 |
selector |
186 |
^ selector |
|
187 |
||
188 |
"Created: / 6.2.1998 / 13:29:25 / cg" |
|
911 | 189 |
! |
190 |
||
191 |
selector:aSymbol |
|
2257 | 192 |
self assert:(aSymbol isSymbol). |
193 |
||
911 | 194 |
selector := aSymbol |
195 |
||
196 |
"Created: / 6.2.1998 / 13:29:25 / cg" |
|
0 | 197 |
! ! |
198 |
||
849 | 199 |
!MethodChange methodsFor:'applying'! |
200 |
||
201 |
apply |
|
202 |
"apply the change" |
|
203 |
||
2020
5b3af99a4829
changed #apply: use #applyChange
Stefan Vogel <sv@exept.de>
parents:
1845
diff
changeset
|
204 |
|class| |
1322 | 205 |
|
2020
5b3af99a4829
changed #apply: use #applyChange
Stefan Vogel <sv@exept.de>
parents:
1845
diff
changeset
|
206 |
class := self changeClass. |
1196 | 207 |
class isNil ifTrue:[ |
2077 | 208 |
self error:('Cannot apply change for missing class: ' , className) mayProceed:true. |
209 |
^ self |
|
1196 | 210 |
]. |
849 | 211 |
class compile:source classified:methodCategory logged:true. |
212 |
! ! |
|
213 |
||
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
214 |
!MethodChange methodsFor:'comparing'! |
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 |
isForSameAs:changeB |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
217 |
"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
|
218 |
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
|
219 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
220 |
"/ 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
|
221 |
changeB isMethodChange ifFalse:[^ false]. |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
222 |
|
1199 | 223 |
selector ~= changeB selector ifTrue:[^ false]. |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
224 |
className ~= changeB className ifTrue:[^ false]. |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
225 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
226 |
^ true |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
227 |
! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
228 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
229 |
sameAs:changeB |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
230 |
"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
|
231 |
|
798 | 232 |
(self isForSameAs:changeB) ifFalse:[^ false]. |
1509 | 233 |
(self sameSourceAs:changeB) ifTrue:[^ true]. |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
234 |
|
1509 | 235 |
^ false. |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
236 |
|
1509 | 237 |
"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
|
238 |
! ! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
779
diff
changeset
|
239 |
|
1325 | 240 |
!MethodChange methodsFor:'converting'! |
241 |
||
242 |
asNamedMethodChange |
|
243 |
^ NamedMethodChange fromMethodChange:self |
|
244 |
! ! |
|
245 |
||
2369 | 246 |
!MethodChange methodsFor:'fileout'! |
247 |
||
248 |
basicFileOutOn: aStream |
|
249 |
||
250 |
|cat | |
|
251 |
||
252 |
self isMethodCodeChange ifFalse:[^super basicFileOutOn: aStream]. |
|
253 |
||
254 |
||
255 |
||
256 |
aStream nextPutChunkSeparator. |
|
257 |
self className printOn:aStream. |
|
258 |
"/ self printClassNameOn:aStream. |
|
259 |
||
260 |
(privacy ? #public) ~~ #public ifTrue:[ |
|
261 |
aStream space; nextPutAll:privacy; nextPutAll:'MethodsFor:'. |
|
262 |
] ifFalse:[ |
|
263 |
aStream nextPutAll:' methodsFor:'. |
|
264 |
]. |
|
265 |
||
266 |
cat := methodCategory ? ''. |
|
267 |
aStream nextPutAll:cat asString storeString. |
|
268 |
aStream nextPutChunkSeparator; cr; cr. |
|
269 |
||
270 |
source := self source. |
|
271 |
source isNil ifTrue:[ |
|
272 |
ClassDescription fileOutErrorSignal |
|
273 |
raiseRequestWith:self |
|
274 |
errorString:(' - no source for method: ' , |
|
275 |
self className , '>>' , selector). |
|
276 |
||
277 |
] ifFalse:[ |
|
278 |
aStream nextChunkPut:source. |
|
279 |
]. |
|
280 |
aStream space. |
|
281 |
aStream nextPutChunkSeparator. |
|
282 |
aStream cr; cr |
|
283 |
||
284 |
"Modified: / 05-12-2009 / 12:38:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
285 |
! ! |
|
286 |
||
963 | 287 |
!MethodChange methodsFor:'printing & storing'! |
0 | 288 |
|
7 | 289 |
printOn:aStream |
800 | 290 |
"append a user printed representation of the receiver to aStream. |
291 |
The format is suitable for a human - not meant to be read back." |
|
292 |
||
2170 | 293 |
aStream |
294 |
nextPutAll:(self className ? 'unnamed'); |
|
295 |
nextPutAll:'>>'; |
|
296 |
nextPutAll:(selector ? '?'); |
|
297 |
nextPutAll:' {'; |
|
298 |
nextPutAll:(methodCategory ? '?'); |
|
299 |
nextPutAll:'}' |
|
1512 | 300 |
|
1833
cf60e3c0087e
care for bad (nil) methodCategory
Claus Gittinger <cg@exept.de>
parents:
1512
diff
changeset
|
301 |
"Modified: / 04-10-2006 / 16:46:01 / cg" |
2170 | 302 |
"Modified: / 07-11-2008 / 08:29:03 / Jan Vrany <vranyj1@fel.cvut.cz>" |
779 | 303 |
! |
304 |
||
896 | 305 |
printWithoutClassNameOn:aStream |
306 |
(className endsWith:' class') ifTrue:[ |
|
307 |
aStream nextPutAll:'class ' |
|
308 |
]. |
|
309 |
aStream nextPutAll:selector |
|
310 |
! |
|
311 |
||
312 |
printWithoutOwningClassOn:aStream |
|
2022
a498c70c0aac
changed #printWithoutOwningClassOn:
Claus Gittinger <cg@exept.de>
parents:
2020
diff
changeset
|
313 |
self breakPoint:#cg. |
779 | 314 |
(className endsWith:' class') ifTrue:[ |
315 |
aStream nextPutAll:'class ' |
|
316 |
]. |
|
317 |
aStream nextPutAll:selector |
|
1845 | 318 |
! |
319 |
||
320 |
sourceForMethod |
|
2157 | 321 |
^ '(' , className , ' compiledMethodAt:' , selector asSymbol storeString, ')' |
1845 | 322 |
|
323 |
"Created: / 09-10-2006 / 13:58:09 / cg" |
|
0 | 324 |
! ! |
235 | 325 |
|
2369 | 326 |
|
2130 | 327 |
!MethodChange methodsFor:'testing'! |
652 | 328 |
|
329 |
isMethodChange |
|
2130 | 330 |
"true if this is a method related change" |
331 |
||
652 | 332 |
^ true |
333 |
||
334 |
"Created: / 7.2.1998 / 19:26:59 / cg" |
|
2130 | 335 |
! |
336 |
||
2187 | 337 |
isMethodChangeForVersionMethod |
338 |
^ self isMethodCodeChange |
|
339 |
and:[ AbstractSourceCodeManager isVersionMethodSelector:self selector ] |
|
340 |
! |
|
341 |
||
2130 | 342 |
isMethodCodeChange |
343 |
"true if this is a method's code change (not package, category etc.)" |
|
344 |
||
2260 | 345 |
^ true |
652 | 346 |
! ! |
347 |
||
1325 | 348 |
!MethodChange::NamedMethodChange class methodsFor:'instance creation'! |
349 |
||
350 |
fromMethodChange:aMethodChange |
|
351 |
^ self new cloneInstanceVariablesFrom:aMethodChange |
|
352 |
! ! |
|
353 |
||
354 |
!MethodChange::NamedMethodChange methodsFor:'accessing'! |
|
355 |
||
356 |
changeName:something |
|
357 |
changeName := something. |
|
358 |
! ! |
|
359 |
||
360 |
!MethodChange::NamedMethodChange methodsFor:'printing & storing'! |
|
361 |
||
362 |
printOn:aStream |
|
363 |
changeName notNil ifTrue:[ |
|
364 |
changeName printOn:aStream. |
|
365 |
^ self. |
|
366 |
]. |
|
367 |
super printOn:aStream |
|
368 |
! ! |
|
369 |
||
235 | 370 |
!MethodChange class methodsFor:'documentation'! |
371 |
||
2369 | 372 |
version_CVS |
2470 | 373 |
^ '$Header: /cvs/stx/stx/libbasic3/MethodChange.st,v 1.58 2011-07-25 10:40:48 vrany Exp $' |
2187 | 374 |
! |
375 |
||
2369 | 376 |
version_SVN |
2414 | 377 |
^ '§ Id: MethodChange.st 1867 2011-06-08 21:57:08Z vranyj1 §' |
235 | 378 |
! ! |