Skip to content

Commit 78cd1ca

Browse files
committed
Refactore Attribute node
Instead of having two children object and attribute, I now have a name property for the attribute. I also renamed object to value because this is the name in the python AST
1 parent b8da6b8 commit 78cd1ca

6 files changed

Lines changed: 233 additions & 564 deletions

File tree

‎src/FAST-Python-Model-Generator/FASTPythonMetamodelGenerator.class.st‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
311311
attribute --|> tReturnReferenceable.
312312
attribute --|> tAsPatternTarget.
313313
attribute --|> tSplatParameterTarget.
314+
attribute --|> tNamedEntity.
314315

315316
augmentedAssignment --|> assignment.
316317

@@ -628,13 +629,10 @@ FASTPythonMetamodelGenerator >> defineRelations [
628629
((assertStatement property: #expressions) comment: 'The expressions asserted')
629630
<>-* ((expression property: #parentAssertStatement) comment: 'The assert statement that own the expression (if it''s the case)').
630631

631-
((attribute property: #object) comment:
632+
((attribute property: #value) comment:
632633
'I am the receiver of the attribute. I can be multiple things such as a variable, a call, another attribute access, a primitive type, a subscript...')
633634
<>- ((expression property: #attributeObjectOwner) comment: 'My parent if I define the object of an attribute access (if it''s the case).').
634635

635-
((attribute property: #attribute) comment: 'The variable been accessed')
636-
<>- ((identifier property: #attributeOwner) comment: 'The attribute access accessing me (if it''s the case)').
637-
638636
(await property: #expression) <>- (expression property: #parentAwait).
639637

640638
((call property: #callee) comment:

‎src/FAST-Python-Model/FASTPyAttributeAccess.class.st‎

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8+
| `invokedIn` | `FASTTNamedEntity` | `invoked` | `FASTTInvocation` | Optional invocation where this name is used|
89
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
910
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |
1011
| `parentAssignmentLeft` | `FASTPyTAssignable` | `left` | `FASTPyAssignment` | |
@@ -17,20 +18,26 @@
1718
### Children
1819
| Relation | Origin | Opposite | Type | Comment |
1920
|---|
20-
| `attribute` | `FASTPyAttributeAccess` | `attributeOwner` | `FASTPyIdentifier` | The variable been accessed|
21-
| `object` | `FASTPyAttributeAccess` | `attributeObjectOwner` | `FASTPyExpression` | I am the receiver of the attribute. I can be multiple things such as a variable, a call, another attribute access, a primitive type, a subscript...|
21+
| `value` | `FASTPyAttributeAccess` | `attributeObjectOwner` | `FASTPyExpression` | I am the receiver of the attribute. I can be multiple things such as a variable, a call, another attribute access, a primitive type, a subscript...|
2222
2323
24+
## Properties
25+
======================
26+
27+
| Name | Type | Default value | Comment |
28+
|---|
29+
| `endPos` | `Number` | nil | |
30+
| `name` | `String` | nil | |
31+
| `startPos` | `Number` | nil | |
2432
2533
"
2634
Class {
2735
#name : 'FASTPyAttributeAccess',
2836
#superclass : 'FASTPyExpression',
29-
#traits : 'FASTPyTAsPatternTarget + FASTPyTReturnReferenceable + FASTPyTSplatParameterTarget',
30-
#classTraits : 'FASTPyTAsPatternTarget classTrait + FASTPyTReturnReferenceable classTrait + FASTPyTSplatParameterTarget classTrait',
37+
#traits : 'FASTPyTAsPatternTarget + FASTPyTReturnReferenceable + FASTPyTSplatParameterTarget + FASTTNamedEntity',
38+
#classTraits : 'FASTPyTAsPatternTarget classTrait + FASTPyTReturnReferenceable classTrait + FASTPyTSplatParameterTarget classTrait + FASTTNamedEntity classTrait',
3139
#instVars : [
32-
'#attribute => FMOne type: #FASTPyIdentifier opposite: #attributeOwner',
33-
'#object => FMOne type: #FASTPyExpression opposite: #attributeObjectOwner'
40+
'#value => FMOne type: #FASTPyExpression opposite: #attributeObjectOwner'
3441
],
3542
#category : 'FAST-Python-Model-Entities',
3643
#package : 'FAST-Python-Model',
@@ -47,47 +54,24 @@ FASTPyAttributeAccess class >> annotation [
4754
]
4855

4956
{ #category : 'accessing' }
50-
FASTPyAttributeAccess >> attribute [
51-
"Relation named: #attribute type: #FASTPyIdentifier opposite: #attributeOwner"
52-
53-
<generated>
54-
<FMComment: 'The variable been accessed'>
55-
^ attribute
56-
]
57-
58-
{ #category : 'accessing' }
59-
FASTPyAttributeAccess >> attribute: anObject [
60-
61-
<generated>
62-
attribute := anObject
63-
]
64-
65-
{ #category : 'navigation' }
66-
FASTPyAttributeAccess >> attributeGroup [
67-
<generated>
68-
<navigation: 'Attribute'>
69-
^ MooseSpecializedGroup with: self attribute
70-
]
71-
72-
{ #category : 'accessing' }
73-
FASTPyAttributeAccess >> object [
74-
"Relation named: #object type: #FASTPyExpression opposite: #attributeObjectOwner"
57+
FASTPyAttributeAccess >> value [
58+
"Relation named: #value type: #FASTPyExpression opposite: #attributeObjectOwner"
7559

7660
<generated>
7761
<FMComment: 'I am the receiver of the attribute. I can be multiple things such as a variable, a call, another attribute access, a primitive type, a subscript...'>
78-
^ object
62+
^ value
7963
]
8064

8165
{ #category : 'accessing' }
82-
FASTPyAttributeAccess >> object: anObject [
66+
FASTPyAttributeAccess >> value: anObject [
8367

8468
<generated>
85-
object := anObject
69+
value := anObject
8670
]
8771

8872
{ #category : 'navigation' }
89-
FASTPyAttributeAccess >> objectGroup [
73+
FASTPyAttributeAccess >> valueGroup [
9074
<generated>
91-
<navigation: 'Object'>
92-
^ MooseSpecializedGroup with: self object
75+
<navigation: 'Value'>
76+
^ MooseSpecializedGroup with: self value
9377
]

‎src/FAST-Python-Model/FASTPyExpression.class.st‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
99
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
10-
| `attributeObjectOwner` | `FASTPyExpression` | `object` | `FASTPyAttributeAccess` | My parent if I define the object of an attribute access (if it's the case).|
10+
| `attributeObjectOwner` | `FASTPyExpression` | `value` | `FASTPyAttributeAccess` | My parent if I define the object of an attribute access (if it's the case).|
1111
| `caller` | `FASTPyExpression` | `callee` | `FASTPyCall` | The call entity calling me (if it's the case)|
1212
| `collectionInitializer` | `FASTPyExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1313
| `comprehensionBodyOwner` | `FASTPyExpression` | `body` | `FASTPyTComprehension` | |
@@ -62,7 +62,7 @@ Class {
6262
#traits : 'FASTPyTTypeContent + FASTTExpression',
6363
#classTraits : 'FASTPyTTypeContent classTrait + FASTTExpression classTrait',
6464
#instVars : [
65-
'#attributeObjectOwner => FMOne type: #FASTPyAttributeAccess opposite: #object',
65+
'#attributeObjectOwner => FMOne type: #FASTPyAttributeAccess opposite: #value',
6666
'#caller => FMOne type: #FASTPyCall opposite: #callee',
6767
'#collectionInitializer => FMOne type: #FASTPyCollectionInitializer opposite: #initializers',
6868
'#comprehensionBodyOwner => FMOne type: #FASTPyTComprehension opposite: #body',
@@ -110,7 +110,7 @@ FASTPyExpression class >> annotation [
110110

111111
{ #category : 'accessing' }
112112
FASTPyExpression >> attributeObjectOwner [
113-
"Relation named: #attributeObjectOwner type: #FASTPyAttributeAccess opposite: #object"
113+
"Relation named: #attributeObjectOwner type: #FASTPyAttributeAccess opposite: #value"
114114

115115
<generated>
116116
<FMComment: 'My parent if I define the object of an attribute access (if it''s the case).'>

‎src/FAST-Python-Model/FASTPyIdentifier.class.st‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
### Parents
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
8-
| `attributeOwner` | `FASTPyIdentifier` | `attribute` | `FASTPyAttributeAccess` | The attribute access accessing me (if it's the case)|
98
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
109
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |
1110
| `parentAssignmentLeft` | `FASTPyTAssignable` | `left` | `FASTPyAssignment` | |
@@ -23,9 +22,6 @@ Class {
2322
#superclass : 'FASTPyExpression',
2423
#traits : 'FASTPyTAsPatternTarget + FASTPyTReturnReferenceable + FASTPyTSplatParameterTarget',
2524
#classTraits : 'FASTPyTAsPatternTarget classTrait + FASTPyTReturnReferenceable classTrait + FASTPyTSplatParameterTarget classTrait',
26-
#instVars : [
27-
'#attributeOwner => FMOne type: #FASTPyAttributeAccess opposite: #attribute'
28-
],
2925
#category : 'FAST-Python-Model-Entities',
3026
#package : 'FAST-Python-Model',
3127
#tag : 'Entities'
@@ -39,28 +35,3 @@ FASTPyIdentifier class >> annotation [
3935
<generated>
4036
^ self
4137
]
42-
43-
{ #category : 'accessing' }
44-
FASTPyIdentifier >> attributeOwner [
45-
"Relation named: #attributeOwner type: #FASTPyAttributeAccess opposite: #attribute"
46-
47-
<generated>
48-
<FMComment: 'The attribute access accessing me (if it''s the case)'>
49-
<container>
50-
<derived>
51-
^ attributeOwner
52-
]
53-
54-
{ #category : 'accessing' }
55-
FASTPyIdentifier >> attributeOwner: anObject [
56-
57-
<generated>
58-
attributeOwner := anObject
59-
]
60-
61-
{ #category : 'navigation' }
62-
FASTPyIdentifier >> attributeOwnerGroup [
63-
<generated>
64-
<navigation: 'AttributeOwner'>
65-
^ MooseSpecializedGroup with: self attributeOwner
66-
]

0 commit comments

Comments
 (0)