Skip to content

Commit 9d44ff0

Browse files
committed
fixes
1 parent aeb5a03 commit 9d44ff0

File tree

1 file changed

+51
-60
lines changed

1 file changed

+51
-60
lines changed

src/Famix2Java/FAMIX2JavaVisitor.class.st

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ FAMIX2JavaVisitor >> crlf [
3838

3939
{ #category : #'public-exporting' }
4040
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 ]
4743
]
4844

4945
{ #category : #accessing }
@@ -87,14 +83,11 @@ FAMIX2JavaVisitor >> printImplements: aClass [
8783
"aClass name = 'AbstractActionBean'
8884
ifTrue: [ 1 halt ]."
8985
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 ]).
9487
interfaces isNotEmpty
9588
ifTrue: [ self
9689
<<< ' implements ';
97-
<<< interfaces first to name ].
90+
<<< interfaces first target name ].
9891
2 to: interfaces size do: [ :index |
9992
self
10093
<<< ', ';
@@ -244,55 +237,53 @@ FAMIX2JavaVisitor >> visitClass: aClass [
244237
| file |
245238
file := self rootFolder / (aClass name , '.java').
246239
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 ].
285276
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+
<< '}' ]
296287
]
297288

298289
{ #category : #generated }
@@ -324,7 +315,7 @@ FAMIX2JavaVisitor >> visitMethod: aMethod [
324315
ifFalse: [ self
325316
<<< aMethod name;
326317
<<< '('.
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 <<< ',' ].
328319
self <<< ')' ]
329320
ifTrue: [ self << 'static' ].
330321
"Printing body of method if class is not abstract or an interface"

0 commit comments

Comments
 (0)