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