Skip to content

Commit

Permalink
add test export attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Jun 4, 2024
1 parent 25488cb commit e10fcbd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
26 changes: 26 additions & 0 deletions src/Famix2Java-Tests/FAMIX2JavaVisitorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,32 @@ FAMIX2JavaVisitorTest >> testVisitParametricClassWithTwoParameters [
}'
]

{ #category : #test }
FAMIX2JavaVisitorTest >> testVisitPrivateAttribute [

| attribute attributeClass attributeDeclaredType sourceAnchor model resultString |
model := FamixJavaModel new.
attributeDeclaredType := FamixJavaClass new.
attributeDeclaredType name: 'AttributeClass'.
attribute := FamixJavaAttribute new.
attribute name: 'anAttribute'.
attribute isPrivate: true.
attribute declaredType: attributeDeclaredType.
sourceAnchor := FamixJavaSourceTextAnchor new.
sourceAnchor source: ''.
attribute sourceAnchor: sourceAnchor.
attributeClass := FamixJavaClass new.
attributeClass addAttribute: attribute.
model addAll: {
attribute.
attributeClass.
sourceAnchor }.
resultString := String streamContents: [ :stream |
visitor currentStream: stream.
attribute accept: visitor ].
self assert: resultString equals: 'private AttributeClass anAttribute;'
]

{ #category : #test }
FAMIX2JavaVisitorTest >> testVisitPrivateMethod [

Expand Down
8 changes: 4 additions & 4 deletions src/Famix2Java/FAMIX2JavaVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ FAMIX2JavaVisitor >> visitAttribute: aAttribute [

"Printing modifiers"
self indent.
"modifiers := aAttribute cacheAt: #modifiers ifAbsent: [ aAttribute modifiers ].
modifiers isString
ifTrue: [ self <<< modifiers ]
ifFalse: [ modifiers do: [ :modifier | self <<< modifier ] separatedBy: [ self space ] ]."
aAttribute isPrivate ifTrue: [ self << 'private ' ].
aAttribute isProtected ifTrue: [ self << 'protected ' ].
aAttribute isPublic ifTrue: [ self << 'public ' ].
aAttribute isClassSide ifTrue: [ self << 'static ' ].
"Declared Type"
aAttribute declaredType
ifNotNil: [ self printDeclaredType: aAttribute declaredType ]
Expand Down

0 comments on commit e10fcbd

Please sign in to comment.