author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 04 Oct 2014 00:26:35 +0200 | |
changeset 16879 | 2b94ea863dda |
parent 15419 | a1da7568bcfe |
child 16881 | 0971640d795b |
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 |
||
93 |
fileOut: class on:stream withTimeStamp: stampIt withInitialize: initIt withDefinition: withDefinition methodFilter:methodFilter encoder:encoderOrNil |
|
94 |
"raise an error: must be redefined in concrete subclass(es)" |
|
95 |
||
96 |
^ self subclassResponsibility |
|
97 |
||
98 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
13406 | 99 |
! |
100 |
||
101 |
fileOutMethods: methods on:stream |
|
102 |
||
103 |
"Files out a bunch of methods. This is used to file-out extension methods" |
|
104 |
||
105 |
self subclassResponsibility |
|
106 |
||
107 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
108 |
"Created: / 30-12-2009 / 18:34:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
109 |
! |
|
110 |
||
111 |
fileOutPackageDefinition:packageId on:stream |
|
112 |
"Files out a package definition on the stream, so all subsequent |
|
113 |
code entities will be placed in that package" |
|
114 |
||
115 |
self subclassResponsibility |
|
116 |
||
117 |
"Modified: / 16-08-2009 / 09:59:49 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
118 |
"Created: / 30-12-2009 / 18:34:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
11962 | 119 |
! ! |
120 |
||
121 |
!AbstractSourceFileWriter methodsFor:'source writing - comments'! |
|
122 |
||
123 |
fileOutComment: aStringOrStringCollection on: aStream |
|
12109
1e360b1a1062
comment/format in: #fileOutComment:on:
Claus Gittinger <cg@exept.de>
parents:
12053
diff
changeset
|
124 |
"Writes a comment to a stream using proper syntax" |
11962 | 125 |
|
126 |
self fileOutCommentStartOn: aStream. |
|
127 |
aStringOrStringCollection isStringCollection |
|
128 |
ifTrue: |
|
129 |
[aStringOrStringCollection |
|
130 |
do:[:line|self fileOutCommentLine: line on: aStream] |
|
131 |
separatedBy: [aStream cr]] |
|
132 |
ifFalse: |
|
133 |
[(aStringOrStringCollection includes: Character cr) |
|
134 |
ifTrue:"/hmm...multiline comment as string |
|
135 |
[aStringOrStringCollection asStringCollection |
|
136 |
do:[:line|self fileOutCommentLine: line on: aStream] |
|
137 |
separatedBy: [aStream cr]] |
|
138 |
ifFalse: |
|
139 |
[self fileOutCommentLine: aStringOrStringCollection on: aStream]]. |
|
140 |
self fileOutCommentEndOn: aStream. |
|
141 |
||
142 |
"Created: / 21-08-2009 / 09:36:03 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
143 |
! |
|
144 |
||
145 |
fileOutCommentEndOn: aStream |
|
146 |
" |
|
147 |
Writes a comment end mark on aStream. |
|
148 |
" |
|
149 |
||
150 |
^self subclassResponsibility |
|
151 |
||
152 |
"Created: / 21-08-2009 / 09:40:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
153 |
! |
|
154 |
||
155 |
fileOutCommentLine: aString on: aStream |
|
156 |
||
157 |
" |
|
158 |
Writes a single line of comment on a comment to a stream. |
|
159 |
Should not put an cr to the stream!! |
|
160 |
" |
|
161 |
||
162 |
^self subclassResponsibility |
|
163 |
||
164 |
"Created: / 21-08-2009 / 09:42:23 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
165 |
! |
|
166 |
||
167 |
fileOutCommentStartOn: aStream |
|
168 |
" |
|
169 |
Writes a comment start mark on aStream. |
|
170 |
" |
|
171 |
||
172 |
^self subclassResponsibility |
|
173 |
||
174 |
"Created: / 21-08-2009 / 09:40:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
175 |
! ! |
|
176 |
||
12041 | 177 |
!AbstractSourceFileWriter::MethodSourceRewriteQuery class methodsFor:'documentation'! |
178 |
||
179 |
documentation |
|
180 |
" |
|
181 |
hook to allow for just-in-time rewriting of a method's sourceCode while filing out |
|
182 |
used when saving version_XXX methods in a non-XXX sourceCodeManager |
|
183 |
(i.e. to rewrite all non-CVS version methods while saving into a CVS repository) |
|
184 |
this is required because we cannot save an SVN version method (dollar-ID-...-dollar) into a |
|
185 |
CVS repository without loosing the original string with the next checkout, because it also gets |
|
186 |
expanded by CVS. The same is true vice-versa for CVS-Ids, which get clobbered by SVN. |
|
187 |
||
188 |
see SmalltalkChunkFileSourceWriter fileOutMethod:on: |
|
189 |
" |
|
190 |
! ! |
|
191 |
||
192 |
!AbstractSourceFileWriter::MethodSourceRewriteQuery methodsFor:'accessing'! |
|
193 |
||
194 |
method |
|
195 |
^ method |
|
196 |
! |
|
197 |
||
198 |
method:methodArg source:sourceArg |
|
199 |
method := methodArg. |
|
200 |
source := sourceArg. |
|
201 |
! |
|
202 |
||
203 |
source |
|
204 |
^ source |
|
205 |
! ! |
|
206 |
||
11962 | 207 |
!AbstractSourceFileWriter class methodsFor:'documentation'! |
208 |
||
12041 | 209 |
version_CVS |
16879
2b94ea863dda
Moved #generatingSourceForOriginal: from SmalltalkChunkFileSourceWriter to
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15419
diff
changeset
|
210 |
^ '$Header: /cvs/stx/stx/libbasic/AbstractSourceFileWriter.st,v 1.10 2014-10-03 22:26:35 vrany Exp $' |
12041 | 211 |
! |
212 |
||
213 |
version_SVN |
|
15419
a1da7568bcfe
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
14407
diff
changeset
|
214 |
^ '$ Id: AbstractSourceFileWriter.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
11962 | 215 |
! ! |
15419
a1da7568bcfe
class: AbstractSourceFileWriter
Claus Gittinger <cg@exept.de>
parents:
14407
diff
changeset
|
216 |