Skip to content

Commit

Permalink
can export when not bound
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed May 2, 2024
1 parent de9865d commit 3035c1d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
25 changes: 25 additions & 0 deletions src/Carrefour-Exporter-Tests/CRFExporterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,28 @@ CRFExporterTest >> testExportOneClassWithOneMethodBinded [
}'
]

{ #category : #tests }
CRFExporterTest >> testExportOneClassWithOneMethodNotBinded [

| model resultString aClass method primitiveInt |
model := FamixJavaModel new.
aClass := model newClassNamed: 'DemoClass'.
method := model newMethodNamed: 'aMethod'.
primitiveInt := model newPrimitiveTypeNamed: 'int'.
method declaredType: primitiveInt.
aClass addMethod: method.


resultString := String streamContents: [ :stream |
exporter currentStream: stream.
aClass accept: exporter ].
self assert: resultString equals: 'public class DemoClass {
int aMethod() {
}
}'
]
26 changes: 17 additions & 9 deletions src/Carrefour-Exporter/CRFExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,21 @@ CRFExporter >> visitMethod: aMethod [
aMethod isAbstract isNotNil and: [ aMethod isAbstract ] ])
ifTrue: [ self <<< ';' ]
ifFalse: [
aMethod fast ifNotNil: [ :fastMethod |
| fastJavaExporterVisitor |
fastJavaExporterVisitor := FASTJavaExportVisitor new
outputStream: self currentStream;
indentSize: tabulationSize;
yourself.
self <<< ' '.
1 to: tabs do: [ :tab | fastJavaExporterVisitor indent ].
fastMethod statementBlock accept: fastJavaExporterVisitor ] ]
aMethod fast
ifNotNil: [ :fastMethod |
| fastJavaExporterVisitor |
fastJavaExporterVisitor := FASTJavaExportVisitor new
outputStream: self currentStream;
indentSize: tabulationSize;
yourself.
self <<< ' '.
1 to: tabs do: [ :tab | fastJavaExporterVisitor indent ].
fastMethod statementBlock accept: fastJavaExporterVisitor ]
ifNil: [
currentStream << ' {'.
self eol.
self <<< aMethod bodySourceText.
self
eol;
<< '}' ] ]
]

0 comments on commit 3035c1d

Please sign in to comment.