author | Claus Gittinger <cg@exept.de> |
Tue, 09 Jul 2019 15:23:29 +0200 | |
changeset 4456 | df14ee79655a |
parent 3682 | a590e9e018e3 |
child 3838 | 474d8ec95b33 |
permissions | -rw-r--r-- |
3442 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
2493 | 12 |
"{ Package: 'stx:libbasic3' }" |
13 |
||
14 |
Object subclass:#ChangeDeltaInformation |
|
15 |
instanceVariableNames:'shortDeltaSymbol' |
|
16 |
classVariableNames:'Unknown Identical Different Added Removed IdenticalButWhiteSpace |
|
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
17 |
IdenticalButFormat IdenticalSemantically Conflict' |
2493 | 18 |
poolDictionaries:'' |
19 |
category:'System-Changes' |
|
20 |
! |
|
21 |
||
22 |
!ChangeDeltaInformation class methodsFor:'documentation'! |
|
23 |
||
3442 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
2493 | 38 |
documentation |
39 |
" |
|
40 |
delta used to return a symbol (#=, #~, #+ or #-); |
|
41 |
for more detail, use instances of me: |
|
42 |
Unknown delta is unknown |
|
43 |
Identical exactly the same |
|
44 |
IdenticalButWhiteSpace code is formatted different, but AST is the same |
|
45 |
SemanticallyIdentical code is different, but semantically the same |
|
46 |
(for example, ifNil: -> isNil ifTrue:) |
|
47 |
Different code is different |
|
48 |
Added method/class is added by change |
|
49 |
Removed method/class is removed by change |
|
50 |
" |
|
51 |
! ! |
|
52 |
||
53 |
!ChangeDeltaInformation class methodsFor:'initialization'! |
|
54 |
||
55 |
initialize |
|
56 |
Unknown := self new shortDeltaSymbol:#'?'. "/ delta is unknown |
|
57 |
Identical := self new shortDeltaSymbol:#'='. "/ exactly the same |
|
58 |
IdenticalButWhiteSpace := self new shortDeltaSymbol:#'W'. "/ code is the same except for indentation |
|
59 |
IdenticalButFormat := self new shortDeltaSymbol:#'F'. "/ code is formatted different, but AST is the same |
|
60 |
IdenticalSemantically := self new shortDeltaSymbol:#'%'. "/ code is different, but semantically the same |
|
61 |
"/ (for example, ifNil: -> isNil ifTrue:) |
|
62 |
Different := self new shortDeltaSymbol:#'~'. "/ code is different |
|
63 |
Added := self new shortDeltaSymbol:#'+'. "/ method/class is added by change |
|
64 |
Removed := self new shortDeltaSymbol:#'-'. "/ method/class is removed by change |
|
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
65 |
Conflict := self new shortDeltaSymbol:#'!!'. "/ package conflict - overwrites existing method |
2493 | 66 |
|
67 |
"Created: / 31-08-2011 / 10:09:24 / cg" |
|
68 |
! ! |
|
69 |
||
70 |
!ChangeDeltaInformation class methodsFor:'accessing'! |
|
71 |
||
72 |
added |
|
73 |
"method/class is added by change" |
|
74 |
||
75 |
^ Added |
|
76 |
||
77 |
"Modified (comment): / 31-08-2011 / 10:20:51 / cg" |
|
78 |
! |
|
79 |
||
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
80 |
conflict |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
81 |
"method overwrites existing method from another package" |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
82 |
|
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
83 |
^ Conflict |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
84 |
! |
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
85 |
|
2493 | 86 |
different |
87 |
"code is different" |
|
88 |
||
89 |
^ Different |
|
90 |
||
91 |
"Modified (comment): / 31-08-2011 / 10:21:07 / cg" |
|
92 |
! |
|
93 |
||
94 |
identical |
|
95 |
"exactly the same" |
|
96 |
||
97 |
^ Identical |
|
98 |
||
99 |
"Modified (comment): / 31-08-2011 / 10:21:18 / cg" |
|
100 |
! |
|
101 |
||
102 |
identicalButFormat |
|
103 |
"code is formatted different, but AST is the same" |
|
104 |
||
105 |
^ IdenticalButFormat |
|
106 |
||
107 |
"Created: / 31-08-2011 / 10:23:18 / cg" |
|
108 |
! |
|
109 |
||
110 |
identicalButWhiteSpace |
|
111 |
"code is the same except for indentation" |
|
112 |
||
113 |
^ IdenticalButWhiteSpace |
|
114 |
||
115 |
"Modified (comment): / 31-08-2011 / 10:23:49 / cg" |
|
116 |
! |
|
117 |
||
118 |
identicalSemantically |
|
119 |
"code is different, but semantically the same. |
|
120 |
(for example, ifNil: -> isNil ifTrue:)" |
|
121 |
||
122 |
^ IdenticalSemantically |
|
123 |
||
124 |
"Modified (comment): / 31-08-2011 / 10:24:04 / cg" |
|
125 |
! |
|
126 |
||
127 |
removed |
|
128 |
"method/class is removed by change" |
|
129 |
||
130 |
^ Removed |
|
131 |
||
132 |
"Modified (comment): / 31-08-2011 / 10:24:14 / cg" |
|
133 |
! |
|
134 |
||
135 |
unknown |
|
136 |
"another change / cannot figure out what has changed" |
|
137 |
||
138 |
^ Unknown |
|
139 |
||
140 |
"Created: / 31-08-2011 / 10:20:13 / cg" |
|
141 |
! ! |
|
142 |
||
3682
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
143 |
!ChangeDeltaInformation class methodsFor:'utilities'! |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
144 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
145 |
changeDeltaFor:changeText changeClass:changeClass selector:methodSelector |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
146 |
"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
|
147 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
148 |
|currentText method t1 t2| |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
149 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
150 |
changeClass isNil ifTrue:[ ^ '+']. |
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 |
(methodSelector isNil or:[changeClass theNonMetaclass isLoaded not]) ifTrue:[ |
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 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
155 |
(changeClass includesSelector:methodSelector asSymbol) ifFalse:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
156 |
^ '+'. |
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 |
method := changeClass compiledMethodAt:methodSelector asSymbol. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
160 |
Error handle:[:ex | |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
161 |
Transcript showCR:'Error while accessing methods current source: ',ex description. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
162 |
] do:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
163 |
currentText := method source. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
164 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
165 |
currentText isNil ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
166 |
"/ cannot access the source code - assume changed |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
167 |
^ '!!'. |
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 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
170 |
changeText asString string withoutTrailingSeparators = currentText asString string withoutTrailingSeparators ifTrue:[ |
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 |
t1 := currentText asCollectionOfLines collect:[:s | s withTabsExpanded]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
175 |
t2 := changeText asCollectionOfLines collect:[:s | s withTabsExpanded]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
176 |
t1 = t2 ifTrue:[ |
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 |
]. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
179 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
180 |
RBParser notNil ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
181 |
|tree1 tree2| |
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 |
tree1 := RBParser parseMethod:currentText onError:[:aString :pos | ^ '!!']. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
184 |
tree2 := RBParser parseMethod:changeText onError:[:aString :pos | ^ '!!']. |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
185 |
|
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
186 |
tree1 = tree2 ifTrue:[ |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
187 |
^ '~' |
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
188 |
]. |
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 |
|
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 |
|
2493 | 194 |
!ChangeDeltaInformation methodsFor:'accessing'! |
195 |
||
196 |
shortDeltaSymbol |
|
197 |
^ shortDeltaSymbol |
|
198 |
||
199 |
"Created: / 31-08-2011 / 10:39:01 / cg" |
|
200 |
! |
|
201 |
||
202 |
shortDeltaSymbol:something |
|
203 |
shortDeltaSymbol := something. |
|
204 |
||
205 |
"Created: / 31-08-2011 / 10:39:05 / cg" |
|
206 |
! ! |
|
207 |
||
208 |
!ChangeDeltaInformation class methodsFor:'documentation'! |
|
209 |
||
210 |
version |
|
3682
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
211 |
^ '$Header: /cvs/stx/stx/libbasic3/ChangeDeltaInformation.st,v 1.4 2014-12-11 20:47:41 cg Exp $' |
2493 | 212 |
! |
213 |
||
214 |
version_CVS |
|
3682
a590e9e018e3
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
3442
diff
changeset
|
215 |
^ '$Header: /cvs/stx/stx/libbasic3/ChangeDeltaInformation.st,v 1.4 2014-12-11 20:47:41 cg Exp $' |
2493 | 216 |
! ! |
217 |
||
3215
b2aed720bfd8
class: ChangeDeltaInformation
Claus Gittinger <cg@exept.de>
parents:
2493
diff
changeset
|
218 |
|
2493 | 219 |
ChangeDeltaInformation initialize! |