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