From 35b5d56aa5018dfa92937f67733c694607b1cd6d Mon Sep 17 00:00:00 2001 From: Gabriel Darbord Date: Tue, 30 Jan 2024 17:08:09 +0100 Subject: [PATCH] Smart imports + Decorate type expressions + Refactors - Avoid importing types with same name, refer to them with fully qualified name. - Export arrays correctly, even though Famix does not represent them. - WIP stub export --- .../FamixValueOfType.extension.st | 12 ++ .../FamixValueOfObjectAttribute.class.st | 8 ++ .../FamixValueOfType.class.st | 21 ++++ .../FamixValueUnknownType.class.st | 6 + src/Famix-Value-Exporter/FASTBuilder.class.st | 35 ++++++ .../FASTJavaBuilder.class.st | 97 ++++++++++++++++ .../FASTJavaVariableExpression.extension.st | 7 +- .../FamixJavaAttribute.extension.st | 18 ++- .../FamixJavaType.extension.st | 18 ++- .../FamixTClass.extension.st | 6 +- .../FamixTParameterizedType.extension.st | 6 + .../FamixValue2ASTVisitor.class.st | 9 +- .../FamixValue2FASTJavaVisitor.class.st | 106 +++++++++++++++++- .../FamixValueOfPrimitiveType.extension.st | 6 - .../FamixValueOfType.extension.st | 2 +- .../FamixTClass.extension.st | 6 +- .../FamixTParameterizedType.extension.st | 4 +- .../FamixValueAbstractImporter.class.st | 2 +- .../FamixValueUnknownType.extension.st | 2 +- .../FamixValueJavaArray.class.st | 11 ++ 20 files changed, 345 insertions(+), 37 deletions(-) create mode 100644 src/Famix-Value-Exporter/FASTBuilder.class.st create mode 100644 src/Famix-Value-Exporter/FASTJavaBuilder.class.st diff --git a/src/Famix-Value-Entities-Extensions/FamixValueOfType.extension.st b/src/Famix-Value-Entities-Extensions/FamixValueOfType.extension.st index db94c10..cab5c2e 100644 --- a/src/Famix-Value-Entities-Extensions/FamixValueOfType.extension.st +++ b/src/Famix-Value-Entities-Extensions/FamixValueOfType.extension.st @@ -45,3 +45,15 @@ FamixValueOfType >> value: anObject [ self subclassResponsibility ] + +{ #category : #'*Famix-Value-Entities-Extensions' } +FamixValueOfType >> varName [ + "Basic variable name of a value." + + ^ self typedEntity + ifNotNil: [ :typedEntity | typedEntity name ] + ifNil: [ + attributeInObjects size = 1 + ifTrue: [ attributeInObjects first attribute name ] + ifFalse: [ self type baseName uncapitalized ] ] +] diff --git a/src/Famix-Value-Entities/FamixValueOfObjectAttribute.class.st b/src/Famix-Value-Entities/FamixValueOfObjectAttribute.class.st index 2010702..048daa4 100644 --- a/src/Famix-Value-Entities/FamixValueOfObjectAttribute.class.st +++ b/src/Famix-Value-Entities/FamixValueOfObjectAttribute.class.st @@ -65,3 +65,11 @@ FamixValueOfObjectAttribute >> value: anObject [ value := anObject ] + +{ #category : #generate } +FamixValueOfObjectAttribute >> varName [ + + ^ self attribute + ifNotNil: [ :attribute | attribute name ] + ifNil: [ value varName ] +] diff --git a/src/Famix-Value-Entities/FamixValueOfType.class.st b/src/Famix-Value-Entities/FamixValueOfType.class.st index 4b58cc4..a0245d1 100644 --- a/src/Famix-Value-Entities/FamixValueOfType.class.st +++ b/src/Famix-Value-Entities/FamixValueOfType.class.st @@ -54,6 +54,27 @@ FamixValueOfType >> addValueInDictionary: anObject [ ^ self valueInDictionaries add: anObject ] +{ #category : #'ston persistence' } +FamixValueOfType >> asJsonString [ + "Currently does not work. Ideas: + - Find a way to serialize any object while handling circular dependencies. + - Use the json stored in the root value to read it into raw objects and traverse the path to this value." + + self flag: #TODO. + ^ self asNeoJSONObject asString +] + +{ #category : #'ston persistence' } +FamixValueOfType >> asNeoJSONObject [ + + self flag: #TODO. "see #asJsonString" + ^ self typedEntity + ifNotNil: [ "at root" + NeoJSONObject fromString: (self cacheAt: #json ifAbsent: '{}') ] + ifNil: [ "how to iterate until root?" + NeoJSONObject fromString: (self cacheAt: #json ifAbsent: '{}') ] +] + { #category : #accessing } FamixValueOfType >> attributeInObjects [ "Relation named: #attributeInObjects type: #FamixValueOfObjectAttribute opposite: #value" diff --git a/src/Famix-Value-Entities/FamixValueUnknownType.class.st b/src/Famix-Value-Entities/FamixValueUnknownType.class.st index d30d28d..1310a8e 100644 --- a/src/Famix-Value-Entities/FamixValueUnknownType.class.st +++ b/src/Famix-Value-Entities/FamixValueUnknownType.class.st @@ -24,6 +24,12 @@ FamixValueUnknownType >> acceptValueVisitor: visitor forObject: object [ self error: 'Exporting an unknown type is not (yet?) supported.' ] +{ #category : #converting } +FamixValueUnknownType >> asFASTJavaTypeExpressionOn: visitor [ + + ^ FASTBuilder current referType: self +] + { #category : #testing } FamixValueUnknownType >> isUnknownType [ diff --git a/src/Famix-Value-Exporter/FASTBuilder.class.st b/src/Famix-Value-Exporter/FASTBuilder.class.st new file mode 100644 index 0000000..3f9cd70 --- /dev/null +++ b/src/Famix-Value-Exporter/FASTBuilder.class.st @@ -0,0 +1,35 @@ +Class { + #name : #FASTBuilder, + #superclass : #Object, + #instVars : [ + 'model' + ], + #classVars : [ + 'Current' + ], + #category : #'Famix-Value-Exporter' +} + +{ #category : #accessing } +FASTBuilder class >> current [ + + ^ Current ifNil: [ Current := self new ] +] + +{ #category : #accessing } +FASTBuilder >> beCurrent [ + + Current := self +] + +{ #category : #accessing } +FASTBuilder >> model [ + + ^ model ifNil: [ model := FASTJavaModel new ] +] + +{ #category : #accessing } +FASTBuilder >> model: aFASTModel [ + + model := aFASTModel +] diff --git a/src/Famix-Value-Exporter/FASTJavaBuilder.class.st b/src/Famix-Value-Exporter/FASTJavaBuilder.class.st new file mode 100644 index 0000000..49f95fc --- /dev/null +++ b/src/Famix-Value-Exporter/FASTJavaBuilder.class.st @@ -0,0 +1,97 @@ +Class { + #name : #FASTJavaBuilder, + #superclass : #FASTBuilder, + #instVars : [ + 'imports', + 'typeNameDictionary', + 'registeredTypes' + ], + #category : #'Famix-Value-Exporter' +} + +{ #category : #temp } +FASTJavaBuilder >> fullyQualifiedPackageNameFor: aFamixJavaPackage [ + + ^ aFamixJavaPackage parentPackage + ifNil: [ self model newTypeName name: aFamixJavaPackage name ] + ifNotNil: [ :parentPackage | + self model newQualifiedTypeName + name: aFamixJavaPackage name; + namespace: (self fullyQualifiedPackageNameFor: parentPackage) ] +] + +{ #category : #temp } +FASTJavaBuilder >> fullyQualifiedTypeNameFor: aFamixJavaType [ + + ^ self model newQualifiedTypeName + name: aFamixJavaType baseName; + namespace: + (self fullyQualifiedPackageNameFor: aFamixJavaType typeContainer) +] + +{ #category : #initialization } +FASTJavaBuilder >> initialize [ + + self reset +] + +{ #category : #temp } +FASTJavaBuilder >> makeImportDeclaration: aFamixType [ + + ^ self model newImportDeclaration qualifiedName: + (model newQualifiedName name: aFamixType mooseNameWithDots) +] + +{ #category : #temp } +FASTJavaBuilder >> makeImportDeclarations [ + + ^ typeNameDictionary values collect: [ :type | + self makeImportDeclaration: type ] +] + +{ #category : #temp } +FASTJavaBuilder >> processType: aFamixType [ + + | type | + type := aFamixType isParameterizedType + ifTrue: [ + aFamixType arguments do: [ :argument | + self processType: argument ]. + aFamixType parameterizableClass ] + ifFalse: [ aFamixType ]. + type needsJavaImport ifTrue: [ self registerType: type ] +] + +{ #category : #temp } +FASTJavaBuilder >> referType: aFamixType [ + + | registeredType | + self processType: aFamixType. + registeredType := typeNameDictionary + at: aFamixType name + ifAbsent: nil. + ^ self model newClassTypeExpression typeName: + ((registeredType == aFamixType or: [ + aFamixType needsJavaImport not or: [ + aFamixType isParameterizedType and: [ + registeredType == aFamixType parameterizableClass ] ] ]) + ifTrue: [ "has import" + model newTypeName name: aFamixType baseName ] + ifFalse: [ "no import" + self fullyQualifiedTypeNameFor: aFamixType ]) +] + +{ #category : #temp } +FASTJavaBuilder >> registerType: aFamixType [ + "If the type is in the typeNameDict, it will be imported." + + registeredTypes add: aFamixType. + typeNameDictionary at: aFamixType name ifAbsentPut: aFamixType +] + +{ #category : #initialization } +FASTJavaBuilder >> reset [ + + typeNameDictionary := Dictionary new. + registeredTypes := IdentitySet new +] diff --git a/src/Famix-Value-Exporter/FASTJavaVariableExpression.extension.st b/src/Famix-Value-Exporter/FASTJavaVariableExpression.extension.st index f37fc47..1d4069e 100644 --- a/src/Famix-Value-Exporter/FASTJavaVariableExpression.extension.st +++ b/src/Famix-Value-Exporter/FASTJavaVariableExpression.extension.st @@ -22,8 +22,11 @@ FASTJavaVariableExpression >> accessedAttributesOf: aFamixJavaClass [ ^ (((method := invoc famixInvocation anyCandidate) parameters ifNotEmpty: [ method ] ifEmpty: [ "TODO: investigate why we need to do this" - method invokingMethods anyOneIfOnlyOneElement ]) parameters - at: (invoc arguments indexOf: self)) allAccessedAttributesOf: + | methods | + (methods := method invokingMethods) size = 1 ifFalse: [ + self error: 'Only one method expected' ]. + methods anyOne ]) parameters at: + (invoc arguments indexOf: self)) allAccessedAttributesOf: aFamixJavaClass ]. self error: 'TODO: what else can be using the parameter?'. ^ nil diff --git a/src/Famix-Value-Exporter/FamixJavaAttribute.extension.st b/src/Famix-Value-Exporter/FamixJavaAttribute.extension.st index 223f4c7..7d71795 100644 --- a/src/Famix-Value-Exporter/FamixJavaAttribute.extension.st +++ b/src/Famix-Value-Exporter/FamixJavaAttribute.extension.st @@ -5,22 +5,20 @@ FamixJavaAttribute >> initializerMatchesValues: objectAttributes [ "Assume I have a source and an initializer expression. Return whether the representations of primitive objects, given as argument, match those of my initializer expression, regardless of order. For example, if my representation in Java was: - public static MY_ATTRIBUTE = MyClass(1, 'foo'); + public static MyClass MY_ATTRIBUTE = new MyClass(1, 'foo'); Then I would match: { 1. 'foo' } or { 'foo'. 1 }" - | found source | - found := objectAttributes copy. - source := self sourceText. - source := source + | toFind source | + toFind := objectAttributes copy. + source := (source := self sourceText) copyFrom: (source indexOf: $() + 1 to: (source lastIndexOf: $)) - 1. - source splitJavaArguments do: [ :match | + source splitJavaArguments do: [ :argument | | index | - index := found indexOf: match. - index = 0 + (index := toFind indexOf: argument) = 0 ifTrue: [ ^ false ] - ifFalse: [ found removeAt: index ] ]. - ^ found isEmpty + ifFalse: [ toFind removeAt: index ] ]. + ^ toFind isEmpty ] { #category : #'*Famix-Value-Exporter' } diff --git a/src/Famix-Value-Exporter/FamixJavaType.extension.st b/src/Famix-Value-Exporter/FamixJavaType.extension.st index ac48918..d42ad59 100644 --- a/src/Famix-Value-Exporter/FamixJavaType.extension.st +++ b/src/Famix-Value-Exporter/FamixJavaType.extension.st @@ -9,13 +9,16 @@ FamixJavaType >> acceptValueVisitor: visitor forCollection: collection [ { #category : #'*Famix-Value-Exporter' } FamixJavaType >> acceptValueVisitor: visitor forObject: object [ - ^ visitor visitObjectOfRegularType: object + ^ self isStub + ifTrue: [ visitor visitObjectStub: object ] + ifFalse: [ visitor visitObjectOfRegularType: object ] ] { #category : #'*Famix-Value-Exporter' } FamixJavaType >> asFASTJavaTypeExpressionOn: visitor [ + "^ visitor makeClassTypeExpression: self typeName" - ^ visitor makeClassTypeExpression: self typeName + ^ FASTBuilder current referType: self ] { #category : #'*Famix-Value-Exporter' } @@ -38,6 +41,17 @@ FamixJavaType >> concreteTypeNameOn: stream [ stream nextPutAll: name ] +{ #category : #'*Famix-Value-Exporter' } +FamixJavaType >> decorate: aFamixJavaType asFASTJavaTypeExpressionOn: visitor [ + "This method allows for more control by having access to both the static (argument) and dynamic (self) types of a value. + The default behavior handles when the static type is a parameter type, then it uses the dynamic type. + See Famix-Value-Types for special cases." + + ^ aFamixJavaType isParameterType + ifTrue: [ self asFASTJavaTypeExpressionOn: visitor ] + ifFalse: [ aFamixJavaType asFASTJavaTypeExpressionOn: visitor ] +] + { #category : #'*Famix-Value-Exporter' } FamixJavaType >> typeName [ "Includes type arguments, e.g. List>" diff --git a/src/Famix-Value-Exporter/FamixTClass.extension.st b/src/Famix-Value-Exporter/FamixTClass.extension.st index 512556c..5557060 100644 --- a/src/Famix-Value-Exporter/FamixTClass.extension.st +++ b/src/Famix-Value-Exporter/FamixTClass.extension.st @@ -12,12 +12,14 @@ FamixTClass >> constructorsOrderedByScore [ { #category : #'*Famix-Value-Exporter' } FamixTClass >> findSetterOf: aFamixAttribute [ - ^ self allMethods + ^ self methods detect: [ :method | method isSetterLax and: [ method accesses anySatisfy: [ :access | access variable == aFamixAttribute ] ] ] - ifNone: nil + ifNone: [ + self superclass ifNotNil: [ :superclass | + superclass findSetterOf: aFamixAttribute ] ] ] { #category : #'*Famix-Value-Exporter' } diff --git a/src/Famix-Value-Exporter/FamixTParameterizedType.extension.st b/src/Famix-Value-Exporter/FamixTParameterizedType.extension.st index 20ba281..f930a85 100644 --- a/src/Famix-Value-Exporter/FamixTParameterizedType.extension.st +++ b/src/Famix-Value-Exporter/FamixTParameterizedType.extension.st @@ -6,6 +6,12 @@ FamixTParameterizedType >> constructorScore [ ^ parameterizableClass constructorScore ] +{ #category : #'*Famix-Value-Exporter' } +FamixTParameterizedType >> findSetterOf: aFamixAttribute [ + + ^ parameterizableClass findSetterOf: aFamixAttribute +] + { #category : #'*Famix-Value-Exporter' } FamixTParameterizedType >> publicConstructorsWithMostImpact [ diff --git a/src/Famix-Value-Exporter/FamixValue2ASTVisitor.class.st b/src/Famix-Value-Exporter/FamixValue2ASTVisitor.class.st index 436f197..0fa237f 100644 --- a/src/Famix-Value-Exporter/FamixValue2ASTVisitor.class.st +++ b/src/Famix-Value-Exporter/FamixValue2ASTVisitor.class.st @@ -59,12 +59,9 @@ FamixValue2ASTVisitor >> varNameDict [ { #category : #naming } FamixValue2ASTVisitor >> varNameFor: value [ - ^ self varNameDict at: value ifAbsentPut: [ - (value typedEntity ifNotNil: [ value typedEntity name ] ifNil: [ - value attributeInObjects size = 1 - ifTrue: [ value attributeInObjects first attribute name ] - ifFalse: [ value type baseName uncapitalized ] ]) - , self nextId asString ] + ^ self varNameDict + at: value + ifAbsentPut: [ value varName , self nextId asString ] ] { #category : #visiting } diff --git a/src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st b/src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st index af82bb0..adbed73 100644 --- a/src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st +++ b/src/Famix-Value-Exporter/FamixValue2FASTJavaVisitor.class.st @@ -115,6 +115,91 @@ FamixValue2FASTJavaVisitor >> makeClassTypeExpression: typeName [ (model newTypeName name: typeName) ] +{ #category : #ast } +FamixValue2FASTJavaVisitor >> makeHelper [ + + self model newCompilationUnit + packageDeclaration: (model newPackageDeclaration qualifiedName: + (model newQualifiedName name: 'fr.evref.modest')); + importDeclarations: FASTBuilder current makeImportDeclarations; + addImportDeclaration: (model newImportDeclaration qualifiedName: + (model newQualifiedName name: 'java.io.IOException')); + addImportDeclaration: (model newImportDeclaration qualifiedName: + (model newQualifiedName name: + 'com.fasterxml.jackson.databind.ObjectMapper')); + addClassDeclaration: self makeHelperClass +] + +{ #category : #ast } +FamixValue2FASTJavaVisitor >> makeHelperClass [ + "The helper class has static methods used for creating objects. + It has a private constructor, a Jackson ObjectMapper and a `deserialize` method to handle stubs." + + ^ self model newClassDeclaration + name: 'ModestHelper'; + addModifier: (model newModifier token: 'public'); + declarations: { + (model newMethodEntity + name: 'ModestHelper'; + modifiers: { (model newModifier token: 'private') }; + statementBlock: model newStatementBlock). + (model newVarDeclStatement + type: (model newClassTypeExpression typeName: + (model newTypeName name: 'ObjectMapper')); + modifiers: { + (model newModifier token: 'private'). + (model newModifier token: 'static'). + (model newModifier token: 'final') }; + declarators: { (model newVariableDeclarator + variable: (model newVariableExpression name: 'mapper'); + expression: + (model newNewExpression type: + (model newClassTypeExpression typeName: + (model newTypeName name: 'ObjectMapper')))) }). + (model newMethodEntity + typeParameters: + { (model newTypeParameterExpression name: 'T') }; + type: + (model newClassTypeExpression typeName: + (model newTypeName name: 'T')); + name: 'deserialize'; + parameters: { + (model newParameter + variable: (model newVariableExpression name: 'json'); + type: (model newClassTypeExpression typeName: + (model newTypeName name: 'String'))). + (model newParameter + variable: (model newVariableExpression name: 'clazz'); + type: (model newClassTypeExpression + typeName: (model newTypeName name: 'Class'); + arguments: { (model newClassTypeExpression typeName: + (model newTypeName name: 'T')) })) }; + modifiers: { + (model newModifier token: 'public'). + (model newModifier token: 'static') }; + statementBlock: (model newStatementBlock statements: { + (model newTryCatchStatement + try: (model newStatementBlock statements: + { (model newReturnStatement expression: + (model newMethodInvocation + receiver: (model newIdentifier name: 'mapper'); + name: 'readValue'; + arguments: { + (model newVariableExpression name: 'json'). + (model newVariableExpression name: 'clazz') })) }); + catches: { (model newCatchPartStatement + catchedTypes: + { (model newClassTypeExpression typeName: + (model newTypeName name: 'IOException')) }; + body: (model newStatementBlock statements: + { (model newExpressionStatement expression: + (model newMethodInvocation + receiver: (model newIdentifier name: 'e'); + name: 'printStackTrace')) }); + parameter: (model newVariableExpression name: 'e')) }). + (model newReturnStatement expression: model newNullLiteral) })) } +] + { #category : #ast } FamixValue2FASTJavaVisitor >> makeIdentifier: value [ @@ -125,7 +210,8 @@ FamixValue2FASTJavaVisitor >> makeIdentifier: value [ FamixValue2FASTJavaVisitor >> makeNewExpression: object [ ^ self model newNewExpression type: - (self makeClassTypeExpression: object type concreteTypeName) + (object asFASTJavaTypeExpressionOn: self) + "(self makeClassTypeExpression: object type concreteTypeName)" ] { #category : #ast } @@ -328,6 +414,24 @@ FamixValue2FASTJavaVisitor >> visitObjectOfRegularType: object [ ^ statementBlock ] +{ #category : #visiting } +FamixValue2FASTJavaVisitor >> visitObjectStub: object [ + + self statementBlock addStatement: (self model newVarDeclStatement + type: (object asFASTJavaTypeExpressionOn: self); + addDeclarator: (self model newVariableDeclarator + variable: (self makeVariableExpression: object); + expression: (model newMethodInvocation + name: 'deserialize'; + arguments: { + (model newStringLiteral primitiveValue: + object asJsonString). + (model newClassProperty + type: (object asFASTJavaTypeExpressionOn: self); + fieldName: 'class') })); + yourself) +] + { #category : #visiting } FamixValue2FASTJavaVisitor >> visitPrimitive: primitive [ diff --git a/src/Famix-Value-Exporter/FamixValueOfPrimitiveType.extension.st b/src/Famix-Value-Exporter/FamixValueOfPrimitiveType.extension.st index cffd658..8268e36 100644 --- a/src/Famix-Value-Exporter/FamixValueOfPrimitiveType.extension.st +++ b/src/Famix-Value-Exporter/FamixValueOfPrimitiveType.extension.st @@ -11,9 +11,3 @@ FamixValueOfPrimitiveType >> asFASTJavaExpressionOn: visitor [ ^ value asFASTJavaExpressionOn: visitor of: self type ] - -{ #category : #'*Famix-Value-Exporter' } -FamixValueOfPrimitiveType >> asFASTJavaTypeExpressionOn: visitor [ - - ^ self type asFASTJavaTypeExpressionOn: visitor -] diff --git a/src/Famix-Value-Exporter/FamixValueOfType.extension.st b/src/Famix-Value-Exporter/FamixValueOfType.extension.st index 8eb6f36..0372b3a 100644 --- a/src/Famix-Value-Exporter/FamixValueOfType.extension.st +++ b/src/Famix-Value-Exporter/FamixValueOfType.extension.st @@ -21,7 +21,7 @@ FamixValueOfType >> asFASTJavaExpressionOn: visitor [ { #category : #'*Famix-Value-Exporter' } FamixValueOfType >> asFASTJavaTypeExpressionOn: visitor [ - ^ visitor makeClassTypeExpression: self type typeName + ^ self type asFASTJavaTypeExpressionOn: visitor "It would have been nice to give the type of the typed entity to the value, to use the idea of the regular practice of typing a variable with an interface and affecting a concrete type. However, this brings problems when we want to reconstruct the value, because we need to use setters, and the declared type of the typed entity may not have them, because it can be an abstract class, a superclass, or an interface, and they usually don't define a contract for setters." "(self typedEntity diff --git a/src/Famix-Value-Importer/FamixTClass.extension.st b/src/Famix-Value-Importer/FamixTClass.extension.st index a717535..7e58c23 100644 --- a/src/Famix-Value-Importer/FamixTClass.extension.st +++ b/src/Famix-Value-Importer/FamixTClass.extension.st @@ -1,18 +1,18 @@ Extension { #name : #FamixTClass } { #category : #'*Famix-Value-Importer' } -FamixTClass >> searchAttributeNamed: attributeName [ +FamixTClass >> findAttributeNamed: attributeName [ ^ self attributes detect: [ :attr | attr name = attributeName ] ifNone: [ self inheritedAttributes detect: [ :attribute | attribute name = attributeName ] - ifNone: [ self searchAttributeWithSetterForName: attributeName ] ] + ifNone: [ self findAttributeWithSetterNamed: attributeName ] ] ] { #category : #'*Famix-Value-Importer' } -FamixTClass >> searchAttributeWithSetterForName: attributeName [ +FamixTClass >> findAttributeWithSetterNamed: attributeName [ "Useful when the serialized attribute's name does not exactly match the attribute name. I try to find the setter matching the former, then search for the attribute access." diff --git a/src/Famix-Value-Importer/FamixTParameterizedType.extension.st b/src/Famix-Value-Importer/FamixTParameterizedType.extension.st index 3b5d820..9695c46 100644 --- a/src/Famix-Value-Importer/FamixTParameterizedType.extension.st +++ b/src/Famix-Value-Importer/FamixTParameterizedType.extension.st @@ -1,7 +1,7 @@ Extension { #name : #FamixTParameterizedType } { #category : #'*Famix-Value-Importer' } -FamixTParameterizedType >> searchAttributeNamed: attributeName [ +FamixTParameterizedType >> findAttributeNamed: attributeName [ - ^ parameterizableClass searchAttributeNamed: attributeName + ^ parameterizableClass findAttributeNamed: attributeName ] diff --git a/src/Famix-Value-Importer/FamixValueAbstractImporter.class.st b/src/Famix-Value-Importer/FamixValueAbstractImporter.class.st index eed1265..4233dee 100644 --- a/src/Famix-Value-Importer/FamixValueAbstractImporter.class.st +++ b/src/Famix-Value-Importer/FamixValueAbstractImporter.class.st @@ -112,7 +112,7 @@ FamixValueAbstractImporter >> importObject: rawObject of: type [ (self getObjectIdentity: rawObject) ifNotNil: [ :id | objectDict at: id put: object ]. rawObject associationsDo: [ :assoc | - attribute := type searchAttributeNamed: assoc key. + attribute := type findAttributeNamed: assoc key. self withTypeInference: (attribute ifNotNil: [ attribute declaredType ]) do: [ diff --git a/src/Famix-Value-Importer/FamixValueUnknownType.extension.st b/src/Famix-Value-Importer/FamixValueUnknownType.extension.st index 3cec57f..7b9f562 100644 --- a/src/Famix-Value-Importer/FamixValueUnknownType.extension.st +++ b/src/Famix-Value-Importer/FamixValueUnknownType.extension.st @@ -1,7 +1,7 @@ Extension { #name : #FamixValueUnknownType } { #category : #'*Famix-Value-Importer' } -FamixValueUnknownType >> searchAttributeNamed: attributeName [ +FamixValueUnknownType >> findAttributeNamed: attributeName [ Warning signal: 'Trying to find attribute `' , attributeName , '` in unknown type `' diff --git a/src/Famix-Value-Types/FamixValueJavaArray.class.st b/src/Famix-Value-Types/FamixValueJavaArray.class.st index 257e8d2..b77f53e 100644 --- a/src/Famix-Value-Types/FamixValueJavaArray.class.st +++ b/src/Famix-Value-Types/FamixValueJavaArray.class.st @@ -40,6 +40,17 @@ FamixValueJavaArray >> acceptValueVisitor: visitor forCollection: array [ yourself ] +{ #category : #'as yet unclassified' } +FamixValueJavaArray >> decorate: aFamixJavaType asFASTJavaTypeExpressionOn: visitor [ + "Add array brackets to the type name." + + | expression | + expression := aFamixJavaType asFASTJavaTypeExpressionOn: visitor. + expression typeName name: + expression typeName name , ('[]' repeat: dimensions). + ^ expression +] + { #category : #accessing } FamixValueJavaArray >> dimensions [