Skip to content

Commit

Permalink
fix Dictionnary and Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiovandewaeter committed May 23, 2024
1 parent ad43b96 commit 6f7134d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Famix-Value-Importer/Collection.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Collection >> asJavaJacksonValueOn: importer [
Collection >> asPharoJacksonValueOn: importer [

^ importer
importCollection: self
importArray: self
of: (importer loadTypeNamed: self className)
]

Expand Down
41 changes: 27 additions & 14 deletions src/Famix-Value-Importer/FamixValuePharoJacksonImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ FamixValuePharoJacksonImporter >> idKey: aString [
idKey := aString
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> importArray: rawValue of: type [

^ objectDict
at: rawValue first
ifAbsentPut: [
super importCollection: rawValue allButFirst of: type ]
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> importAssociation: rawValue of: type [

Expand Down Expand Up @@ -75,23 +84,23 @@ FamixValuePharoJacksonImporter >> importClosure: value of: type [
{ #category : #importing }
FamixValuePharoJacksonImporter >> importCollection: rawValue of: type [

^ objectDict
at: rawValue first
ifAbsentPut: [
super importCollection: rawValue allButFirst of: type ]
| collection |
collection := self model newOfCollection type: type.
objectDict at: (self getObjectIdentity: rawValue) put: collection.
(rawValue at: '@') do: [ :rawElement |
collection addValue: (self model newOfCollectionElement value:
(self importValue: rawElement)) ].
^ collection
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> importDictionary: rawValue of: type [

| dictionary assoc |
| dictionary |
dictionary := self model newOfDictionary type: type.
objectDict at: (self getObjectIdentity: rawValue) put: dictionary.
rawValue associationsDo: [ :rawAssoc |
assoc := self model newOfDictionaryAssociation dictionary:
dictionary.
assoc key: (self importValue: rawAssoc key).
assoc value: (self importValue: rawAssoc value) ].
(rawValue at: '@') do: [ :rawAssoc |
(rawAssoc asPharoJacksonValueOn: self) dictionary: dictionary ].
^ dictionary
]

Expand Down Expand Up @@ -159,12 +168,10 @@ FamixValuePharoJacksonImporter >> specialTypes [
put: [ :value :type | self importAssociation: value of: type ].
specialTypes
at: 'OrderedCollection'
put: [ :value :type |
self importCollection: (value at: 'array') of: type ].
put: [ :value :type | self importCollection: value of: type ].
specialTypes
at: 'Set'
put: [ :value :type |
self importCollection: (value at: 'array') of: type ].
put: [ :value :type | self importCollection: value of: type ].
specialTypes
at: 'FullBlockClosure'
put: [ :value :type | self importClosure: value of: type ].
Expand All @@ -174,6 +181,12 @@ FamixValuePharoJacksonImporter >> specialTypes [
specialTypes
at: 'WideSymbol'
put: [ :value :type | self importSymbol: value of: type ].
specialTypes
at: 'Dictionary'
put: [ :value :type | self importDictionary: value of: type ].
specialTypes
at: 'OrderedDictionary'
put: [ :value :type | self importDictionary: value of: type ].
specialTypes ]
]

Expand Down

0 comments on commit 6f7134d

Please sign in to comment.