author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 17 Feb 2021 15:24:09 +0100 | |
branch | jv |
changeset 4568 | 524471ef6575 |
parent 4330 | 998eb03f0736 |
permissions | -rw-r--r-- |
3442 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
4330 | 3 |
COPYRIGHT (c) 2015 Jan Vrany |
3442 | 4 |
All Rights Reserved |
5 |
||
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
2493 | 13 |
"{ Package: 'stx:libbasic3' }" |
14 |
||
3862
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
15 |
"{ NameSpace: Smalltalk }" |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
16 |
|
2493 | 17 |
Object subclass:#ChangeDeltaInformation |
18 |
instanceVariableNames:'shortDeltaSymbol' |
|
19 |
classVariableNames:'Unknown Identical Different Added Removed IdenticalButWhiteSpace |
|
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
20 |
IdenticalButFormat IdenticalSemantically Conflict' |
2493 | 21 |
poolDictionaries:'' |
22 |
category:'System-Changes' |
|
23 |
! |
|
24 |
||
25 |
!ChangeDeltaInformation class methodsFor:'documentation'! |
|
26 |
||
3442 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
4330 | 30 |
COPYRIGHT (c) 2015 Jan Vrany |
3442 | 31 |
All Rights Reserved |
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
! |
|
41 |
||
2493 | 42 |
documentation |
43 |
" |
|
44 |
delta used to return a symbol (#=, #~, #+ or #-); |
|
45 |
for more detail, use instances of me: |
|
46 |
Unknown delta is unknown |
|
47 |
Identical exactly the same |
|
48 |
IdenticalButWhiteSpace code is formatted different, but AST is the same |
|
49 |
SemanticallyIdentical code is different, but semantically the same |
|
50 |
(for example, ifNil: -> isNil ifTrue:) |
|
51 |
Different code is different |
|
52 |
Added method/class is added by change |
|
53 |
Removed method/class is removed by change |
|
54 |
" |
|
55 |
! ! |
|
56 |
||
57 |
!ChangeDeltaInformation class methodsFor:'initialization'! |
|
58 |
||
59 |
initialize |
|
60 |
Unknown := self new shortDeltaSymbol:#'?'. "/ delta is unknown |
|
61 |
Identical := self new shortDeltaSymbol:#'='. "/ exactly the same |
|
62 |
IdenticalButWhiteSpace := self new shortDeltaSymbol:#'W'. "/ code is the same except for indentation |
|
63 |
IdenticalButFormat := self new shortDeltaSymbol:#'F'. "/ code is formatted different, but AST is the same |
|
64 |
IdenticalSemantically := self new shortDeltaSymbol:#'%'. "/ code is different, but semantically the same |
|
65 |
"/ (for example, ifNil: -> isNil ifTrue:) |
|
66 |
Different := self new shortDeltaSymbol:#'~'. "/ code is different |
|
67 |
Added := self new shortDeltaSymbol:#'+'. "/ method/class is added by change |
|
68 |
Removed := self new shortDeltaSymbol:#'-'. "/ method/class is removed by change |
|
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
69 |
Conflict := self new shortDeltaSymbol:#'!!'. "/ package conflict - overwrites existing method |
2493 | 70 |
|
71 |
"Created: / 31-08-2011 / 10:09:24 / cg" |
|
72 |
! ! |
|
73 |
||
74 |
!ChangeDeltaInformation class methodsFor:'accessing'! |
|
75 |
||
76 |
added |
|
77 |
"method/class is added by change" |
|
78 |
||
79 |
^ Added |
|
80 |
||
81 |
"Modified (comment): / 31-08-2011 / 10:20:51 / cg" |
|
82 |
! |
|
83 |
||
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
84 |
conflict |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
85 |
"method overwrites existing method from another package" |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
86 |
|
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
87 |
^ Conflict |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
88 |
! |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
89 |
|
2493 | 90 |
different |
91 |
"code is different" |
|
92 |
||
93 |
^ Different |
|
94 |
||
95 |
"Modified (comment): / 31-08-2011 / 10:21:07 / cg" |
|
96 |
! |
|
97 |
||
98 |
identical |
|
99 |
"exactly the same" |
|
100 |
||
101 |
^ Identical |
|
102 |
||
103 |
"Modified (comment): / 31-08-2011 / 10:21:18 / cg" |
|
104 |
! |
|
105 |
||
106 |
identicalButFormat |
|
107 |
"code is formatted different, but AST is the same" |
|
108 |
||
109 |
^ IdenticalButFormat |
|
110 |
||
111 |
"Created: / 31-08-2011 / 10:23:18 / cg" |
|
112 |
! |
|
113 |
||
114 |
identicalButWhiteSpace |
|
115 |
"code is the same except for indentation" |
|
116 |
||
117 |
^ IdenticalButWhiteSpace |
|
118 |
||
119 |
"Modified (comment): / 31-08-2011 / 10:23:49 / cg" |
|
120 |
! |
|
121 |
||
122 |
identicalSemantically |
|
123 |
"code is different, but semantically the same. |
|
124 |
(for example, ifNil: -> isNil ifTrue:)" |
|
125 |
||
126 |
^ IdenticalSemantically |
|
127 |
||
128 |
"Modified (comment): / 31-08-2011 / 10:24:04 / cg" |
|
129 |
! |
|
130 |
||
131 |
removed |
|
132 |
"method/class is removed by change" |
|
133 |
||
134 |
^ Removed |
|
135 |
||
136 |
"Modified (comment): / 31-08-2011 / 10:24:14 / cg" |
|
137 |
! |
|
138 |
||
139 |
unknown |
|
140 |
"another change / cannot figure out what has changed" |
|
141 |
||
142 |
^ Unknown |
|
143 |
||
144 |
"Created: / 31-08-2011 / 10:20:13 / cg" |
|
145 |
! ! |
|
146 |
||
3682
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
147 |
!ChangeDeltaInformation class methodsFor:'utilities'! |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
148 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
149 |
changeDeltaFor:changeText changeClass:changeClass selector:methodSelector |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
150 |
"utility: give a changed method's source, compare against the current version in the system" |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
151 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
152 |
|currentText method t1 t2| |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
153 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
154 |
changeClass isNil ifTrue:[ ^ '+']. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
155 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
156 |
(methodSelector isNil or:[changeClass theNonMetaclass isLoaded not]) ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
157 |
^ '?' |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
158 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
159 |
(changeClass includesSelector:methodSelector asSymbol) ifFalse:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
160 |
^ '+'. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
161 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
162 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
163 |
method := changeClass compiledMethodAt:methodSelector asSymbol. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
164 |
Error handle:[:ex | |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
165 |
Transcript showCR:'Error while accessing methods current source: ',ex description. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
166 |
] do:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
167 |
currentText := method source. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
168 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
169 |
currentText isNil ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
170 |
"/ cannot access the source code - assume changed |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
171 |
^ '!!'. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
172 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
173 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
174 |
changeText asString string withoutTrailingSeparators = currentText asString string withoutTrailingSeparators ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
175 |
^ '=' |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
176 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
177 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
178 |
t1 := currentText asCollectionOfLines collect:[:s | s withTabsExpanded]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
179 |
t2 := changeText asCollectionOfLines collect:[:s | s withTabsExpanded]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
180 |
t1 = t2 ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
181 |
^ '=' |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
182 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
183 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
184 |
RBParser notNil ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
185 |
|tree1 tree2| |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
186 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
187 |
tree1 := RBParser parseMethod:currentText onError:[:aString :pos | ^ '!!']. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
188 |
tree2 := RBParser parseMethod:changeText onError:[:aString :pos | ^ '!!']. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
189 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
190 |
tree1 = tree2 ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
191 |
^ '~' |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
192 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
193 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
194 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
195 |
^ ' ' |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
196 |
! ! |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
197 |
|
2493 | 198 |
!ChangeDeltaInformation methodsFor:'accessing'! |
199 |
||
200 |
shortDeltaSymbol |
|
201 |
^ shortDeltaSymbol |
|
202 |
||
203 |
"Created: / 31-08-2011 / 10:39:01 / cg" |
|
204 |
! |
|
205 |
||
206 |
shortDeltaSymbol:something |
|
207 |
shortDeltaSymbol := something. |
|
208 |
||
209 |
"Created: / 31-08-2011 / 10:39:05 / cg" |
|
210 |
! ! |
|
211 |
||
3862
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
212 |
!ChangeDeltaInformation methodsFor:'printing & storing'! |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
213 |
|
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
214 |
printOn:aStream |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
215 |
"append a printed representation if the receiver to the argument, aStream" |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
216 |
|
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
217 |
super printOn:aStream. |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
218 |
aStream nextPut:$(. |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
219 |
shortDeltaSymbol printOn:aStream. |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
220 |
aStream nextPut:$). |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
221 |
|
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
222 |
"Modified: / 23-04-2015 / 08:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
223 |
! ! |
476566b38577
Make Change>>delta an obsolete.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3838
diff
changeset
|
224 |
|
2493 | 225 |
!ChangeDeltaInformation class methodsFor:'documentation'! |
226 |
||
227 |
version |
|
3682
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
228 |
^ '$Header: /cvs/stx/stx/libbasic3/ChangeDeltaInformation.st,v 1.4 2014-12-11 20:47:41 cg Exp $' |
2493 | 229 |
! |
230 |
||
231 |
version_CVS |
|
3682
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
232 |
^ '$Header: /cvs/stx/stx/libbasic3/ChangeDeltaInformation.st,v 1.4 2014-12-11 20:47:41 cg Exp $' |
3922
ae8879b8ba67
Refactored and improved support for writing Bee packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3862
diff
changeset
|
233 |
! |
ae8879b8ba67
Refactored and improved support for writing Bee packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3862
diff
changeset
|
234 |
|
ae8879b8ba67
Refactored and improved support for writing Bee packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3862
diff
changeset
|
235 |
version_HG |
ae8879b8ba67
Refactored and improved support for writing Bee packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3862
diff
changeset
|
236 |
|
ae8879b8ba67
Refactored and improved support for writing Bee packages.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3862
diff
changeset
|
237 |
^ '$Changeset: <not expanded> $' |
2493 | 238 |
! ! |
239 |
||
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
240 |
|
2493 | 241 |
ChangeDeltaInformation initialize! |