Skip to content

Commit c3b748a

Browse files
Merge 99bc4b8
2 parents f03418d + 99bc4b8 commit c3b748a

38 files changed

+549
-158
lines changed

src/Famix-Value-Entities-Extensions/FamixValueOfObject.extension.st

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
Extension { #name : 'FamixValueOfObject' }
22

3-
{ #category : '*Famix-Value-Entities-Extensions' }
4-
FamixValueOfObject >> constructorSignature [
5-
6-
^ String streamContents: [ :s |
7-
s << self type name << '('.
8-
value
9-
do: [ :attribute | s << attribute attribute declaredType name ]
10-
separatedBy: [ s nextPut: $, ].
11-
s nextPut: $) ]
12-
]
13-
143
{ #category : '*Famix-Value-Entities-Extensions' }
154
FamixValueOfObject >> containsCollection [
165

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
Extension { #name : 'FamixTType' }
22

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

77
<generated>
88
<derived>
9-
<FMProperty: #valueReferences type: #FamixValueOfTypeReference opposite: #value>
9+
<FMProperty: #valueInstances type: #FamixValueOfType opposite: #type>
1010
<package: #'Famix-Value-Entities'>
11-
^ self attributeAt: #valueReferences ifAbsentPut: [ FMMultivalueLink on: self opposite: #value: ]
11+
^ self attributeAt: #valueInstances ifAbsentPut: [ FMMultivalueLink on: self opposite: #type: ]
1212
]
1313

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

1717
<generated>
18-
self valueReferences value: anObject
18+
self valueInstances value: anObject
1919
]
2020

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

2525
<generated>
2626
<derived>
27-
<FMProperty: #values type: #FamixValueOfType opposite: #type>
27+
<FMProperty: #valueReferences type: #FamixValueOfTypeReference opposite: #value>
2828
<package: #'Famix-Value-Entities'>
29-
^ self attributeAt: #values ifAbsentPut: [ FMMultivalueLink on: self opposite: #type: ]
29+
^ self attributeAt: #valueReferences ifAbsentPut: [ FMMultivalueLink on: self opposite: #value: ]
3030
]
3131

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

3535
<generated>
36-
self values value: anObject
36+
self valueReferences value: anObject
3737
]

src/Famix-Value-Entities/FamixValueOfType.class.st

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Abstract superclass of all ValueOf_Type_ entities.
1010
| `attributeInObjects` | `FamixValueOfType` | `value` | `FamixValueOfObjectAttribute` | |
1111
| `elementInCollections` | `FamixValueOfType` | `value` | `FamixValueOfCollectionElement` | |
1212
| `keyInDictionaries` | `FamixValueOfType` | `key` | `FamixValueOfDictionaryAssociation` | |
13-
| `type` | `FamixValueOfType` | `values` | `FamixTType` | |
13+
| `type` | `FamixValueOfType` | `valueInstances` | `FamixTType` | |
1414
| `typedEntity` | `FamixValueOfType` | `values` | `FamixTTypedEntity` | |
1515
| `valueInDictionaries` | `FamixValueOfType` | `value` | `FamixValueOfDictionaryAssociation` | |
1616
| `variableInClosures` | `FamixValueOfType` | `value` | `FamixValueOfClosureVariable` | |
@@ -137,18 +137,18 @@ FamixValueOfType >> keyInDictionaries: anObject [
137137

138138
{ #category : 'accessing' }
139139
FamixValueOfType >> type [
140-
"Relation named: #type type: #FamixTType opposite: #values"
140+
"Relation named: #type type: #FamixTType opposite: #valueInstances"
141141

142142
<generated>
143-
<FMProperty: #type type: #FamixTType opposite: #values>
143+
<FMProperty: #type type: #FamixTType opposite: #valueInstances>
144144
^ self attributeAt: #type ifAbsent: [ nil ]
145145
]
146146

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

150150
<generated>
151-
self attributeAt: #type put: (FMMultivalueLink on: self update: #values from: self type to: anObject).
151+
self attributeAt: #type put: (FMMultivalueLink on: self update: #valueInstances from: self type to: anObject).
152152
]
153153

154154
{ #category : 'accessing' }

src/Famix-Value-Entities/FamixValueUnknownType.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ An unknown type.
1919
|---|
2020
| `sourceAnchor` | `FamixTSourceEntity` | `element` | `FamixTSourceAnchor` | SourceAnchor entity linking to the original source code for this entity|
2121
| `typedEntities` | `FamixTType` | `declaredType` | `FamixTTypedEntity` | Entities that have this type as declaredType|
22+
| `valueInstances` | `FamixTType` | `type` | `FamixValueOfType` | |
2223
| `valueReferences` | `FamixTType` | `value` | `FamixValueOfTypeReference` | |
23-
| `values` | `FamixTType` | `type` | `FamixValueOfType` | |
2424
2525
2626
## Properties

src/Famix-Value-Exporter/FASTJavaBuilder.class.st

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ FASTJavaBuilder >> fullyQualifiedPackageNameFor: aFamixJavaPackage [
2525

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

2930
^ self model newQualifiedTypeName
3031
name: aFamixJavaType baseName;
3132
namespace:
32-
(self fullyQualifiedPackageNameFor: aFamixJavaType typeContainer)
33+
(aFamixJavaType typeContainer fullyQualifiedTypeNameOn:
34+
self model)
3335
]
3436

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

4446
^ self model newImportDeclaration qualifiedName:
45-
(model newQualifiedName name: aFamixType mooseNameWithDots)
47+
(aFamixType fullyQualifiedNameOn: self model)
4648
]
4749

4850
{ #category : 'ast' }

src/Famix-Value-Exporter/FASTJavaVariableExpression.extension.st

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,14 @@ FASTJavaVariableExpression >> accessedAttributesOf: aFamixJavaClass [
2424
ifFalse: [
2525
(method parameters at: (invoc arguments indexOf: self))
2626
allAccessedAttributesOf: aFamixJavaClass ] ].
27+
receiverOwner ifNotNil: [ :receiver | "receiver of a method, reiterate on the variable 'this'"
28+
| method |
29+
^ (method := receiver famixInvocation anyCandidate) isStub
30+
ifTrue: [ "ignore stubs" { } ]
31+
ifFalse: [
32+
method implicitVariables
33+
detect: [ :var | var isSelf ]
34+
ifFound: [ :var | var allAccessedAttributesOf: aFamixJavaClass ]
35+
ifNone: [ { } ] ] ].
2736
self error: 'TODO: what else can be using the parameter?'
2837
]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Extension { #name : 'FamixJavaInterface' }
2+
3+
{ #category : '*Famix-Value-Exporter' }
4+
FamixJavaInterface >> withSubHierarchy [
5+
"Includes subinterfaces and their implementing classes"
6+
7+
| result |
8+
result := Set new.
9+
self withSubclassHierarchy do: [ :interface |
10+
result add: interface.
11+
interface implementations do: [ :implementation |
12+
implementation implementingClass withSubclassesDo: [ :class |
13+
result add: class ] ] ].
14+
^ result asOrderedCollection
15+
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Extension { #name : 'FamixJavaPackage' }
2+
3+
{ #category : '*Famix-Value-Exporter' }
4+
FamixJavaPackage >> fullyQualifiedNameOn: aFASTJavaModel [
5+
6+
^ parentPackage
7+
ifNil: [ aFASTJavaModel newQualifiedName name: name ]
8+
ifNotNil: [
9+
aFASTJavaModel newQualifiedName
10+
name: name;
11+
namespace: (parentPackage fullyQualifiedNameOn: aFASTJavaModel) ]
12+
]
13+
14+
{ #category : '*Famix-Value-Exporter' }
15+
FamixJavaPackage >> fullyQualifiedTypeNameOn: aFASTJavaModel [
16+
17+
^ parentPackage
18+
ifNil: [ aFASTJavaModel newQualifiedTypeName name: name ]
19+
ifNotNil: [
20+
aFASTJavaModel newQualifiedTypeName
21+
name: name;
22+
namespace:
23+
(parentPackage fullyQualifiedTypeNameOn: aFASTJavaModel) ]
24+
]

src/Famix-Value-Exporter/FamixJavaType.extension.st

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,29 @@ FamixJavaType >> decorate: aFamixJavaType asFASTJavaTypeExpressionOn: visitor [
4444
ifFalse: [ aFamixJavaType asFASTJavaTypeExpressionOn: visitor ]
4545
]
4646

47+
{ #category : '*Famix-Value-Exporter' }
48+
FamixJavaType >> fullyQualifiedNameOn: aFASTJavaModel [
49+
50+
^ typeContainer
51+
ifNil: [ aFASTJavaModel newQualifiedName name: name ]
52+
ifNotNil: [
53+
aFASTJavaModel newQualifiedName
54+
name: name;
55+
namespace: (typeContainer fullyQualifiedNameOn: aFASTJavaModel) ]
56+
]
57+
58+
{ #category : '*Famix-Value-Exporter' }
59+
FamixJavaType >> fullyQualifiedTypeNameOn: aFASTJavaModel [
60+
61+
^ typeContainer
62+
ifNil: [ aFASTJavaModel newQualifiedTypeName name: name ]
63+
ifNotNil: [
64+
aFASTJavaModel newQualifiedTypeName
65+
name: name;
66+
namespace:
67+
(typeContainer fullyQualifiedTypeNameOn: aFASTJavaModel) ]
68+
]
69+
4770
{ #category : '*Famix-Value-Exporter' }
4871
FamixJavaType >> needsJavaImport [
4972

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Extension { #name : 'FamixJavaWildcard' }
2+
3+
{ #category : '*Famix-Value-Exporter' }
4+
FamixJavaWildcard >> needsJavaImport [
5+
6+
^ false
7+
]

src/Famix-Value-Exporter/FamixTMethod.extension.st

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,19 @@ FamixTMethod >> mapConstructorParametersToAttributes [
5555
(parameter fastAccesses flatCollectAsSet: [ :access |
5656
access accessedAttributesOf: parentType ])
5757
ifNotEmpty: [ :attributes |
58-
attributes size = 1
59-
ifTrue: [ attributes anyOne ]
60-
ifFalse: [ self error: 'Expected only one attribute.' ] ]
58+
| attribute |
59+
attributes size = 1 ifFalse: [
60+
FamixValueExporterError signal: 'Expected only one attribute.' ].
61+
(attribute := attributes anyOne) declaredType
62+
ifNil: [ "TODO should not happen, fix Java parser" nil ]
63+
ifNotNil: [ :attributeType |
64+
(attributeType withSubHierarchy includes:
65+
parameter declaredType)
66+
ifTrue: [ attribute ]
67+
ifFalse: [ "parameter is used to set the attribute, but not directly because they are of different types
68+
a common occurence is an array-to-collection transformation:
69+
setValues(String... values) { this.values = Arrays.asList(values); }
70+
however reality is often more complex, so for now we ignore this parameter-to-attribute mapping (10/24)"
71+
nil ] ] ]
6172
ifEmpty: [ "parameter is not mapped to an attribute" nil ] ]
6273
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Extension { #name : 'FamixTWithInheritances' }
2+
3+
{ #category : '*Famix-Value-Exporter' }
4+
FamixTWithInheritances >> withSubHierarchy [
5+
"Returns the complete sub-hierarchy, see implementors for special cases"
6+
7+
^ self withSubclassHierarchy
8+
]

0 commit comments

Comments
 (0)