author | Stefan Vogel <sv@exept.de> |
Thu, 12 Dec 2019 19:01:46 +0100 | |
changeset 25102 | 5e2a71db9286 |
parent 18913 | 7ed4b692fff2 |
child 18919 | dbe023989a90 |
permissions | -rw-r--r-- |
13406 | 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 |
" |
|
11962 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
15 |
|
11962 | 16 |
Object subclass:#AbstractSourceFileWriter |
16879
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
17 |
instanceVariableNames:'generatingSourceForOriginal' |
11962 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
15419
a1da7568bcfe
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
14407
diff
changeset
|
20 |
category:'Kernel-Classes-Support' |
11962 | 21 |
! |
22 |
||
12041 | 23 |
Query subclass:#MethodSourceRewriteQuery |
24 |
instanceVariableNames:'method source' |
|
25 |
classVariableNames:'' |
|
26 |
poolDictionaries:'' |
|
27 |
privateIn:AbstractSourceFileWriter |
|
28 |
! |
|
29 |
||
13406 | 30 |
!AbstractSourceFileWriter class methodsFor:'documentation'! |
31 |
||
32 |
copyright |
|
33 |
" |
|
34 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
35 |
All Rights Reserved |
|
36 |
||
37 |
This software is furnished under a license and may be used |
|
38 |
only in accordance with the terms of that license and with the |
|
39 |
inclusion of the above copyright notice. This software may not |
|
40 |
be provided or otherwise made available to, or used by, any |
|
41 |
other person. No title to or ownership of the software is |
|
42 |
hereby transferred. |
|
43 |
" |
|
14407 | 44 |
! |
45 |
||
46 |
documentation |
|
47 |
" |
|
48 |
Abstract common superclass for source file writers |
|
49 |
" |
|
13406 | 50 |
! ! |
12041 | 51 |
|
18913 | 52 |
!AbstractSourceFileWriter class methodsFor:'queries'! |
53 |
||
54 |
isAbstract |
|
55 |
^ self == AbstractSourceFileWriter |
|
56 |
! ! |
|
57 |
||
12041 | 58 |
!AbstractSourceFileWriter class methodsFor:'signal constants'! |
11962 | 59 |
|
12041 | 60 |
methodSourceRewriteQuery |
61 |
"hook to allow for just-in-time rewriting of a method's sourceCode while filing out |
|
62 |
used when saving version_XXX methods in a non-XXX sourceCodeManager |
|
63 |
(i.e. to rewrite all non-CVS version methods while saving into a CVS repository) |
|
64 |
this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a |
|
65 |
CVS repository without loosing the original string with the next checkout, because it also gets |
|
66 |
expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN. |
|
67 |
||
68 |
see SmalltalkChunkFileSourceWriter fileOutMethod:on:" |
|
69 |
||
70 |
^ MethodSourceRewriteQuery |
|
11962 | 71 |
! ! |
72 |
||
16879
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
73 |
!AbstractSourceFileWriter methodsFor:'accessing'! |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
74 |
|
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
75 |
generatingSourceForOriginal:aBoolean |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
76 |
"if false (the default), the source of the current (in image) code is generated. |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
77 |
That means, that any extension method which shadows some other original method, |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
78 |
that extension method's code is generated. |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
79 |
if true, the code of the original method is generated. |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
80 |
Use a true value, when generating code for a SCM checkin operation, as then we do not |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
81 |
want the extension to shadow the original" |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
82 |
|
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
83 |
generatingSourceForOriginal := aBoolean. |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
84 |
! ! |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
85 |
|
11962 | 86 |
!AbstractSourceFileWriter methodsFor:'fileout'! |
87 |
||
88 |
fileOut:aClass on:outStreamArg |
|
89 |
||
90 |
self |
|
91 |
fileOut:aClass on:outStreamArg |
|
92 |
withTimeStamp:true withInitialize:true |
|
93 |
withDefinition:true |
|
94 |
methodFilter:nil encoder:nil |
|
95 |
||
96 |
"Created: / 15-08-2009 / 13:11:31 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
97 |
! ! |
|
98 |
||
99 |
!AbstractSourceFileWriter methodsFor:'source writing'! |
|
100 |
||
16881
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
101 |
fileOut: class on:stream withTimeStamp: stampIt withInitialize: initIt withDefinition: withDefinition methodFilter:methodFilter |
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
102 |
|
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
103 |
^ self |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
104 |
fileOut: class |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
105 |
on:stream |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
106 |
withTimeStamp: stampIt |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
107 |
withInitialize: initIt |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
108 |
withDefinition: withDefinition |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
109 |
methodFilter:methodFilter |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
110 |
encoder:nil |
16881
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
111 |
|
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
112 |
"Created: / 04-10-2014 / 12:10:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
113 |
! |
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
114 |
|
11962 | 115 |
fileOut: class on:stream withTimeStamp: stampIt withInitialize: initIt withDefinition: withDefinition methodFilter:methodFilter encoder:encoderOrNil |
116 |
"raise an error: must be redefined in concrete subclass(es)" |
|
117 |
||
118 |
^ self subclassResponsibility |
|
119 |
||
120 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13406 | 121 |
! |
122 |
||
123 |
fileOutMethods: methods on:stream |
|
124 |
||
125 |
"Files out a bunch of methods. This is used to file-out extension methods" |
|
126 |
||
127 |
self subclassResponsibility |
|
128 |
||
129 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
130 |
"Created: / 30-12-2009 / 18:34:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
131 |
! |
|
132 |
||
133 |
fileOutPackageDefinition:packageId on:stream |
|
134 |
"Files out a package definition on the stream, so all subsequent |
|
135 |
code entities will be placed in that package" |
|
136 |
||
137 |
self subclassResponsibility |
|
138 |
||
139 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
140 |
"Created: / 30-12-2009 / 18:34:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11962 | 141 |
! ! |
142 |
||
143 |
!AbstractSourceFileWriter methodsFor:'source writing - comments'! |
|
144 |
||
145 |
fileOutComment: aStringOrStringCollection on: aStream |
|
12109
1e360b1a1062
comment/format in: #fileOutComment:on:
Claus Gittinger <cg@exept.de>
parents:
12053
diff
changeset
|
146 |
"Writes a comment to a stream using proper syntax" |
11962 | 147 |
|
148 |
self fileOutCommentStartOn: aStream. |
|
149 |
aStringOrStringCollection isStringCollection |
|
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
150 |
ifTrue:[ |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
151 |
aStringOrStringCollection |
11962 | 152 |
do:[:line|self fileOutCommentLine: line on: aStream] |
153 |
separatedBy: [aStream cr]] |
|
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
154 |
ifFalse:[ |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
155 |
(aStringOrStringCollection includes: Character cr) |
11962 | 156 |
ifTrue:"/hmm...multiline comment as string |
157 |
[aStringOrStringCollection asStringCollection |
|
158 |
do:[:line|self fileOutCommentLine: line on: aStream] |
|
159 |
separatedBy: [aStream cr]] |
|
160 |
ifFalse: |
|
161 |
[self fileOutCommentLine: aStringOrStringCollection on: aStream]]. |
|
162 |
self fileOutCommentEndOn: aStream. |
|
163 |
||
164 |
"Created: / 21-08-2009 / 09:36:03 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
165 |
! |
|
166 |
||
167 |
fileOutCommentEndOn: aStream |
|
168 |
" |
|
169 |
Writes a comment end mark on aStream. |
|
170 |
" |
|
171 |
||
172 |
^self subclassResponsibility |
|
173 |
||
174 |
"Created: / 21-08-2009 / 09:40:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
175 |
! |
|
176 |
||
177 |
fileOutCommentLine: aString on: aStream |
|
178 |
||
179 |
" |
|
180 |
Writes a single line of comment on a comment to a stream. |
|
181 |
Should not put an cr to the stream!! |
|
182 |
" |
|
183 |
||
184 |
^self subclassResponsibility |
|
185 |
||
186 |
"Created: / 21-08-2009 / 09:42:23 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
187 |
! |
|
188 |
||
189 |
fileOutCommentStartOn: aStream |
|
190 |
" |
|
191 |
Writes a comment start mark on aStream. |
|
192 |
" |
|
193 |
||
194 |
^self subclassResponsibility |
|
195 |
||
196 |
"Created: / 21-08-2009 / 09:40:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
197 |
! ! |
|
198 |
||
12041 | 199 |
!AbstractSourceFileWriter::MethodSourceRewriteQuery class methodsFor:'documentation'! |
200 |
||
201 |
documentation |
|
202 |
" |
|
203 |
hook to allow for just-in-time rewriting of a method's sourceCode while filing out |
|
204 |
used when saving version_XXX methods in a non-XXX sourceCodeManager |
|
205 |
(i.e. to rewrite all non-CVS version methods while saving into a CVS repository) |
|
206 |
this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a |
|
207 |
CVS repository without loosing the original string with the next checkout, because it also gets |
|
208 |
expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN. |
|
209 |
||
210 |
see SmalltalkChunkFileSourceWriter fileOutMethod:on: |
|
211 |
" |
|
212 |
! ! |
|
213 |
||
214 |
!AbstractSourceFileWriter::MethodSourceRewriteQuery methodsFor:'accessing'! |
|
215 |
||
216 |
method |
|
217 |
^ method |
|
218 |
! |
|
219 |
||
220 |
method:methodArg source:sourceArg |
|
221 |
method := methodArg. |
|
222 |
source := sourceArg. |
|
223 |
! |
|
224 |
||
225 |
source |
|
226 |
^ source |
|
227 |
! ! |
|
228 |
||
11962 | 229 |
!AbstractSourceFileWriter class methodsFor:'documentation'! |
230 |
||
16881
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
231 |
version |
18913 | 232 |
^ '$Header$' |
16881
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
233 |
! |
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
234 |
|
12041 | 235 |
version_CVS |
18913 | 236 |
^ '$Header$' |
12041 | 237 |
! |
238 |
||
239 |
version_SVN |
|
15419
a1da7568bcfe
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
14407
diff
changeset
|
240 |
^ '$ Id: AbstractSourceFileWriter.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
11962 | 241 |
! ! |
15419
a1da7568bcfe
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
14407
diff
changeset
|
242 |