Skip to content

Commit

Permalink
Simplify attribute filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed Jul 2, 2024
1 parent 80483cb commit f24fb0e
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Class {
'markedForReflection',
'constructorCache',
'staticAttributesCache',
'objectExportStrategy',
'setterCache'
'objectExportStrategy'
],
#category : #'Famix-Value-Exporter'
}
Expand Down Expand Up @@ -74,21 +73,16 @@ FamixValue2FASTJavaVisitor >> constructObject: object [
FamixValue2FASTJavaVisitor >> filterAttributesToSet: attributes for: object [
"No need to set attributes that are set in the constructor."

^ (setterCache at: object type ifAbsentPut: [
| famixAttributes |
famixAttributes := attributes collect: [ :attribute |
attribute attribute ].
constructorCache
at: object type
ifPresent: [ :constructor |
constructorCache
at: constructor
ifPresent: [ :constructorAttributes |
famixAttributes difference: constructorAttributes ]
ifAbsent: [ famixAttributes ] ]
ifAbsent: [ famixAttributes ] ]) ifNotEmpty: [ :famixAttributes |
attributes select: [ :attribute |
famixAttributes includes: attribute attribute ] ]
^ constructorCache
at: object type
ifPresent: [ :constructor |
constructorCache
at: constructor
ifPresent: [ :constructorAttributes |
attributes reject: [ :attribute |
constructorAttributes includes: attribute attribute ] ]
ifAbsent: [ attributes ] ]
ifAbsent: [ attributes ]
]

{ #category : #private }
Expand Down Expand Up @@ -138,7 +132,6 @@ FamixValue2FASTJavaVisitor >> findStaticAttributeMatching: object [
FamixValue2FASTJavaVisitor >> initialize [

constructorCache := IdentityDictionary new.
setterCache := IdentityDictionary new.
staticAttributesCache := IdentityDictionary new
]

Expand Down

0 comments on commit f24fb0e

Please sign in to comment.