author | vrany |
Wed, 06 Jul 2011 13:50:11 +0200 | |
changeset 2411 | 37acd98eb083 |
parent 2378 | 9d8435b2e196 |
child 2471 | b0dd40fea5d3 |
permissions | -rw-r--r-- |
3 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
38 | 3 |
All Rights Reserved |
3 | 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 |
" |
|
932 | 12 |
"{ Package: 'stx:libbasic3' }" |
13 |
||
0 | 14 |
Object subclass:#Change |
1147 | 15 |
instanceVariableNames:'source timeOfChangeIfKnown' |
235 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'System-Changes' |
|
0 | 19 |
! |
20 |
||
633 | 21 |
!Change class methodsFor:'documentation'! |
9 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
38 | 26 |
All Rights Reserved |
9 | 27 |
|
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
abstract superclass for all kind of changes - managed in changeSets. |
|
235 | 40 |
|
41 |
[author:] |
|
42 |
Claus Gittinger |
|
9 | 43 |
" |
44 |
! ! |
|
45 |
||
1510 | 46 |
!Change class methodsFor:'support'! |
47 |
||
48 |
isSource:source1Arg sameSourceAs:source2Arg |
|
49 |
"return true, if the given sources are the same, ignoring tabs and whitespace differences." |
|
50 |
||
51 |
|source1 source2| |
|
52 |
||
53 |
source1 := source1Arg. |
|
54 |
source2 := source2Arg. |
|
55 |
||
56 |
source1 = source2 ifTrue:[^ true]. |
|
57 |
||
58 |
source1 := source1 withoutTrailingSeparators asCollectionOfLines. |
|
59 |
source2 := source2 withoutTrailingSeparators asCollectionOfLines. |
|
60 |
source1 size ~~ source2 size ifTrue:[^ false]. |
|
61 |
source1 := source1 collect:[:line | line withTabsExpanded withoutTrailingSeparators]. |
|
62 |
source2 := source2 collect:[:line | line withTabsExpanded withoutTrailingSeparators]. |
|
63 |
^ source1 = source2 |
|
64 |
||
65 |
"Created: / 25-07-2006 / 11:22:21 / cg" |
|
66 |
! ! |
|
67 |
||
647 | 68 |
!Change methodsFor:'accessing'! |
69 |
||
850 | 70 |
changeClass |
71 |
"the class of the change (nil if not present)" |
|
72 |
||
73 |
^ nil |
|
74 |
||
75 |
! |
|
76 |
||
2378 | 77 |
changeLanguage |
78 |
||
79 |
"Answer the language of the receiver. Since changesets |
|
80 |
are now supported only for Smalltalk, return SmalltalkLanguage |
|
81 |
unconditionally" |
|
82 |
||
83 |
^SmalltalkLanguage instance |
|
84 |
! |
|
85 |
||
850 | 86 |
changeSelector |
87 |
^ nil |
|
88 |
||
89 |
"Created: / 6.2.1998 / 13:29:35 / cg" |
|
90 |
! |
|
91 |
||
647 | 92 |
className |
93 |
"the className of the change" |
|
94 |
||
95 |
^ nil |
|
96 |
||
97 |
"Modified: / 15.7.1996 / 09:26:34 / cg" |
|
98 |
"Created: / 6.2.1998 / 13:06:56 / cg" |
|
99 |
! |
|
100 |
||
2378 | 101 |
delta |
102 |
||
103 |
"Returns a delta to current state as symbol: |
|
104 |
#+ .....the subject is to be added to the image (new) |
|
105 |
#- .....the subject is to be removed from the image (old) |
|
106 |
#= .....the image is up to date |
|
107 |
#~ .....change version and image version differ |
|
108 |
#? .....delta is unknown or N/A for this kind of change |
|
109 |
" |
|
110 |
||
111 |
^#? "We don't know how to compute delta for generic change" |
|
112 |
! |
|
113 |
||
909 | 114 |
file |
115 |
^ nil "/ to be added as instvar |
|
116 |
! |
|
117 |
||
118 |
file:aFile position:anInteger |
|
119 |
^ self "/ to be added |
|
120 |
! |
|
121 |
||
2411 | 122 |
nonMetaClassName |
123 |
||
124 |
^nil |
|
125 |
||
126 |
"Created: / 26-11-2009 / 16:14:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
127 |
! |
|
128 |
||
909 | 129 |
objectType:aSymbol |
130 |
^ self "/ to be added as instvar |
|
131 |
! |
|
132 |
||
2287 | 133 |
package |
134 |
^ nil |
|
135 |
! |
|
136 |
||
1052 | 137 |
prettyPrintedSource |
138 |
"return the prettyPrinted or normal source of the change" |
|
139 |
||
140 |
^ self source |
|
141 |
! |
|
142 |
||
2411 | 143 |
removed |
144 |
||
145 |
^(self objectAttributeAt: #removed) ? false |
|
146 |
||
147 |
"Created: / 24-10-2009 / 21:10:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
148 |
! |
|
149 |
||
150 |
removed: aBoolean |
|
151 |
||
152 |
^self objectAttributeAt: #removed put: aBoolean |
|
153 |
||
154 |
"Created: / 24-10-2009 / 21:11:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
155 |
! |
|
156 |
||
647 | 157 |
selector |
158 |
^ nil |
|
159 |
||
160 |
"Created: / 6.2.1998 / 13:29:35 / cg" |
|
787 | 161 |
! |
162 |
||
163 |
source |
|
164 |
"return the source of the change" |
|
165 |
||
1096 | 166 |
|s| |
167 |
||
168 |
source isNil ifTrue:[ |
|
1385
495fc9f2c9da
replaced '' writeStream by String writeStream
Claus Gittinger <cg@exept.de>
parents:
1290
diff
changeset
|
169 |
s := String writeStream. |
1096 | 170 |
self printOn:s. |
171 |
^ s contents. |
|
172 |
]. |
|
787 | 173 |
^ source |
174 |
||
175 |
"Modified: 15.7.1996 / 09:26:34 / cg" |
|
176 |
! |
|
177 |
||
178 |
source:someString |
|
179 |
"set the source of the change" |
|
180 |
||
1290 | 181 |
"/ debugging only ... |
182 |
someString isString ifFalse:[ |
|
183 |
(someString respondsTo:#string) ifFalse:[ |
|
184 |
self halt:'argument should be string-like' |
|
185 |
] |
|
186 |
]. |
|
787 | 187 |
source := someString |
188 |
||
189 |
"Modified: / 15.7.1996 / 09:26:34 / cg" |
|
190 |
"Created: / 16.2.1998 / 13:05:16 / cg" |
|
1147 | 191 |
! |
192 |
||
193 |
timeOfChangeIfKnown |
|
194 |
^ timeOfChangeIfKnown |
|
195 |
! |
|
196 |
||
197 |
timeStamp:aTimestamp |
|
198 |
timeOfChangeIfKnown := aTimestamp |
|
647 | 199 |
! ! |
200 |
||
849 | 201 |
!Change methodsFor:'applying'! |
202 |
||
203 |
apply |
|
204 |
"apply the change" |
|
205 |
||
206 |
self subclassResponsibility |
|
1873
2cbdfc5da6d7
changes for compare-project functionality
Claus Gittinger <cg@exept.de>
parents:
1868
diff
changeset
|
207 |
|
2cbdfc5da6d7
changes for compare-project functionality
Claus Gittinger <cg@exept.de>
parents:
1868
diff
changeset
|
208 |
"Modified: / 13-10-2006 / 00:41:05 / cg" |
849 | 209 |
! ! |
210 |
||
1234 | 211 |
!Change methodsFor:'change notification'! |
212 |
||
213 |
sendChangeNotificationThroughSmalltalk |
|
214 |
"intentionally left blank" |
|
215 |
! ! |
|
216 |
||
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
217 |
!Change methodsFor:'comparing'! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
218 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
219 |
isForSameAs:changeB |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
220 |
"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:
783
diff
changeset
|
221 |
thingy as the receiver (i.e. same method, same definition etc.)." |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
222 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
223 |
^ false |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
224 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
225 |
! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
226 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
227 |
sameAs:changeB |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
228 |
"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:
783
diff
changeset
|
229 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
230 |
^ false |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
231 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
232 |
! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
233 |
|
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
234 |
sameSourceAs:changeB |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
235 |
"return true, if the given change has the same source as the receiver." |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
236 |
|
1510 | 237 |
^ self class isSource:(self source) sameSourceAs:(changeB source) |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
238 |
|
1510 | 239 |
"Modified: / 25-07-2006 / 11:22:46 / cg" |
784
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
240 |
! ! |
1e50cc7fd07d
added compare methods #sameAs: and #isForSameAs:
Claus Gittinger <cg@exept.de>
parents:
783
diff
changeset
|
241 |
|
2411 | 242 |
!Change methodsFor:'converting'! |
243 |
||
244 |
asAntiChange |
|
245 |
"Returns my anti-change, i.e. change that do the |
|
246 |
opposite. For class defintion change it returns |
|
247 |
class remove change, for method defintion change |
|
248 |
it returns method remove change. If there is no way |
|
249 |
how to revert the change, an error is trigerred. |
|
250 |
||
251 |
JV: personal note: we should switch to deltastreams |
|
252 |
(http://wiki.squeak.org/squeak/6001) |
|
253 |
" |
|
254 |
||
255 |
"/self error: 'Could not create antichange' |
|
256 |
^self copy |
|
257 |
||
258 |
"Created: / 02-11-2009 / 11:11:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
259 |
"Modified: / 26-11-2009 / 16:10:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
260 |
! ! |
|
2378 | 261 |
|
262 |
!Change methodsFor:'enumerating'! |
|
263 |
||
264 |
do: aBlock |
|
265 |
||
266 |
^aBlock value: self |
|
267 |
||
268 |
"Created: / 29-10-2010 / 14:02:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
269 |
! ! |
|
270 |
||
271 |
!Change methodsFor:'fileout'! |
|
272 |
||
273 |
basicFileOutOn: aStream |
|
274 |
||
275 |
aStream |
|
276 |
cr; |
|
277 |
nextPutAllAsChunk: self source; |
|
278 |
cr; |
|
279 |
nextPutChunkSeparator; cr |
|
280 |
! |
|
281 |
||
282 |
fileOutOn: aStream |
|
283 |
||
284 |
self removed ifFalse:[self basicFileOutOn: aStream] |
|
285 |
! ! |
|
286 |
||
778 | 287 |
!Change methodsFor:'printing & storing'! |
288 |
||
897 | 289 |
printStringWithoutClassName |
778 | 290 |
|s| |
291 |
||
1385
495fc9f2c9da
replaced '' writeStream by String writeStream
Claus Gittinger <cg@exept.de>
parents:
1290
diff
changeset
|
292 |
s := String writeStream. |
897 | 293 |
self printWithoutClassNameOn:s. |
778 | 294 |
^ s contents |
295 |
! |
|
296 |
||
897 | 297 |
printWithoutClassNameOn:aStream |
778 | 298 |
self printOn:aStream |
299 |
||
300 |
||
301 |
! ! |
|
302 |
||
2411 | 303 |
!Change methodsFor:'private'! |
304 |
||
305 |
flattenOnto: aCollection |
|
306 |
aCollection add: self |
|
307 |
! |
|
308 |
||
309 |
flattenedChanges |
|
310 |
| changes | |
|
311 |
changes := OrderedCollection new. |
|
312 |
self flattenOnto: changes. |
|
313 |
^changes |
|
314 |
! ! |
|
2378 | 315 |
|
2167 | 316 |
!Change methodsFor:'queries'! |
317 |
||
318 |
isForGeneratedSubject |
|
319 |
" |
|
320 |
Answers true iff subject of this method is somewhat |
|
321 |
auto-generated by some tool - just like version methods |
|
322 |
are. |
|
323 |
" |
|
324 |
||
325 |
^ false |
|
326 |
||
327 |
"Created: / 08-04-2009 / 09:45:26 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
328 |
"Modified: / 17-08-2009 / 18:55:20 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
329 |
! ! |
|
330 |
||
2135 | 331 |
!Change methodsFor:'testing'! |
651 | 332 |
|
1175 | 333 |
isClassCategoryChange |
2135 | 334 |
"return true, if this is a class-category change" |
335 |
||
1175 | 336 |
^ false |
337 |
||
338 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
339 |
! |
|
340 |
||
932 | 341 |
isClassChange |
2135 | 342 |
"return true, if this is a class-related change" |
343 |
||
932 | 344 |
^ false |
345 |
||
346 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
347 |
! |
|
348 |
||
777 | 349 |
isClassCommentChange |
2135 | 350 |
"return true, if this is a class-comment change" |
351 |
||
777 | 352 |
^ false |
353 |
||
354 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
355 |
! |
|
356 |
||
771 | 357 |
isClassDefinitionChange |
2135 | 358 |
"return true, if this is a class-definition change" |
359 |
||
771 | 360 |
^ false |
361 |
||
362 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
363 |
! |
|
364 |
||
798 | 365 |
isClassInstVarDefinitionChange |
366 |
^ false |
|
367 |
||
368 |
! |
|
369 |
||
1234 | 370 |
isClassRemoveChange |
371 |
^ false |
|
372 |
||
373 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
374 |
! |
|
375 |
||
2411 | 376 |
isClassRemoveChangeOrMethodRemoveChange |
377 |
^self isClassRemoveChange or: [self isMethodRemoveChange] |
|
378 |
||
379 |
"Created: / 25-11-2009 / 08:16:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
380 |
! |
|
381 |
||
1234 | 382 |
isClassRenameChange |
383 |
^ false |
|
384 |
||
385 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
386 |
! |
|
387 |
||
2378 | 388 |
isCompositeChange |
389 |
^ false |
|
390 |
||
391 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
392 |
! |
|
393 |
||
773 | 394 |
isDoIt |
395 |
^ false |
|
396 |
||
397 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
398 |
! |
|
399 |
||
964
64282b5e5c48
added #isMEthodCategoryChange
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
400 |
isMethodCategoryChange |
64282b5e5c48
added #isMEthodCategoryChange
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
401 |
^ false |
64282b5e5c48
added #isMEthodCategoryChange
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
402 |
! |
64282b5e5c48
added #isMEthodCategoryChange
Claus Gittinger <cg@exept.de>
parents:
932
diff
changeset
|
403 |
|
1234 | 404 |
isMethodCategoryRenameChange |
405 |
^ false |
|
406 |
||
407 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
408 |
! |
|
409 |
||
651 | 410 |
isMethodChange |
2135 | 411 |
"true if this is a method related change" |
412 |
||
413 |
^ false |
|
414 |
||
415 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
416 |
! |
|
417 |
||
2185 | 418 |
isMethodChangeForVersionMethod |
419 |
"true if this is a method's code change (not package, category etc.)" |
|
420 |
||
421 |
^ false |
|
422 |
||
423 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
424 |
! |
|
425 |
||
2135 | 426 |
isMethodCodeChange |
427 |
"true if this is a method's code change (not package, category etc.)" |
|
428 |
||
651 | 429 |
^ false |
430 |
||
431 |
"Created: / 7.2.1998 / 19:26:50 / cg" |
|
783 | 432 |
! |
433 |
||
1225 | 434 |
isMethodDefinitionChange |
435 |
^ false |
|
436 |
! |
|
437 |
||
2167 | 438 |
isMethodPackageChange |
439 |
^ false |
|
440 |
||
441 |
"Created: / 08-04-2009 / 09:00:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
442 |
! |
|
443 |
||
1163
4886886a78b7
#isMethodRemoveChange query added
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
444 |
isMethodRemoveChange |
4886886a78b7
#isMethodRemoveChange query added
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
445 |
^ false |
4886886a78b7
#isMethodRemoveChange query added
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
446 |
! |
4886886a78b7
#isMethodRemoveChange query added
Claus Gittinger <cg@exept.de>
parents:
1147
diff
changeset
|
447 |
|
783 | 448 |
isPrimitiveChange |
449 |
^ false |
|
450 |
||
451 |
! |
|
452 |
||
453 |
isPrimitiveDefinitionsChange |
|
454 |
^ false |
|
455 |
||
456 |
! |
|
457 |
||
458 |
isPrimitiveFunctionsChange |
|
459 |
^ false |
|
460 |
||
461 |
! |
|
462 |
||
463 |
isPrimitiveVariablesChange |
|
464 |
^ false |
|
465 |
||
1868
301a5aeb8176
+isPrivateClassDefinitionChange
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
466 |
! |
301a5aeb8176
+isPrivateClassDefinitionChange
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
467 |
|
301a5aeb8176
+isPrivateClassDefinitionChange
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
468 |
isPrivateClassDefinitionChange |
301a5aeb8176
+isPrivateClassDefinitionChange
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
469 |
^ false |
301a5aeb8176
+isPrivateClassDefinitionChange
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
470 |
|
301a5aeb8176
+isPrivateClassDefinitionChange
Claus Gittinger <cg@exept.de>
parents:
1510
diff
changeset
|
471 |
"Created: / 12-10-2006 / 22:59:04 / cg" |
651 | 472 |
! ! |
473 |
||
633 | 474 |
!Change class methodsFor:'documentation'! |
235 | 475 |
|
2378 | 476 |
version_CVS |
2411 | 477 |
^ '$Header: /cvs/stx/stx/libbasic3/Change.st,v 1.50 2011-07-06 11:50:11 vrany Exp $' |
2185 | 478 |
! |
479 |
||
2378 | 480 |
version_SVN |
2411 | 481 |
^ '§ Id: Change.st 1867 2011-06-08 21:57:08Z vranyj1 §' |
235 | 482 |
! ! |