diff --git a/src/Famix2Java-Tests/FAMIX2JavaVisitorTest.class.st b/src/Famix2Java-Tests/FAMIX2JavaVisitorTest.class.st index 1945dcd..74196b7 100644 --- a/src/Famix2Java-Tests/FAMIX2JavaVisitorTest.class.st +++ b/src/Famix2Java-Tests/FAMIX2JavaVisitorTest.class.st @@ -571,7 +571,6 @@ FAMIX2JavaVisitorTest >> testVisitBasicInterface [ aClass accept: visitor ]. self assert: resultString equals: 'public interface DemoInterface { - }' ] @@ -687,6 +686,33 @@ FAMIX2JavaVisitorTest >> testVisitClassWithMethodsAndAttributes [ }' ] +{ #category : #test } +FAMIX2JavaVisitorTest >> testVisitInterfaceWithOneMethod [ + + | model resultString anInterface voidPrimitive interfaceMethod | + model := FamixJavaModel new. + voidPrimitive := model newPrimitiveTypeNamed: 'void'. + anInterface := model newInterface + name: 'DemoInterface'; + yourself. + + "Add a method to the class" + interfaceMethod := model newMethodNamed: 'insert'. + interfaceMethod isPublic: true. + interfaceMethod declaredType: voidPrimitive. + + anInterface addMethod: interfaceMethod. + + resultString := String streamContents: [ :stream | + visitor currentStream: stream. + anInterface accept: visitor ]. + self assert: resultString equals: 'public interface DemoInterface { + + public void insert(); + +}' +] + { #category : #test } FAMIX2JavaVisitorTest >> testVisitMethodDeclaredTypePrimitiveVoid [ diff --git a/src/Famix2Java/FAMIX2JavaVisitor.class.st b/src/Famix2Java/FAMIX2JavaVisitor.class.st index c304cec..8bb2222 100644 --- a/src/Famix2Java/FAMIX2JavaVisitor.class.st +++ b/src/Famix2Java/FAMIX2JavaVisitor.class.st @@ -407,22 +407,13 @@ FAMIX2JavaVisitor >> visitInterface: aClass [ currentStream << aClass name. "printing inheritance and implementation" self printExtends: aClass. - currentStream << ' {'. + self << ' {'. self eol. - "Printing Attributs" self indentPlus. - aClass attributes do: [ :attribute | - attribute accept: self clone. - self eol ]. - self eol. - "Printing Methods" - aClass methods do: [ :method | - self eol. - method accept: self clone. - self eol ]. - "Closing Class" + self printContentOfClass: aClass. self eol. - currentStream << '}' + self indentMinus. + self <<| '}' ] { #category : #accessing } @@ -465,7 +456,7 @@ FAMIX2JavaVisitor >> visitMethod: aMethod [ separatedBy: [ self << ', ' ] ]. "Printing body of method if class is not abstract or an interface" - ((aMethod atScope: FamixTClass) anyOne isInterface or: [ + (aMethod parentType isInterface or: [ aMethod isAbstract isNotNil and: [ aMethod isAbstract ] ]) ifTrue: [ self << ';' ] ifFalse: [