Skip to content

Commit 8542fa6

Browse files
committed
Manage assert statement
1 parent ab907e5 commit 8542fa6

14 files changed

+186
-5
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ FASTPythonMetamodelGenerator >> defineClasses [
175175
argumentList := builder ensureClassNamed: #ArgumentList."Todo"
176176
asPattern := builder ensureClassNamed: #AsPattern."Todo"
177177
asPatternTarget := builder ensureClassNamed: #AsPatternTarget."Todo"
178-
assertStatement := builder ensureClassNamed: #AssertStatement."Todo"
178+
assertStatement := builder ensureClassNamed: #AssertStatement.
179179
assignment := builder ensureClassNamed: #Assignment."To review"
180180
attribute := builder ensureClassNamed: #Attribute."To review"
181181
augmentedAssignment := builder ensureClassNamed: #AugmentedAssignment."Todo"
@@ -312,6 +312,8 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
312312

313313
assignment --|> tAssignment.
314314

315+
assertStatement --|> tStatement.
316+
315317
attribute --|> structuralEntity.
316318

317319
binaryOperator --|> operator.
@@ -433,6 +435,9 @@ FASTPythonMetamodelGenerator >> defineRelations [
433435
((collectionInitializer property: #initializers) comment: 'Each initializer defines one element.')
434436
<>-* ((tExpression property: #collectionInitializer) comment: 'The owner of the expression').
435437

438+
((assertStatement property: #expression) comment: 'The expression asserted')
439+
<>- ((tExpression property: #assertOwner) comment: 'The assert statement that own the expression (if it''s the case)').
440+
436441
((tUnaryOperator property: #argument) comment: 'Expression influanced by the unary operator..')
437442
<>- ((tExpression property: #parentUnaryOperator) comment: 'Parent unary operator in which I am.')
438443
]

src/FAST-Python-Model/FASTPyAssertStatement.class.st

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
1+
"
2+
## Relations
3+
======================
4+
5+
### Parents
6+
| Relation | Origin | Opposite | Type | Comment |
7+
|---|
8+
| `parentLoopStatement` | `FASTTStatement` | `body` | `FASTTLoopStatement` | Optional loop of which this statement is the body|
9+
| `statementContainer` | `FASTTStatement` | `statements` | `FASTTStatementBlock` | Block containing this statement.|
10+
11+
### Children
12+
| Relation | Origin | Opposite | Type | Comment |
13+
|---|
14+
| `expression` | `FASTPyAssertStatement` | `assertOwner` | `FASTTExpression` | The expression asserted|
15+
16+
17+
## Properties
18+
======================
19+
20+
| Name | Type | Default value | Comment |
21+
|---|
22+
| `endPos` | `Number` | nil | |
23+
| `startPos` | `Number` | nil | |
24+
25+
"
126
Class {
227
#name : 'FASTPyAssertStatement',
328
#superclass : 'FASTPyEntity',
29+
#traits : 'FASTTStatement',
30+
#classTraits : 'FASTTStatement classTrait',
431
#category : 'FAST-Python-Model-Entities',
532
#package : 'FAST-Python-Model',
633
#tag : 'Entities'
@@ -14,3 +41,34 @@ FASTPyAssertStatement class >> annotation [
1441
<generated>
1542
^ self
1643
]
44+
45+
{ #category : 'accessing' }
46+
FASTPyAssertStatement >> expression [
47+
"Relation named: #expression type: #FASTTExpression opposite: #assertOwner"
48+
49+
<generated>
50+
<FMComment: 'The expression asserted'>
51+
<FMProperty: #expression type: #FASTTExpression opposite: #assertOwner>
52+
^ self attributeAt: #expression ifAbsent: [ nil ]
53+
]
54+
55+
{ #category : 'accessing' }
56+
FASTPyAssertStatement >> expression: anObject [
57+
58+
<generated>
59+
(self attributeAt: #expression ifAbsentPut: [nil]) == anObject ifTrue: [ ^ anObject ].
60+
anObject ifNil: [ | otherSide |
61+
otherSide := self expression.
62+
self attributeAt: #expression put: anObject.
63+
otherSide assertOwner: nil ]
64+
ifNotNil: [
65+
self attributeAt: #expression put: anObject.
66+
anObject assertOwner: self ]
67+
]
68+
69+
{ #category : 'navigation' }
70+
FASTPyAssertStatement >> expressionGroup [
71+
<generated>
72+
<navigation: 'Expression'>
73+
^ MooseSpecializedGroup with: self expression
74+
]

src/FAST-Python-Model/FASTPyAssignment.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

src/FAST-Python-Model/FASTPyBinaryOperator.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

src/FAST-Python-Model/FASTPyBoolean.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

src/FAST-Python-Model/FASTPyBooleanOperator.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

src/FAST-Python-Model/FASTPyCall.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

src/FAST-Python-Model/FASTPyEntity.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

src/FAST-Python-Model/FASTPyLiteral.class.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
| Relation | Origin | Opposite | Type | Comment |
77
|---|
88
| `argumentOwner` | `FASTTExpression` | `arguments` | `FASTTWithArguments` | my owner|
9+
| `assertOwner` | `FASTTExpression` | `expression` | `FASTPyAssertStatement` | The assert statement that own the expression (if it's the case)|
910
| `assignedIn` | `FASTTExpression` | `expression` | `FASTTAssignment` | Optional assignment where this expression is used|
1011
| `collectionInitializer` | `FASTTExpression` | `initializers` | `FASTPyCollectionInitializer` | The owner of the expression|
1112
| `expressionStatementOwner` | `FASTTExpression` | `expression` | `FASTTExpressionStatement` | The expression statement that own me (if it's the case|

0 commit comments

Comments
 (0)