Skip to content

Commit

Permalink
Merge 9a9b95e
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiovandewaeter committed May 21, 2024
2 parents 1c90a7c + 9a9b95e commit 89e36ca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 67 deletions.
2 changes: 1 addition & 1 deletion src/BaselineOfFamixValue/BaselineOfFamixValue.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BaselineOfFamixValue >> dependencies: spec [
loads: 'tools' ];
baseline: 'Carrefour'
with: [
spec repository: 'github://moosetechnology/Carrefour:v4/src' ]
spec repository: 'github://moosetechnology/Carrefour:v5/src' ]
]

{ #category : #baselines }
Expand Down
6 changes: 3 additions & 3 deletions src/Famix-Value-Importer/FamixValueAbstractImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ FamixValueAbstractImporter >> importDictionary: rawValue of: type [
| dictionary keyType valueType assoc |
dictionary := self model newOfDictionary type: type.
(self parametricTypeInferencesOf: type)
ifNotNil: [ :paramTypeInferences |
ifNotEmpty: [ :paramTypeInferences |
keyType := paramTypeInferences at: 1.
valueType := paramTypeInferences at: 2 ]
ifNil: [ keyType := valueType := nil ].
ifEmpty: [ keyType := valueType := nil ].
rawValue associationsDo: [ :rawAssoc |
assoc := self model newOfDictionaryAssociation dictionary:
dictionary.
Expand Down Expand Up @@ -194,7 +194,7 @@ FamixValueAbstractImporter >> parametricTypeInferencesOf: type [
type isParametricEntity ifFalse: [ ^ { } ].
^ type isGenericEntity
ifTrue: [
self typeInference ifNotNil: [ :inference |
self typeInference ifNil: [ { } ] ifNotNil: [ :inference |
(inference isDictionaryType and: [
inference concreteParameters size = 1 ])
ifTrue: [
Expand Down
71 changes: 8 additions & 63 deletions src/Famix-Value-Importer/FamixValuePharoJacksonImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ Class {
#category : #'Famix-Value-Importer'
}

{ #category : #importing }
{ #category : #enumerating }
FamixValuePharoJacksonImporter >> getDefaultUnknownType [

^ self getUnknownTypeNamed: 'Object'
]

{ #category : #importing }
{ #category : #enumerating }
FamixValuePharoJacksonImporter >> getObjectIdentity: rawObject [
"Keep track of objects by using the id given by Jackson.
References to previously seen objects are serialized by using this id."

^ rawObject removeKey: self idKey ifAbsent: nil
]

{ #category : #importing }
{ #category : #accessing }
FamixValuePharoJacksonImporter >> idKey [

^ idKey ifNil: [ idKey := '@id' ]
]

{ #category : #importing }
{ #category : #accessing }
FamixValuePharoJacksonImporter >> idKey: aString [

idKey := aString
Expand Down Expand Up @@ -104,81 +104,26 @@ FamixValuePharoJacksonImporter >> importObject: rawObject of: type [
^ super importObject: rawObject of: type
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> importObjectAttribute: rawValue of: type named: name [

| attribute |
(attribute := type findAttributeNamed: name).
^ self
withTypeInference:
(attribute ifNotNil: [ attribute declaredType ])
do: [
self model newOfObjectAttribute
value: (self importValue: rawValue);
attribute: attribute ]
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> importSpecialObject: rawValue of: type [
"Some objects have special rules for serialization.
They should have a corresponding type wrapper that knows how to handle them."

self specialTypes
at: type mooseNameWithDots
ifPresent: [ :typeWrapper |
^ typeWrapper import: rawValue wrapping: type on: self ].
^ nil
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> importValue: rawValue [

^ rawValue asPharoJacksonValueOn: self
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> importValueFromList: rawValue of: type [
"Jackson can serialize different types of values in a list, so we need to find out which it is."

rawValue isCollection ifTrue: [
^ self importCollection: rawValue of: type ].
type isUnknownType ifTrue: [
^ self model newOfUnknownType
value: rawValue;
type: type ].
(type usesFamixTrait: FamixTEnum) ifTrue: [
^ self importEnumValue: rawValue of: type ].
(self isPrimitiveType: type) ifTrue: [
^ self model newOfPrimitiveType
value: rawValue;
type: type ].
type isClass ifTrue: [ "might be a special object"
(self importSpecialObject: rawValue of: type) ifNotNil: [ :object |
^ object ] ].
self error: 'Unknown type: ' , type mooseNameWithDots
]

{ #category : #importing }
FamixValuePharoJacksonImporter >> isPrimitiveType: type [

^ type isPrimitiveType or: [ "Classes wrapping primitives are also considered primitives."
type isPrimitiveWrapper ]
]

{ #category : #parsing }
FamixValuePharoJacksonImporter >> parseList: serializedValues [
"Ignore first element which is the id of the array."

^ (super parseList: serializedValues) allButFirst
]

{ #category : #importing }
{ #category : #accessing }
FamixValuePharoJacksonImporter >> refKey [

^ refKey ifNil: [ refKey := '@ref' ]
]

{ #category : #importing }
{ #category : #accessing }
FamixValuePharoJacksonImporter >> refKey: aString [

refKey := aString
Expand Down Expand Up @@ -209,13 +154,13 @@ FamixValuePharoJacksonImporter >> specialTypes [
specialTypes ]
]

{ #category : #importing }
{ #category : #accessing }
FamixValuePharoJacksonImporter >> typeKey [

^ typeKey ifNil: [ typeKey := '@type' ]
]

{ #category : #importing }
{ #category : #accessing }
FamixValuePharoJacksonImporter >> typeKey: aString [

typeKey := aString
Expand Down

0 comments on commit 89e36ca

Please sign in to comment.