@@ -38,12 +38,8 @@ FAMIX2JavaVisitor >> crlf [
38
38
39
39
{ #category : #' public-exporting' }
40
40
FAMIX2JavaVisitor >> export: aFAMIXCompatibilityModel [
41
- [ aFAMIXCompatibilityModel allModelNamespaces
42
- do: [ :namespace | self clone visit: namespace ] ]
43
- ensure : [ currentStream
44
- ifNotNil: [ currentStream
45
- flush;
46
- close ] ]
41
+ aFAMIXCompatibilityModel allModelNamespaces
42
+ do: [ :namespace | self clone visit: namespace ]
47
43
]
48
44
49
45
{ #category : #accessing }
@@ -87,14 +83,11 @@ FAMIX2JavaVisitor >> printImplements: aClass [
87
83
" aClass name = 'AbstractActionBean'
88
84
ifTrue: [ 1 halt ]."
89
85
interfaces := OrderedCollection new .
90
- interfaces
91
- addAll:
92
- (aClass superInheritances
93
- select: [ :inheritances | inheritances to isInterface ]).
86
+ interfaces addAll: (aClass superInheritances select: [ :inheritances | inheritances target isInterface ]).
94
87
interfaces isNotEmpty
95
88
ifTrue: [ self
96
89
<<< ' implements ' ;
97
- <<< interfaces first to name ].
90
+ <<< interfaces first target name ].
98
91
2 to: interfaces size do: [ :index |
99
92
self
100
93
<<< ' , ' ;
@@ -244,55 +237,53 @@ FAMIX2JavaVisitor >> visitClass: aClass [
244
237
| file |
245
238
file := self rootFolder / (aClass name , ' .java' ).
246
239
file deleteIfAbsent: [ ].
247
- currentStream := file writeStream.
248
- " Printing class package and imports if the class is not an inner class"
249
- aClass container isNamespace
250
- ifTrue: [ self << ' package ' .
251
- aClass container fullNamePrintOn: currentStream.
252
- self
253
- <<< ' ;' ;
254
- crlf;
255
- crlf.
256
- self printImports: aClass.
257
- self crlf ].
258
- " Printing class annotations"
259
- aClass annotationInstances
260
- do: [ :annotationInstance |
261
- self clone visit: annotationInstance.
262
- self crlf ].
263
- " Printing Class declaration"
264
- currentStream << ' public ' .
265
- aClass isInterface
266
- ifTrue: [ currentStream << ' interface ' ]
267
- ifFalse: [ currentStream << ' class ' ].
268
- currentStream << aClass name.
269
- " printing inheritance and implementation"
270
- self printExtends: aClass.
271
- self printImplements: aClass.
272
- currentStream
273
- << ' {' ;
274
- << String crlf.
275
- " Printing Attributs"
276
- tabs := tabs + 1 .
277
- aClass attributes
278
- do: [ :attribute |
279
- self clone visit: attribute.
280
- currentStream << String crlf ].
281
- self crlf.
282
- " Printing Methods"
283
- aClass methods
284
- do: [ :method |
240
+ file
241
+ writeStreamDo: [ :stream |
242
+ currentStream := stream.
243
+ " Printing class package and imports if the class is not an inner class"
244
+ aClass container isNamespace
245
+ ifTrue: [ self << ' package ' .
246
+ aClass container fullNamePrintOn: currentStream.
247
+ self
248
+ <<< ' ;' ;
249
+ crlf;
250
+ crlf.
251
+ self printImports: aClass.
252
+ self crlf ].
253
+ " Printing class annotations"
254
+ aClass annotationInstances
255
+ do: [ :annotationInstance |
256
+ self clone visit: annotationInstance.
257
+ self crlf ].
258
+ " Printing Class declaration"
259
+ currentStream << ' public ' .
260
+ aClass isInterface
261
+ ifTrue: [ currentStream << ' interface ' ]
262
+ ifFalse: [ currentStream << ' class ' ].
263
+ currentStream << aClass name.
264
+ " printing inheritance and implementation"
265
+ self printExtends: aClass.
266
+ self printImplements: aClass.
267
+ currentStream
268
+ << ' {' ;
269
+ << String crlf.
270
+ " Printing Attributs"
271
+ tabs := tabs + 1 .
272
+ aClass attributes
273
+ do: [ :attribute |
274
+ self clone visit: attribute.
275
+ currentStream << String crlf ].
285
276
self crlf.
286
- self clone visit: method.
287
- self crlf ].
288
- " Closing Class "
289
- currentStream
290
- < < String crlf;
291
- < < ' } ' .
292
- " Closing Stream "
293
- currentStream
294
- flush ;
295
- close
277
+ " Printing Methods "
278
+ aClass methods
279
+ do: [ :method |
280
+ self crlf.
281
+ self clone visit: method.
282
+ self crlf ] .
283
+ " Closing Class "
284
+ currentStream
285
+ < < String crlf ;
286
+ < < ' } ' ]
296
287
]
297
288
298
289
{ #category : #generated }
@@ -324,7 +315,7 @@ FAMIX2JavaVisitor >> visitMethod: aMethod [
324
315
ifFalse: [ self
325
316
<<< aMethod name;
326
317
<<< ' (' .
327
- aMethod parameters size - 1 do: [ :index | self clone visit: (aMethod parameters at: index) ] separatedBy: [ self <<< ' ,' ].
318
+ aMethod parameters do: [ :parameter | self clone visit: parameter ] separatedBy: [ self <<< ' ,' ].
328
319
self <<< ' )' ]
329
320
ifTrue: [ self << ' static' ].
330
321
" Printing body of method if class is not abstract or an interface"
0 commit comments