From ecce0b9ef347b24225204c42d4ae8f358cbb1465 Mon Sep 17 00:00:00 2001 From: Gabriel Darbord Date: Thu, 6 Jun 2024 18:07:45 +0200 Subject: [PATCH 1/2] Importer: No attribute search in interfaces --- .../FamixValueJavaJacksonImporter.class.st | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st b/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st index fe94f57..518554d 100644 --- a/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st +++ b/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st @@ -62,6 +62,10 @@ FamixValueJavaJacksonImporter >> importClassReference: rawValue of: type [ FamixValueJavaJacksonImporter >> importObjectAttribute: rawValue of: type named: name [ | attribute | + type isInterface ifTrue: [ + Error signal: + 'Cannot find attributes in interfaces. Signaled for attribute `' + , name , '` and interface `' , type name , '`.' ]. (attribute := type findAttributeNamed: name) ifNotNil: [ "Skip transient attributes." attribute isTransient ifTrue: [ ^ nil ] ]. ^ self From b497c8c1314ede100f9a6a87d32bcf1ffd012032 Mon Sep 17 00:00:00 2001 From: Gabriel Darbord Date: Thu, 6 Jun 2024 18:11:09 +0200 Subject: [PATCH 2/2] Importers: Dispatch key extraction to specialized method In preparation for **not** removing keys from raw objects --- src/Famix-Value-Importer/Dictionary.extension.st | 4 ++-- .../FamixValueJavaJacksonImporter.class.st | 6 ++++++ .../FamixValuePharoJacksonImporter.class.st | 12 ++++++++++++ .../OrderedDictionary.extension.st | 14 +++++++------- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/Famix-Value-Importer/Dictionary.extension.st b/src/Famix-Value-Importer/Dictionary.extension.st index 4cc7dcd..8fa2fcd 100644 --- a/src/Famix-Value-Importer/Dictionary.extension.st +++ b/src/Famix-Value-Importer/Dictionary.extension.st @@ -3,7 +3,7 @@ Extension { #name : #Dictionary } { #category : #'*Famix-Value-Importer' } Dictionary >> asPharoJacksonValueOn: importer [ - ^ (self removeKey: importer typeKey ifAbsent: nil) + ^ (importer getObjectType: self) ifNotNil: [ :className | "object of an unloaded class" className = 'Class' ifTrue: [ @@ -15,7 +15,7 @@ Dictionary >> asPharoJacksonValueOn: importer [ importObject: self of: (importer loadTypeNamed: className) ] ] ifNil: [ "species of dictionary" - (self removeKey: importer refKey ifAbsent: nil) + (importer getObjectReference: self) ifNotNil: [ :refId | "if @ref" importer getObjectFromIdentity: refId diff --git a/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st b/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st index 518554d..8badc65 100644 --- a/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st +++ b/src/Famix-Value-Importer/FamixValueJavaJacksonImporter.class.st @@ -36,6 +36,12 @@ FamixValueJavaJacksonImporter >> getObjectIdentity: rawObject [ ^ rawObject removeKey: self idKey ifAbsent: nil ] +{ #category : #enumerating } +FamixValueJavaJacksonImporter >> getObjectType: rawObject [ + + ^ rawObject removeKey: self typeKey ifAbsent: nil +] + { #category : #accessing } FamixValueJavaJacksonImporter >> idKey [ diff --git a/src/Famix-Value-Importer/FamixValuePharoJacksonImporter.class.st b/src/Famix-Value-Importer/FamixValuePharoJacksonImporter.class.st index df709a9..d4ae209 100644 --- a/src/Famix-Value-Importer/FamixValuePharoJacksonImporter.class.st +++ b/src/Famix-Value-Importer/FamixValuePharoJacksonImporter.class.st @@ -24,6 +24,18 @@ FamixValuePharoJacksonImporter >> getObjectIdentity: rawObject [ ^ rawObject removeKey: self idKey ifAbsent: nil ] +{ #category : #enumerating } +FamixValuePharoJacksonImporter >> getObjectReference: rawObject [ + + ^ rawObject removeKey: self refKey ifAbsent: nil +] + +{ #category : #enumerating } +FamixValuePharoJacksonImporter >> getObjectType: rawObject [ + + ^ rawObject removeKey: self typeKey ifAbsent: nil +] + { #category : #accessing } FamixValuePharoJacksonImporter >> idKey [ diff --git a/src/Famix-Value-Importer/OrderedDictionary.extension.st b/src/Famix-Value-Importer/OrderedDictionary.extension.st index 13296d1..3093c87 100644 --- a/src/Famix-Value-Importer/OrderedDictionary.extension.st +++ b/src/Famix-Value-Importer/OrderedDictionary.extension.st @@ -4,11 +4,11 @@ Extension { #name : #OrderedDictionary } OrderedDictionary >> asJavaJacksonValueOn: importer [ | type | - (self removeKey: importer typeKey ifAbsent: nil) - ifNotNil: [ :typeName | type := importer loadTypeNamed: typeName ] - ifNil: [ - (type := importer typeInference) ifNil: [ - self error: 'Cannot determine type.' ] ]. + type := (importer getObjectType: self) + ifNotNil: [ :typeName | importer loadTypeNamed: typeName ] + ifNil: [ + importer typeInference ifNil: [ + Error signal: 'Cannot determine type.' ] ]. ^ (type isUnknownType or: [ type isDictionaryType ]) ifTrue: [ importer importDictionary: self of: type ] ifFalse: [ importer importObject: self of: type ] @@ -17,7 +17,7 @@ OrderedDictionary >> asJavaJacksonValueOn: importer [ { #category : #'*Famix-Value-Importer' } OrderedDictionary >> asPharoJacksonValueOn: importer [ - ^ (self removeKey: importer typeKey ifAbsent: nil) + ^ (importer getObjectType: self) ifNotNil: [ :className | "object of an unloaded class" className = 'Class' ifTrue: [ @@ -29,7 +29,7 @@ OrderedDictionary >> asPharoJacksonValueOn: importer [ importObject: self of: (importer loadTypeNamed: className) ] ] ifNil: [ "species of dictionary" - (self removeKey: importer refKey ifAbsent: nil) + (importer getObjectReference: self) ifNotNil: [ :refId | "if @ref" importer getObjectFromIdentity: refId