Skip to content

Commit 9a52bee

Browse files
committed
Manage raise statement
1 parent b7f9424 commit 9a52bee

11 files changed

Lines changed: 358 additions & 14 deletions

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ Class {
156156
'tCanBeSplatExpression',
157157
'tAsPatternTarget',
158158
'tAsPatternSource',
159-
'tWithStatementItem'
159+
'tWithStatementItem',
160+
'tRaised'
160161
],
161162
#category : 'FAST-Python-Model-Generator',
162163
#package : 'FAST-Python-Model-Generator'
@@ -330,6 +331,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
330331
attribute --|> tCanBeSplatExpression.
331332
attribute --|> tAsPatternTarget.
332333
attribute --|> tAsPatternSource.
334+
attribute --|> tRaised.
333335

334336
augmentedAssignment --|> statement.
335337

@@ -344,6 +346,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
344346
booleanOperator --|> operator.
345347
booleanOperator --|> tBinaryExpression. "I am not 100% sure this is the best trait to use but it seems to work well for now"
346348
booleanOperator --|> tCanBeSplatExpression.
349+
booleanOperator --|> tRaised.
347350

348351
boolean --|> literal.
349352
boolean --|> tBooleanLiteral.
@@ -356,6 +359,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
356359
call --|> tCanBeSplatExpression.
357360
call --|> tAsPatternSource.
358361
call --|> tWithStatementItem.
362+
call --|> tRaised.
359363

360364
classDefinition --|> statement.
361365
classDefinition --|> tDefinition.
@@ -424,6 +428,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
424428
identifier --|> tCanBeSplatExpression.
425429
identifier --|> tAsPatternTarget.
426430
identifier --|> tAsPatternSource.
431+
identifier --|> tRaised.
427432

428433
ifClause --|> expression. "This is wrong! I am just here temporarily until we rework the relation to the for in clause (I need to be able to be a clause of a list comprehension)"
429434

@@ -482,6 +487,8 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
482487
passStatement --|> statement.
483488

484489
printStatement --|> statement.
490+
491+
raiseStatement --|> statement.
485492

486493
returnStatement --|> statement.
487494
returnStatement --|> tReturnStatement.
@@ -504,6 +511,7 @@ FASTPythonMetamodelGenerator >> defineHierarchy [
504511
subscript --|> tCanBeSplatExpression.
505512
subscript --|> tAsPatternTarget.
506513
subscript --|> tAsPatternSource.
514+
subscript --|> tRaised.
507515

508516
tAsPatternTarget --|> tAsPatternSource.
509517

@@ -652,6 +660,8 @@ FASTPythonMetamodelGenerator >> defineRelations [
652660
(patternList property: #elements) <>-* (expression property: #patternListOwner).
653661

654662
(printStatement property: #expressions) <>-* (expression property: #prarentPrintStatement).
663+
664+
(raiseStatement property: #exception) <>- (tRaised property: #parentRaiseStatement).
655665

656666
((slice property: #components) comment: 'The components are the expressions between the `:` of a slice.')
657667
<>-* ((expression property: #sliceOwner) comment: 'Slice in which I am a component (start, end or step) (If it''s the case)'''). "Originally, I created a trait for Slice content because the python syntax does not allow all expressions. But multiple libraries are changing the syntax to accept other objects such as float, list or even string. So now I point FASTPyExpression to not fail on all those cases."
@@ -697,6 +707,7 @@ FASTPythonMetamodelGenerator >> defineTraits [
697707
tComprehension := builder newTraitNamed: #TComprehension.
698708
tDefinition := builder newTraitNamed: #TDefinition.
699709
(tDecoratorExpression := builder newTraitNamed: #TDecoratorExpression) comment: 'I represent an entity that *can* be the expression of a decorator.'.
710+
(tRaised := builder newTraitNamed: #TRaised) comment: 'I represent an expression that can give an exception to raise in a raise statement.'.
700711
tUnaryOperator := builder newTraitNamed: #TUnaryOperator.
701712
tWithStatementItem := (builder newTraitNamed: #TWithStatementItem) comment: 'I represent an entity that can be the item of a with_statement.'.
702713
tWithElseClause := builder newTraitNamed: #TWithElseClause.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"
2+
Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
3+
"
4+
Class {
5+
#name : 'ManifestFASTPythonModelGenerator',
6+
#superclass : 'PackageManifest',
7+
#category : 'FAST-Python-Model-Generator-Manifest',
8+
#package : 'FAST-Python-Model-Generator',
9+
#tag : 'Manifest'
10+
}
11+
12+
{ #category : 'code-critics' }
13+
ManifestFASTPythonModelGenerator class >> ruleLongMethodsRuleV1FalsePositive [
14+
15+
<ignoreForCoverage>
16+
^ #(#(#(#RGPackageDefinition #(#'FAST-Python-Model-Generator')) #'2026-03-13T22:20:00.537523+01:00') )
17+
]

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
99
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |
1010
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
11+
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1112
| `parentSplat` | `FASTPyTCanBeSplatExpression` | `expression` | `FASTPyCollectionSplat` | |
1213
1314
### Children
@@ -22,8 +23,8 @@
2223
Class {
2324
#name : 'FASTPyAttributeAccess',
2425
#superclass : 'FASTPyExpression',
25-
#traits : 'FASTPyTAsPatternSource + FASTPyTAsPatternTarget + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression',
26-
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAsPatternTarget classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait',
26+
#traits : 'FASTPyTAsPatternSource + FASTPyTAsPatternTarget + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression + FASTPyTRaised',
27+
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAsPatternTarget classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait + FASTPyTRaised classTrait',
2728
#instVars : [
2829
'#attribute => FMOne type: #FASTPyVariable opposite: #attributeOwner',
2930
'#object => FMOne type: #FASTPyExpression opposite: #attributeObjectOwner'

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1515
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1616
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
17+
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1718
| `parentSplat` | `FASTPyTCanBeSplatExpression` | `expression` | `FASTPyCollectionSplat` | |
1819
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
1920
@@ -37,8 +38,8 @@
3738
Class {
3839
#name : 'FASTPyBooleanOperator',
3940
#superclass : 'FASTPyOperator',
40-
#traits : 'FASTPyTCanBeSplatExpression + FASTTBinaryExpression',
41-
#classTraits : 'FASTPyTCanBeSplatExpression classTrait + FASTTBinaryExpression classTrait',
41+
#traits : 'FASTPyTCanBeSplatExpression + FASTPyTRaised + FASTTBinaryExpression',
42+
#classTraits : 'FASTPyTCanBeSplatExpression classTrait + FASTPyTRaised classTrait + FASTTBinaryExpression classTrait',
4243
#category : 'FAST-Python-Model-Entities',
4344
#package : 'FAST-Python-Model',
4445
#tag : 'Entities'

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| `parentExpression` | `FASTTExpression` | `expression` | `FASTTUnaryExpression` | Parent (unary) expression|
1717
| `parentExpressionLeft` | `FASTTExpression` | `leftOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am left side|
1818
| `parentExpressionRight` | `FASTTExpression` | `rightOperand` | `FASTTBinaryExpression` | Parent (binary) expression of which I am right side|
19+
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1920
| `parentSplat` | `FASTPyTCanBeSplatExpression` | `expression` | `FASTPyCollectionSplat` | |
2021
| `parentWithStatementItem` | `FASTPyTWithStatementItem` | `items` | `FASTPyWithStatement` | |
2122
| `returnOwner` | `FASTTExpression` | `expression` | `FASTTReturnStatement` | The return statement that own the expression (if it's the case)|
@@ -40,8 +41,8 @@
4041
Class {
4142
#name : 'FASTPyCall',
4243
#superclass : 'FASTPyExpression',
43-
#traits : 'FASTPyTAsPatternSource + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression + FASTPyTWithStatementItem + FASTTInvocation',
44-
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait + FASTPyTWithStatementItem classTrait + FASTTInvocation classTrait',
44+
#traits : 'FASTPyTAsPatternSource + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression + FASTPyTRaised + FASTPyTWithStatementItem + FASTTInvocation',
45+
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait + FASTPyTRaised classTrait + FASTPyTWithStatementItem classTrait + FASTTInvocation classTrait',
4546
#instVars : [
4647
'#callee => FMOne type: #FASTPyExpression opposite: #caller'
4748
],

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
99
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |
1010
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
11+
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1112
| `parentSplat` | `FASTPyTCanBeSplatExpression` | `expression` | `FASTPyCollectionSplat` | |
1213
1314
@@ -16,8 +17,8 @@
1617
Class {
1718
#name : 'FASTPyIdentifier',
1819
#superclass : 'FASTPyExpression',
19-
#traits : 'FASTPyTAsPatternSource + FASTPyTAsPatternTarget + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression',
20-
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAsPatternTarget classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait',
20+
#traits : 'FASTPyTAsPatternSource + FASTPyTAsPatternTarget + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression + FASTPyTRaised',
21+
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAsPatternTarget classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait + FASTPyTRaised classTrait',
2122
#category : 'FAST-Python-Model-Entities',
2223
#package : 'FAST-Python-Model',
2324
#tag : 'Entities'
Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
"
2+
## Relations
3+
======================
4+
5+
### Children
6+
| Relation | Origin | Opposite | Type | Comment |
7+
|---|
8+
| `exception` | `FASTPyRaiseStatement` | `parentRaiseStatement` | `FASTPyTRaised` | |
9+
10+
11+
12+
"
113
Class {
214
#name : 'FASTPyRaiseStatement',
3-
#superclass : 'FASTPyEntity',
15+
#superclass : 'FASTPyStatement',
16+
#instVars : [
17+
'#exception => FMOne type: #FASTPyTRaised opposite: #parentRaiseStatement'
18+
],
419
#category : 'FAST-Python-Model-Entities',
520
#package : 'FAST-Python-Model',
621
#tag : 'Entities'
@@ -9,8 +24,30 @@ Class {
924
{ #category : 'meta' }
1025
FASTPyRaiseStatement class >> annotation [
1126

12-
<FMClass: #RaiseStatement super: #FASTPyEntity>
27+
<FMClass: #RaiseStatement super: #FASTPyStatement>
1328
<package: #'FAST-Python-Model'>
1429
<generated>
1530
^ self
1631
]
32+
33+
{ #category : 'accessing' }
34+
FASTPyRaiseStatement >> exception [
35+
"Relation named: #exception type: #FASTPyTRaised opposite: #parentRaiseStatement"
36+
37+
<generated>
38+
^ exception
39+
]
40+
41+
{ #category : 'accessing' }
42+
FASTPyRaiseStatement >> exception: anObject [
43+
44+
<generated>
45+
exception := anObject
46+
]
47+
48+
{ #category : 'navigation' }
49+
FASTPyRaiseStatement >> exceptionGroup [
50+
<generated>
51+
<navigation: 'Exception'>
52+
^ MooseSpecializedGroup with: self exception
53+
]

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
| `parentAsPatternSource` | `FASTPyTAsPatternSource` | `source` | `FASTPyAsPattern` | |
99
| `parentAsPatternTarget` | `FASTPyTAsPatternTarget` | `target` | `FASTPyAsPattern` | |
1010
| `parentDeclarator` | `FASTPyTDecoratorExpression` | `expression` | `FASTPyDecorator` | |
11+
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
1112
| `parentSplat` | `FASTPyTCanBeSplatExpression` | `expression` | `FASTPyCollectionSplat` | |
1213
1314
### Children
@@ -22,8 +23,8 @@
2223
Class {
2324
#name : 'FASTPySubscript',
2425
#superclass : 'FASTPyExpression',
25-
#traits : 'FASTPyTAsPatternSource + FASTPyTAsPatternTarget + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression',
26-
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAsPatternTarget classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait',
26+
#traits : 'FASTPyTAsPatternSource + FASTPyTAsPatternTarget + FASTPyTCanBeSplatExpression + FASTPyTDecoratorExpression + FASTPyTRaised',
27+
#classTraits : 'FASTPyTAsPatternSource classTrait + FASTPyTAsPatternTarget classTrait + FASTPyTCanBeSplatExpression classTrait + FASTPyTDecoratorExpression classTrait + FASTPyTRaised classTrait',
2728
#instVars : [
2829
'#indices => FMMany type: #FASTPyExpression opposite: #subscriptIndiceOwner',
2930
'#value => FMOne type: #FASTPyExpression opposite: #subscriptValueOwner'
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"
2+
I represent an expression that can give an exception to raise in a raise statement.
3+
4+
## Relations
5+
======================
6+
7+
### Parents
8+
| Relation | Origin | Opposite | Type | Comment |
9+
|---|
10+
| `parentRaiseStatement` | `FASTPyTRaised` | `exception` | `FASTPyRaiseStatement` | |
11+
12+
13+
14+
"
15+
Trait {
16+
#name : 'FASTPyTRaised',
17+
#instVars : [
18+
'#parentRaiseStatement => FMOne type: #FASTPyRaiseStatement opposite: #exception'
19+
],
20+
#category : 'FAST-Python-Model-Traits',
21+
#package : 'FAST-Python-Model',
22+
#tag : 'Traits'
23+
}
24+
25+
{ #category : 'meta' }
26+
FASTPyTRaised classSide >> annotation [
27+
28+
<FMClass: #TRaised super: #Object>
29+
<package: #'FAST-Python-Model'>
30+
<generated>
31+
^ self
32+
]
33+
34+
{ #category : 'accessing' }
35+
FASTPyTRaised >> parentRaiseStatement [
36+
"Relation named: #parentRaiseStatement type: #FASTPyRaiseStatement opposite: #exception"
37+
38+
<generated>
39+
<container>
40+
<derived>
41+
^ parentRaiseStatement
42+
]
43+
44+
{ #category : 'accessing' }
45+
FASTPyTRaised >> parentRaiseStatement: anObject [
46+
47+
<generated>
48+
parentRaiseStatement := anObject
49+
]
50+
51+
{ #category : 'navigation' }
52+
FASTPyTRaised >> parentRaiseStatementGroup [
53+
<generated>
54+
<navigation: 'ParentRaiseStatement'>
55+
^ MooseSpecializedGroup with: self parentRaiseStatement
56+
]

0 commit comments

Comments
 (0)