Skip to content

Commit

Permalink
simplify visitAnnotationInstance:
Browse files Browse the repository at this point in the history
and kill dead code
  • Loading branch information
badetitou committed May 2, 2024
1 parent 39b6185 commit 514f416
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/Famix2Java/FAMIX2JavaVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,11 @@ FAMIX2JavaVisitor >> visitAnnotationInstance: aAnnotationInstance [
self
<< '@';
<<< aAnnotationInstance annotationType name.
aAnnotationInstance attributes ifNotEmpty: [ :attributes |
aAnnotationInstance attributes ifNotEmpty: [ :attributes |
self <<< '('.
1 to: attributes size - 1 do: [ :index |
(attributes at: index) accept: self.
self <<< ',' ].
attributes last accept: self.
attributes
do: [ :attribute | attribute accept: self ]
separatedBy: [ self <<< ',' ].
self <<< ')' ]
]

Expand All @@ -267,14 +266,13 @@ FAMIX2JavaVisitor >> visitAnnotationInstanceAttribute: aAnnotationInstanceAttrib

{ #category : #accessing }
FAMIX2JavaVisitor >> visitAttribute: aAttribute [

"Visit an attribute to print its annotations and its field."

" Printing the annotations for the attribute"

| attributeSource attributeSourceFromName |
aAttribute annotationInstances do: [ :annotationInstance |
annotationInstance accept: self .
aAttribute annotationInstances do: [ :annotationInstance |
annotationInstance accept: self.
self eol ].

"Printing modifiers"
Expand All @@ -293,13 +291,22 @@ FAMIX2JavaVisitor >> visitAttribute: aAttribute [
<<< aAttribute name.

"This is an hack to get the affectation is any (hack because some problems with annotations that are sometimes part of the sourceAnchor...)"
attributeSource := aAttribute sourceAnchor ifNil: [ '' ] ifNotNil: [ :sourceAnchor | sourceAnchor sourceText ].
attributeSource ifNotEmpty: [
attributeSourceFromName := attributeSource copyFrom: (attributeSource findString: aAttribute name) to: attributeSource size.
(attributeSourceFromName includesSubstring: '=') ifTrue: [
attributeSource := aAttribute sourceAnchor
ifNil: [ '' ]
ifNotNil: [ :sourceAnchor |
sourceAnchor sourceText ].
attributeSource ifNotEmpty: [
attributeSourceFromName := attributeSource
copyFrom:
(attributeSource findString:
aAttribute name)
to: attributeSource size.
(attributeSourceFromName includesSubstring: '=') ifTrue: [
self
space;
<<< ((attributeSourceFromName copyFrom: (attributeSourceFromName findString: '=') to: attributeSourceFromName size) removeSuffix: ';') ] ].
<<< ((attributeSourceFromName
copyFrom: (attributeSourceFromName findString: '=')
to: attributeSourceFromName size) removeSuffix: ';') ] ].
self <<< ';'
]

Expand Down Expand Up @@ -400,11 +407,6 @@ FAMIX2JavaVisitor >> visitMethod: aMethod [
"Printing method annotations"
self printMethodAnnotations: aMethod.
"Printing modifiers of method ex: static,public/private/protected"
"aMethod modifiers
do: [ :modifier |
self
<< modifier;
space ]."
self indent.
aMethod isPrivate ifTrue: [ self <<< 'private ' ].
aMethod isProtected ifTrue: [ self <<< 'protected ' ].
Expand Down

0 comments on commit 514f416

Please sign in to comment.