Skip to content

Commit a9d1703

Browse files
committed
Start to clean imports + add a first version of a test generator
1 parent 86051a6 commit a9d1703

11 files changed

Lines changed: 364 additions & 110 deletions

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ Class {
141141
'tAssignment',
142142
'variable',
143143
'structuralEntity',
144-
'import'
144+
'import',
145+
'importedEntity'
145146
],
146147
#category : 'FAST-Python-Model-Generator',
147148
#package : 'FAST-Python-Model-Generator'
@@ -170,7 +171,6 @@ FASTPythonMetamodelGenerator >> defineClasses [
170171
super defineClasses.
171172
entity := builder ensureClassNamed: #Entity.
172173
_ERROR := builder ensureClassNamed: #ERROR.
173-
aliasedImport := builder ensureClassNamed: #AliasedImport."Todo"
174174
argumentList := builder ensureClassNamed: #ArgumentList."Todo"
175175
asPattern := builder ensureClassNamed: #AsPattern."Todo"
176176
asPatternTarget := builder ensureClassNamed: #AsPatternTarget."Todo"
@@ -224,16 +224,15 @@ FASTPythonMetamodelGenerator >> defineClasses [
224224
formatExpression := builder ensureClassNamed: #FormatExpression."Todo"
225225
formatSpecifier := builder ensureClassNamed: #FormatSpecifier."Todo"
226226
functionDefinition := builder ensureClassNamed: #FunctionDefinition."ToReview"
227-
futureImportStatement := builder ensureClassNamed: #FutureImportStatement."Todo"
228227
generatorExpression := builder ensureClassNamed: #GeneratorExpression."Todo"
229228
genericType := builder ensureClassNamed: #GenericType."Todo"
230229
globalStatement := builder ensureClassNamed: #GlobalStatement."Todo"
231230
identifier := builder ensureClassNamed: #Identifier."Todo"
232231
ifClause := builder ensureClassNamed: #IfClause."Todo"
233232
ifStatement := builder ensureClassNamed: #IfStatement."Todo"
234233
import := builder ensureClassNamed: #Import. "To review"
234+
importedEntity := builder ensureClassNamed: #ImportedEntity.
235235
importFromStatement := builder ensureClassNamed: #ImportFromStatement."Todo"
236-
importPrefix := builder ensureClassNamed: #ImportPrefix."Todo"
237236
importStatement := builder ensureClassNamed: #ImportStatement."Todo"
238237
integer := builder ensureClassNamed: #Integer.
239238
interpolation := builder ensureClassNamed: #Interpolation.
@@ -292,7 +291,6 @@ FASTPythonMetamodelGenerator >> defineClasses [
292291
unionType := builder ensureClassNamed: #UnionType."Todo"
293292
variable := builder ensureClassNamed: #Variable. "To review"
294293
whileStatement := builder ensureClassNamed: #WhileStatement."Todo"
295-
wildcardImport := builder ensureClassNamed: #WildcardImport."Todo"
296294
withClause := builder ensureClassNamed: #WithClause."Todo"
297295
withItem := builder ensureClassNamed: #WithItem."Todo"
298296
withStatement := builder ensureClassNamed: #WithStatement."Todo"
@@ -377,7 +375,14 @@ FASTPythonMetamodelGenerator >> defineProperties [
377375
(comparisonOperator property: #operators type: #String)
378376
multivalued: true;
379377
comment: 'The comparators applied in order. Possible operators: <, <=, ==, !=, >=, >, <>, in, not in, is, is not'.
380-
378+
379+
(importedEntity property: #segments type: #String)
380+
multivalued: true;
381+
comment:
382+
'The segments of the imported entity. For example if you import `xml.etree.ElementTree`, the segments will be { ''xml'' . ''etree'' . ''ElementTree''}.'.
383+
384+
(importedEntity property: #alias type: #String) comment: 'If the imported entity has an alias, I contain it.'.
385+
381386
unaryOperator property: #operator type: #String
382387
]
383388

@@ -391,11 +396,12 @@ FASTPythonMetamodelGenerator >> defineRelations [
391396
((comparisonOperator property: #operands) comment:
392397
'List of the operands of the comparison operands. For example if we have `a == b != c`, it will be a, b and c.')
393398
<>-* ((tExpression property: #parentComparisonOperator) comment: 'Parent comparison expression of which I am.').
394-
395-
((tUnaryOperator property: #argument) comment:
396-
'Expression influanced by the unary operator..')
399+
400+
((tUnaryOperator property: #argument) comment: 'Expression influanced by the unary operator..')
397401
<>- ((tExpression property: #parentUnaryOperator) comment: 'Parent unary operator in which I am.').
398-
402+
403+
((import property: #importedEntities) comment: 'List of the imported entities.')
404+
<>-* ((importedEntity property: #import) comment: 'Import declaring me as imported entity.')
399405
]
400406

401407
{ #category : 'definition' }

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,6 @@ FASTPyEntity >> isLiteral [
164164
^ false
165165
]
166166

167-
{ #category : 'testing' }
168-
FASTPyEntity >> isQueryable [
169-
170-
<generated>
171-
^ false
172-
]
173-
174167
{ #category : 'testing' }
175168
FASTPyEntity >> isScopableEntity [
176169

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

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

Lines changed: 45 additions & 0 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+
| `importedEntities` | `FASTPyImport` | `import` | `FASTPyImportedEntity` | List of the imported entities.|
9+
10+
11+
12+
"
113
Class {
214
#name : 'FASTPyImport',
315
#superclass : 'FASTPyEntity',
16+
#instVars : [
17+
'#importedEntities => FMMany type: #FASTPyImportedEntity opposite: #import'
18+
],
419
#category : 'FAST-Python-Model-Entities',
520
#package : 'FAST-Python-Model',
621
#tag : 'Entities'
@@ -14,3 +29,33 @@ FASTPyImport class >> annotation [
1429
<generated>
1530
^ self
1631
]
32+
33+
{ #category : 'adding' }
34+
FASTPyImport >> addImportedEntity: anObject [
35+
<generated>
36+
^ self importedEntities add: anObject
37+
]
38+
39+
{ #category : 'accessing' }
40+
FASTPyImport >> importedEntities [
41+
"Relation named: #importedEntities type: #FASTPyImportedEntity opposite: #import"
42+
43+
<generated>
44+
<FMComment: 'List of the imported entities.'>
45+
<derived>
46+
^ importedEntities
47+
]
48+
49+
{ #category : 'accessing' }
50+
FASTPyImport >> importedEntities: anObject [
51+
52+
<generated>
53+
importedEntities value: anObject
54+
]
55+
56+
{ #category : 'navigation' }
57+
FASTPyImport >> importedEntitiesGroup [
58+
<generated>
59+
<navigation: 'ImportedEntities'>
60+
^ MooseSpecializedGroup withAll: self importedEntities asSet
61+
]

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

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"
2+
## Relations
3+
======================
4+
5+
### Parents
6+
| Relation | Origin | Opposite | Type | Comment |
7+
|---|
8+
| `import` | `FASTPyImportedEntity` | `importedEntities` | `FASTPyImport` | Import declaring me as imported entity.|
9+
10+
11+
## Properties
12+
======================
13+
14+
| Name | Type | Default value | Comment |
15+
|---|
16+
| `alias` | `String` | nil | If the imported entity has an alias, I contain it.|
17+
| `segments` | `String` | nil | The segments of the imported entity. For example if you import `xml.etree.ElementTree`, the segments will be { 'xml' . 'etree' . 'ElementTree'}.|
18+
19+
"
20+
Class {
21+
#name : 'FASTPyImportedEntity',
22+
#superclass : 'FASTPyEntity',
23+
#instVars : [
24+
'#segments => FMProperty',
25+
'#alias => FMProperty',
26+
'#import => FMOne type: #FASTPyImport opposite: #importedEntities'
27+
],
28+
#category : 'FAST-Python-Model-Entities',
29+
#package : 'FAST-Python-Model',
30+
#tag : 'Entities'
31+
}
32+
33+
{ #category : 'meta' }
34+
FASTPyImportedEntity class >> annotation [
35+
36+
<FMClass: #ImportedEntity super: #FASTPyEntity>
37+
<package: #'FAST-Python-Model'>
38+
<generated>
39+
^ self
40+
]
41+
42+
{ #category : 'accessing' }
43+
FASTPyImportedEntity >> alias [
44+
45+
<FMProperty: #alias type: #String>
46+
<generated>
47+
<FMComment: 'If the imported entity has an alias, I contain it.'>
48+
^ alias
49+
]
50+
51+
{ #category : 'accessing' }
52+
FASTPyImportedEntity >> alias: anObject [
53+
<generated>
54+
alias := anObject
55+
]
56+
57+
{ #category : 'accessing' }
58+
FASTPyImportedEntity >> import [
59+
"Relation named: #import type: #FASTPyImport opposite: #importedEntities"
60+
61+
<generated>
62+
<FMComment: 'Import declaring me as imported entity.'>
63+
<container>
64+
^ import
65+
]
66+
67+
{ #category : 'accessing' }
68+
FASTPyImportedEntity >> import: anObject [
69+
70+
<generated>
71+
import := anObject
72+
]
73+
74+
{ #category : 'navigation' }
75+
FASTPyImportedEntity >> importGroup [
76+
<generated>
77+
<navigation: 'Import'>
78+
^ MooseSpecializedGroup with: self import
79+
]
80+
81+
{ #category : 'accessing' }
82+
FASTPyImportedEntity >> segments [
83+
84+
<FMProperty: #segments type: #String>
85+
<generated>
86+
<multivalued>
87+
<FMComment: 'The segments of the imported entity. For example if you import `xml.etree.ElementTree`, the segments will be { ''xml'' . ''etree'' . ''ElementTree''}.'>
88+
^ segments
89+
]
90+
91+
{ #category : 'accessing' }
92+
FASTPyImportedEntity >> segments: anObject [
93+
<generated>
94+
segments := anObject
95+
]

‎src/FAST-Python-Model/FASTPyTEntityCreator.trait.st‎

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ FASTPyTEntityCreator classSide >> annotation [
2020
^ self
2121
]
2222

23-
{ #category : 'entity creation' }
24-
FASTPyTEntityCreator >> newAliasedImport [
25-
26-
<generated>
27-
^ self add: FASTPyAliasedImport new
28-
]
29-
3023
{ #category : 'entity creation' }
3124
FASTPyTEntityCreator >> newArgumentList [
3225

@@ -398,13 +391,6 @@ FASTPyTEntityCreator >> newFunctionDefinition [
398391
^ self add: FASTPyFunctionDefinition new
399392
]
400393

401-
{ #category : 'entity creation' }
402-
FASTPyTEntityCreator >> newFutureImportStatement [
403-
404-
<generated>
405-
^ self add: FASTPyFutureImportStatement new
406-
]
407-
408394
{ #category : 'entity creation' }
409395
FASTPyTEntityCreator >> newGeneratorExpression [
410396

@@ -462,17 +448,17 @@ FASTPyTEntityCreator >> newImportFromStatement [
462448
]
463449

464450
{ #category : 'entity creation' }
465-
FASTPyTEntityCreator >> newImportPrefix [
451+
FASTPyTEntityCreator >> newImportStatement [
466452

467453
<generated>
468-
^ self add: FASTPyImportPrefix new
454+
^ self add: FASTPyImportStatement new
469455
]
470456

471457
{ #category : 'entity creation' }
472-
FASTPyTEntityCreator >> newImportStatement [
458+
FASTPyTEntityCreator >> newImportedEntity [
473459

474460
<generated>
475-
^ self add: FASTPyImportStatement new
461+
^ self add: FASTPyImportedEntity new
476462
]
477463

478464
{ #category : 'entity creation' }
@@ -874,13 +860,6 @@ FASTPyTEntityCreator >> newWhileStatement [
874860
^ self add: FASTPyWhileStatement new
875861
]
876862

877-
{ #category : 'entity creation' }
878-
FASTPyTEntityCreator >> newWildcardImport [
879-
880-
<generated>
881-
^ self add: FASTPyWildcardImport new
882-
]
883-
884863
{ #category : 'entity creation' }
885864
FASTPyTEntityCreator >> newWithClause [
886865

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

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)