author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 10 Jun 2015 08:43:00 +0100 | |
branch | jv |
changeset 18482 | 68a43e2b3e78 |
parent 18120 | e3a375d5f6a8 |
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 |
|
52 |
!AbstractSourceFileWriter class methodsFor:'signal constants'! |
|
11962 | 53 |
|
12041 | 54 |
methodSourceRewriteQuery |
55 |
"hook to allow for just-in-time rewriting of a method's sourceCode while filing out |
|
56 |
used when saving version_XXX methods in a non-XXX sourceCodeManager |
|
57 |
(i.e. to rewrite all non-CVS version methods while saving into a CVS repository) |
|
58 |
this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a |
|
59 |
CVS repository without loosing the original string with the next checkout, because it also gets |
|
60 |
expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN. |
|
61 |
||
62 |
see SmalltalkChunkFileSourceWriter fileOutMethod:on:" |
|
63 |
||
64 |
^ MethodSourceRewriteQuery |
|
11962 | 65 |
! ! |
66 |
||
16879
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
67 |
!AbstractSourceFileWriter methodsFor:'accessing'! |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
68 |
|
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
69 |
generatingSourceForOriginal:aBoolean |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
70 |
"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
|
71 |
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
|
72 |
that extension method's code is generated. |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
73 |
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
|
74 |
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
|
75 |
want the extension to shadow the original" |
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 |
! ! |
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
79 |
|
11962 | 80 |
!AbstractSourceFileWriter methodsFor:'fileout'! |
81 |
||
82 |
fileOut:aClass on:outStreamArg |
|
83 |
||
84 |
self |
|
85 |
fileOut:aClass on:outStreamArg |
|
86 |
withTimeStamp:true withInitialize:true |
|
87 |
withDefinition:true |
|
88 |
methodFilter:nil encoder:nil |
|
89 |
||
90 |
"Created: / 15-08-2009 / 13:11:31 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
91 |
! ! |
|
92 |
||
93 |
!AbstractSourceFileWriter methodsFor:'source writing'! |
|
94 |
||
16881
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
95 |
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
|
96 |
|
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
97 |
^ self |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
98 |
fileOut: class |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
99 |
on:stream |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
100 |
withTimeStamp: stampIt |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
101 |
withInitialize: initIt |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
102 |
withDefinition: withDefinition |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
103 |
methodFilter:methodFilter |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
104 |
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
|
105 |
|
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
106 |
"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
|
107 |
! |
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
108 |
|
11962 | 109 |
fileOut: class on:stream withTimeStamp: stampIt withInitialize: initIt withDefinition: withDefinition methodFilter:methodFilter encoder:encoderOrNil |
110 |
"raise an error: must be redefined in concrete subclass(es)" |
|
111 |
||
112 |
^ self subclassResponsibility |
|
113 |
||
114 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13406 | 115 |
! |
116 |
||
117 |
fileOutMethods: methods on:stream |
|
118 |
||
119 |
"Files out a bunch of methods. This is used to file-out extension methods" |
|
120 |
||
121 |
self subclassResponsibility |
|
122 |
||
123 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
124 |
"Created: / 30-12-2009 / 18:34:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
125 |
! |
|
126 |
||
127 |
fileOutPackageDefinition:packageId on:stream |
|
128 |
"Files out a package definition on the stream, so all subsequent |
|
129 |
code entities will be placed in that package" |
|
130 |
||
131 |
self subclassResponsibility |
|
132 |
||
133 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
134 |
"Created: / 30-12-2009 / 18:34:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11962 | 135 |
! ! |
136 |
||
137 |
!AbstractSourceFileWriter methodsFor:'source writing - comments'! |
|
138 |
||
139 |
fileOutComment: aStringOrStringCollection on: aStream |
|
12109
1e360b1a1062
comment/format in: #fileOutComment:on:
Claus Gittinger <cg@exept.de>
parents:
12053
diff
changeset
|
140 |
"Writes a comment to a stream using proper syntax" |
11962 | 141 |
|
142 |
self fileOutCommentStartOn: aStream. |
|
143 |
aStringOrStringCollection isStringCollection |
|
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
144 |
ifTrue:[ |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
145 |
aStringOrStringCollection |
11962 | 146 |
do:[:line|self fileOutCommentLine: line on: aStream] |
147 |
separatedBy: [aStream cr]] |
|
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
148 |
ifFalse:[ |
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
149 |
(aStringOrStringCollection includes: Character cr) |
11962 | 150 |
ifTrue:"/hmm...multiline comment as string |
151 |
[aStringOrStringCollection asStringCollection |
|
152 |
do:[:line|self fileOutCommentLine: line on: aStream] |
|
153 |
separatedBy: [aStream cr]] |
|
154 |
ifFalse: |
|
155 |
[self fileOutCommentLine: aStringOrStringCollection on: aStream]]. |
|
156 |
self fileOutCommentEndOn: aStream. |
|
157 |
||
158 |
"Created: / 21-08-2009 / 09:36:03 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
159 |
! |
|
160 |
||
161 |
fileOutCommentEndOn: aStream |
|
162 |
" |
|
163 |
Writes a comment end mark on aStream. |
|
164 |
" |
|
165 |
||
166 |
^self subclassResponsibility |
|
167 |
||
168 |
"Created: / 21-08-2009 / 09:40:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
169 |
! |
|
170 |
||
171 |
fileOutCommentLine: aString on: aStream |
|
172 |
||
173 |
" |
|
174 |
Writes a single line of comment on a comment to a stream. |
|
175 |
Should not put an cr to the stream!! |
|
176 |
" |
|
177 |
||
178 |
^self subclassResponsibility |
|
179 |
||
180 |
"Created: / 21-08-2009 / 09:42:23 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
181 |
! |
|
182 |
||
183 |
fileOutCommentStartOn: aStream |
|
184 |
" |
|
185 |
Writes a comment start mark on aStream. |
|
186 |
" |
|
187 |
||
188 |
^self subclassResponsibility |
|
189 |
||
190 |
"Created: / 21-08-2009 / 09:40:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
191 |
! ! |
|
192 |
||
12041 | 193 |
!AbstractSourceFileWriter::MethodSourceRewriteQuery class methodsFor:'documentation'! |
194 |
||
195 |
documentation |
|
196 |
" |
|
197 |
hook to allow for just-in-time rewriting of a method's sourceCode while filing out |
|
198 |
used when saving version_XXX methods in a non-XXX sourceCodeManager |
|
199 |
(i.e. to rewrite all non-CVS version methods while saving into a CVS repository) |
|
200 |
this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a |
|
201 |
CVS repository without loosing the original string with the next checkout, because it also gets |
|
202 |
expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN. |
|
203 |
||
204 |
see SmalltalkChunkFileSourceWriter fileOutMethod:on: |
|
205 |
" |
|
206 |
! ! |
|
207 |
||
208 |
!AbstractSourceFileWriter::MethodSourceRewriteQuery methodsFor:'accessing'! |
|
209 |
||
210 |
method |
|
211 |
^ method |
|
212 |
! |
|
213 |
||
214 |
method:methodArg source:sourceArg |
|
215 |
method := methodArg. |
|
216 |
source := sourceArg. |
|
217 |
! |
|
218 |
||
219 |
source |
|
220 |
^ source |
|
221 |
! ! |
|
222 |
||
11962 | 223 |
!AbstractSourceFileWriter class methodsFor:'documentation'! |
224 |
||
16881
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
225 |
version |
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
226 |
^ '$Header: /cvs/stx/stx/libbasic/AbstractSourceFileWriter.st,v 1.12 2015-01-28 17:02:47 cg Exp $' |
16881
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
227 |
! |
0971640d795b
Oops, fixes to class fileout to handle non-ASCII code correctly.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16879
diff
changeset
|
228 |
|
12041 | 229 |
version_CVS |
17334
5c901455163b
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
16881
diff
changeset
|
230 |
^ '$Header: /cvs/stx/stx/libbasic/AbstractSourceFileWriter.st,v 1.12 2015-01-28 17:02:47 cg Exp $' |
12041 | 231 |
! |
232 |
||
233 |
version_SVN |
|
15419
a1da7568bcfe
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
14407
diff
changeset
|
234 |
^ '$ Id: AbstractSourceFileWriter.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
11962 | 235 |
! ! |
15419
a1da7568bcfe
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
14407
diff
changeset
|
236 |