Skip to content

Commit

Permalink
Merge 99bc4b8
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed Nov 15, 2024
2 parents f03418d + 99bc4b8 commit c3b748a
Show file tree
Hide file tree
Showing 38 changed files with 549 additions and 158 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
Extension { #name : 'FamixValueOfObject' }

{ #category : '*Famix-Value-Entities-Extensions' }
FamixValueOfObject >> constructorSignature [

^ String streamContents: [ :s |
s << self type name << '('.
value
do: [ :attribute | s << attribute attribute declaredType name ]
separatedBy: [ s nextPut: $, ].
s nextPut: $) ]
]

{ #category : '*Famix-Value-Entities-Extensions' }
FamixValueOfObject >> containsCollection [

Expand Down
24 changes: 12 additions & 12 deletions src/Famix-Value-Entities/FamixTType.extension.st
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
Extension { #name : 'FamixTType' }

{ #category : '*Famix-Value-Entities-accessing' }
FamixTType >> valueReferences [
"Relation named: #valueReferences type: #FamixValueOfTypeReference opposite: #value"
FamixTType >> valueInstances [
"Relation named: #valueInstances type: #FamixValueOfType opposite: #type"

<generated>
<derived>
<FMProperty: #valueReferences type: #FamixValueOfTypeReference opposite: #value>
<FMProperty: #valueInstances type: #FamixValueOfType opposite: #type>
<package: #'Famix-Value-Entities'>
^ self attributeAt: #valueReferences ifAbsentPut: [ FMMultivalueLink on: self opposite: #value: ]
^ self attributeAt: #valueInstances ifAbsentPut: [ FMMultivalueLink on: self opposite: #type: ]
]

{ #category : '*Famix-Value-Entities-accessing' }
FamixTType >> valueReferences: anObject [
FamixTType >> valueInstances: anObject [

<generated>
self valueReferences value: anObject
self valueInstances value: anObject
]

{ #category : '*Famix-Value-Entities-accessing' }
FamixTType >> values [
"Relation named: #values type: #FamixValueOfType opposite: #type"
FamixTType >> valueReferences [
"Relation named: #valueReferences type: #FamixValueOfTypeReference opposite: #value"

<generated>
<derived>
<FMProperty: #values type: #FamixValueOfType opposite: #type>
<FMProperty: #valueReferences type: #FamixValueOfTypeReference opposite: #value>
<package: #'Famix-Value-Entities'>
^ self attributeAt: #values ifAbsentPut: [ FMMultivalueLink on: self opposite: #type: ]
^ self attributeAt: #valueReferences ifAbsentPut: [ FMMultivalueLink on: self opposite: #value: ]
]

{ #category : '*Famix-Value-Entities-accessing' }
FamixTType >> values: anObject [
FamixTType >> valueReferences: anObject [

<generated>
self values value: anObject
self valueReferences value: anObject
]
8 changes: 4 additions & 4 deletions src/Famix-Value-Entities/FamixValueOfType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Abstract superclass of all ValueOf_Type_ entities.
| `attributeInObjects` | `FamixValueOfType` | `value` | `FamixValueOfObjectAttribute` | |
| `elementInCollections` | `FamixValueOfType` | `value` | `FamixValueOfCollectionElement` | |
| `keyInDictionaries` | `FamixValueOfType` | `key` | `FamixValueOfDictionaryAssociation` | |
| `type` | `FamixValueOfType` | `values` | `FamixTType` | |
| `type` | `FamixValueOfType` | `valueInstances` | `FamixTType` | |
| `typedEntity` | `FamixValueOfType` | `values` | `FamixTTypedEntity` | |
| `valueInDictionaries` | `FamixValueOfType` | `value` | `FamixValueOfDictionaryAssociation` | |
| `variableInClosures` | `FamixValueOfType` | `value` | `FamixValueOfClosureVariable` | |
Expand Down Expand Up @@ -137,18 +137,18 @@ FamixValueOfType >> keyInDictionaries: anObject [

{ #category : 'accessing' }
FamixValueOfType >> type [
"Relation named: #type type: #FamixTType opposite: #values"
"Relation named: #type type: #FamixTType opposite: #valueInstances"

<generated>
<FMProperty: #type type: #FamixTType opposite: #values>
<FMProperty: #type type: #FamixTType opposite: #valueInstances>
^ self attributeAt: #type ifAbsent: [ nil ]
]

{ #category : 'accessing' }
FamixValueOfType >> type: anObject [

<generated>
self attributeAt: #type put: (FMMultivalueLink on: self update: #values from: self type to: anObject).
self attributeAt: #type put: (FMMultivalueLink on: self update: #valueInstances from: self type to: anObject).
]

{ #category : 'accessing' }
Expand Down
2 changes: 1 addition & 1 deletion src/Famix-Value-Entities/FamixValueUnknownType.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ An unknown type.
|---|
| `sourceAnchor` | `FamixTSourceEntity` | `element` | `FamixTSourceAnchor` | SourceAnchor entity linking to the original source code for this entity|
| `typedEntities` | `FamixTType` | `declaredType` | `FamixTTypedEntity` | Entities that have this type as declaredType|
| `valueInstances` | `FamixTType` | `type` | `FamixValueOfType` | |
| `valueReferences` | `FamixTType` | `value` | `FamixValueOfTypeReference` | |
| `values` | `FamixTType` | `type` | `FamixValueOfType` | |
## Properties
Expand Down
6 changes: 4 additions & 2 deletions src/Famix-Value-Exporter/FASTJavaBuilder.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ FASTJavaBuilder >> fullyQualifiedPackageNameFor: aFamixJavaPackage [

{ #category : 'ast' }
FASTJavaBuilder >> fullyQualifiedTypeNameFor: aFamixJavaType [
"A type can be in another type or a package"

^ self model newQualifiedTypeName
name: aFamixJavaType baseName;
namespace:
(self fullyQualifiedPackageNameFor: aFamixJavaType typeContainer)
(aFamixJavaType typeContainer fullyQualifiedTypeNameOn:
self model)
]

{ #category : 'initialization' }
Expand All @@ -42,7 +44,7 @@ FASTJavaBuilder >> initialize [
FASTJavaBuilder >> makeImportDeclaration: aFamixType [

^ self model newImportDeclaration qualifiedName:
(model newQualifiedName name: aFamixType mooseNameWithDots)
(aFamixType fullyQualifiedNameOn: self model)
]

{ #category : 'ast' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,14 @@ FASTJavaVariableExpression >> accessedAttributesOf: aFamixJavaClass [
ifFalse: [
(method parameters at: (invoc arguments indexOf: self))
allAccessedAttributesOf: aFamixJavaClass ] ].
receiverOwner ifNotNil: [ :receiver | "receiver of a method, reiterate on the variable 'this'"
| method |
^ (method := receiver famixInvocation anyCandidate) isStub
ifTrue: [ "ignore stubs" { } ]
ifFalse: [
method implicitVariables
detect: [ :var | var isSelf ]
ifFound: [ :var | var allAccessedAttributesOf: aFamixJavaClass ]
ifNone: [ { } ] ] ].
self error: 'TODO: what else can be using the parameter?'
]
15 changes: 15 additions & 0 deletions src/Famix-Value-Exporter/FamixJavaInterface.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Extension { #name : 'FamixJavaInterface' }

{ #category : '*Famix-Value-Exporter' }
FamixJavaInterface >> withSubHierarchy [
"Includes subinterfaces and their implementing classes"

| result |
result := Set new.
self withSubclassHierarchy do: [ :interface |
result add: interface.
interface implementations do: [ :implementation |
implementation implementingClass withSubclassesDo: [ :class |
result add: class ] ] ].
^ result asOrderedCollection
]
24 changes: 24 additions & 0 deletions src/Famix-Value-Exporter/FamixJavaPackage.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Extension { #name : 'FamixJavaPackage' }

{ #category : '*Famix-Value-Exporter' }
FamixJavaPackage >> fullyQualifiedNameOn: aFASTJavaModel [

^ parentPackage
ifNil: [ aFASTJavaModel newQualifiedName name: name ]
ifNotNil: [
aFASTJavaModel newQualifiedName
name: name;
namespace: (parentPackage fullyQualifiedNameOn: aFASTJavaModel) ]
]

{ #category : '*Famix-Value-Exporter' }
FamixJavaPackage >> fullyQualifiedTypeNameOn: aFASTJavaModel [

^ parentPackage
ifNil: [ aFASTJavaModel newQualifiedTypeName name: name ]
ifNotNil: [
aFASTJavaModel newQualifiedTypeName
name: name;
namespace:
(parentPackage fullyQualifiedTypeNameOn: aFASTJavaModel) ]
]
23 changes: 23 additions & 0 deletions src/Famix-Value-Exporter/FamixJavaType.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ FamixJavaType >> decorate: aFamixJavaType asFASTJavaTypeExpressionOn: visitor [
ifFalse: [ aFamixJavaType asFASTJavaTypeExpressionOn: visitor ]
]

{ #category : '*Famix-Value-Exporter' }
FamixJavaType >> fullyQualifiedNameOn: aFASTJavaModel [

^ typeContainer
ifNil: [ aFASTJavaModel newQualifiedName name: name ]
ifNotNil: [
aFASTJavaModel newQualifiedName
name: name;
namespace: (typeContainer fullyQualifiedNameOn: aFASTJavaModel) ]
]

{ #category : '*Famix-Value-Exporter' }
FamixJavaType >> fullyQualifiedTypeNameOn: aFASTJavaModel [

^ typeContainer
ifNil: [ aFASTJavaModel newQualifiedTypeName name: name ]
ifNotNil: [
aFASTJavaModel newQualifiedTypeName
name: name;
namespace:
(typeContainer fullyQualifiedTypeNameOn: aFASTJavaModel) ]
]

{ #category : '*Famix-Value-Exporter' }
FamixJavaType >> needsJavaImport [

Expand Down
7 changes: 7 additions & 0 deletions src/Famix-Value-Exporter/FamixJavaWildcard.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : 'FamixJavaWildcard' }

{ #category : '*Famix-Value-Exporter' }
FamixJavaWildcard >> needsJavaImport [

^ false
]
17 changes: 14 additions & 3 deletions src/Famix-Value-Exporter/FamixTMethod.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,19 @@ FamixTMethod >> mapConstructorParametersToAttributes [
(parameter fastAccesses flatCollectAsSet: [ :access |
access accessedAttributesOf: parentType ])
ifNotEmpty: [ :attributes |
attributes size = 1
ifTrue: [ attributes anyOne ]
ifFalse: [ self error: 'Expected only one attribute.' ] ]
| attribute |
attributes size = 1 ifFalse: [
FamixValueExporterError signal: 'Expected only one attribute.' ].
(attribute := attributes anyOne) declaredType
ifNil: [ "TODO should not happen, fix Java parser" nil ]
ifNotNil: [ :attributeType |
(attributeType withSubHierarchy includes:
parameter declaredType)
ifTrue: [ attribute ]
ifFalse: [ "parameter is used to set the attribute, but not directly because they are of different types
a common occurence is an array-to-collection transformation:
setValues(String... values) { this.values = Arrays.asList(values); }
however reality is often more complex, so for now we ignore this parameter-to-attribute mapping (10/24)"
nil ] ] ]
ifEmpty: [ "parameter is not mapped to an attribute" nil ] ]
]
8 changes: 8 additions & 0 deletions src/Famix-Value-Exporter/FamixTWithInheritances.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Extension { #name : 'FamixTWithInheritances' }

{ #category : '*Famix-Value-Exporter' }
FamixTWithInheritances >> withSubHierarchy [
"Returns the complete sub-hierarchy, see implementors for special cases"

^ self withSubclassHierarchy
]
Loading

0 comments on commit c3b748a

Please sign in to comment.