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