Skip to content

Commit 614c4f2

Browse files
authored
Merge pull request #30 from MTahaCode/missing-elements-from-importer
Missing elements from importer
2 parents 026d01a + 8f9399e commit 614c4f2

10 files changed

Lines changed: 171 additions & 27 deletions

‎.github/workflows/common.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
strategy:
1616
matrix:
1717
# List of images at https://github.com/hpi-swa/smalltalkCI#images
18-
# Use Moose64-11 that includes our visualization tool
19-
smalltalk: [Moose64-11]
18+
# Use Moose64-12 that includes our visualization tool
19+
smalltalk: [Moose64-12]
2020
name: ${{ matrix.smalltalk }}
2121
steps:
2222
- name: Checkout code

‎src/Famix-TypeScript-Entities/FamixTypeScriptArrowFunction.class.st‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ I represent a TypeScript arrow function.
4141
4242
| Name | Type | Default value | Comment |
4343
|---|
44+
| `cyclomaticComplexity` | `Number` | 0 | Cyclomatic Complexity Property for Functions.|
4445
| `isStub` | `Boolean` | false | Flag true if the entity attributes are incomplete, either because the entity is missing or not imported.|
4546
| `name` | `String` | nil | Basic name of the entity, not full reference.|
4647
| `signature` | `String` | nil | Signature of the message being sent|
@@ -49,8 +50,8 @@ I represent a TypeScript arrow function.
4950
Class {
5051
#name : 'FamixTypeScriptArrowFunction',
5152
#superclass : 'FamixTypeScriptBehaviouralEntity',
52-
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable',
53-
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait',
53+
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable + FamixTypeScriptTFunctionMetrics',
54+
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait + FamixTypeScriptTFunctionMetrics classTrait',
5455
#category : 'Famix-TypeScript-Entities-Entities',
5556
#package : 'Famix-TypeScript-Entities',
5657
#tag : 'Entities'

‎src/Famix-TypeScript-Entities/FamixTypeScriptFunction.class.st‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ I represent a TypeScript function.
4141
4242
| Name | Type | Default value | Comment |
4343
|---|
44+
| `cyclomaticComplexity` | `Number` | 0 | Cyclomatic Complexity Property for Functions.|
4445
| `isStub` | `Boolean` | false | Flag true if the entity attributes are incomplete, either because the entity is missing or not imported.|
4546
| `name` | `String` | nil | Basic name of the entity, not full reference.|
4647
| `signature` | `String` | nil | Signature of the message being sent|
@@ -49,8 +50,8 @@ I represent a TypeScript function.
4950
Class {
5051
#name : 'FamixTypeScriptFunction',
5152
#superclass : 'FamixTypeScriptBehaviouralEntity',
52-
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable',
53-
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait',
53+
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable + FamixTypeScriptTFunctionMetrics',
54+
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait + FamixTypeScriptTFunctionMetrics classTrait',
5455
#category : 'Famix-TypeScript-Entities-Entities',
5556
#package : 'Famix-TypeScript-Entities',
5657
#tag : 'Entities'

‎src/Famix-TypeScript-Entities/FamixTypeScriptModule.class.st‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,26 @@
1818
| `incomingImports` | `FamixTImportable` | `importedEntity` | `FamixTImport` | List of imports of this entity|
1919
2020
21+
## Properties
22+
======================
23+
24+
| Name | Type | Default value | Comment |
25+
|---|
26+
| `isAmbient` | `Boolean` | false | |
27+
| `isModule` | `Boolean` | false | |
28+
| `isNamespace` | `Boolean` | false | |
2129
2230
"
2331
Class {
2432
#name : 'FamixTypeScriptModule',
2533
#superclass : 'FamixTypeScriptScriptEntity',
2634
#traits : 'FamixTImportable + FamixTWithImports + FamixTWithLocalVariables',
2735
#classTraits : 'FamixTImportable classTrait + FamixTWithImports classTrait + FamixTWithLocalVariables classTrait',
36+
#instVars : [
37+
'#isAmbient => FMProperty defaultValue: false',
38+
'#isModule => FMProperty defaultValue: false',
39+
'#isNamespace => FMProperty defaultValue: false'
40+
],
2841
#category : 'Famix-TypeScript-Entities-Entities',
2942
#package : 'Famix-TypeScript-Entities',
3043
#tag : 'Entities'
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"
2+
## Properties
3+
======================
4+
5+
| Name | Type | Default value | Comment |
6+
|---|
7+
| `cyclomaticComplexity` | `Number` | 0 | Cyclomatic Complexity Property for Functions.|
8+
9+
"
10+
Trait {
11+
#name : 'FamixTypeScriptTFunctionMetrics',
12+
#instVars : [
13+
'#cyclomaticComplexity => FMProperty defaultValue: 0'
14+
],
15+
#category : 'Famix-TypeScript-Entities-Traits',
16+
#package : 'Famix-TypeScript-Entities',
17+
#tag : 'Traits'
18+
}
19+
20+
{ #category : 'meta' }
21+
FamixTypeScriptTFunctionMetrics classSide >> annotation [
22+
23+
<FMClass: #TFunctionMetrics super: #Object>
24+
<package: #FamixTypeScript>
25+
<generated>
26+
^ self
27+
]
28+
29+
{ #category : 'accessing' }
30+
FamixTypeScriptTFunctionMetrics >> cyclomaticComplexity [
31+
32+
<FMProperty: #cyclomaticComplexity type: #Number defaultValue: 0>
33+
<generated>
34+
<FMComment: 'Cyclomatic Complexity Property for Functions.'>
35+
^ cyclomaticComplexity ifNil: [ cyclomaticComplexity := 0 ]
36+
]
37+
38+
{ #category : 'accessing' }
39+
FamixTypeScriptTFunctionMetrics >> cyclomaticComplexity: anObject [
40+
<generated>
41+
cyclomaticComplexity := anObject
42+
]

‎src/Famix-TypeScript-Generator/FamixTWithSourceLanguages.extension.st‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Extension { #name : #FamixTWithSourceLanguages }
1+
Extension { #name : 'FamixTWithSourceLanguages' }
22

3-
{ #category : #'*Famix-TypeScript-Generator' }
3+
{ #category : '*Famix-TypeScript-Generator' }
44
FamixTWithSourceLanguages >> formattedSourceText [
55
^ self sourceLanguage
66
ifNotNil: [ :language | language format: self sourceText from: self ]

‎src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st‎

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Class {
2-
#name : #FamixTypeScriptGenerator,
3-
#superclass : #FamixBasicInfrastructureGenerator,
2+
#name : 'FamixTypeScriptGenerator',
3+
#superclass : 'FamixBasicInfrastructureGenerator',
44
#instVars : [
55
'access',
66
'class',
@@ -44,30 +44,32 @@ Class {
4444
'parametricClass',
4545
'parametricInterface',
4646
'concretization',
47-
'parameterConcretization'
47+
'parameterConcretization',
48+
'tTypeScriptFunctionMetrics'
4849
],
49-
#category : #'Famix-TypeScript-Generator'
50+
#category : 'Famix-TypeScript-Generator',
51+
#package : 'Famix-TypeScript-Generator'
5052
}
5153

52-
{ #category : #accessing }
54+
{ #category : 'accessing' }
5355
FamixTypeScriptGenerator class >> packageName [
5456

5557
^ #'Famix-TypeScript-Entities'
5658
]
5759

58-
{ #category : #accessing }
60+
{ #category : 'accessing' }
5961
FamixTypeScriptGenerator class >> packageNameForAnnotations [
6062

6163
^ #'FamixTypeScript'
6264
]
6365

64-
{ #category : #accessing }
66+
{ #category : 'accessing' }
6567
FamixTypeScriptGenerator class >> prefix [
6668

6769
^ #'FamixTypeScript'
6870
]
6971

70-
{ #category : #accessing }
72+
{ #category : 'accessing' }
7173
FamixTypeScriptGenerator class >> translationDictionary [
7274

7375
| classNames associations |
@@ -79,7 +81,7 @@ FamixTypeScriptGenerator class >> translationDictionary [
7981
^ Dictionary newFrom: associations.
8082
]
8183

82-
{ #category : #comments }
84+
{ #category : 'comments' }
8385
FamixTypeScriptGenerator >> commentForConcretization [
8486
"To verify"
8587
^ '## Relations
@@ -113,7 +115,7 @@ FamixTypeScriptGenerator >> commentForConcretization [
113115
'
114116
]
115117

116-
{ #category : #'as yet unclassified' }
118+
{ #category : 'as yet unclassified' }
117119
FamixTypeScriptGenerator >> commentForParameterConcretization [
118120
^ '## Relations
119121
======================
@@ -146,7 +148,7 @@ FamixTypeScriptGenerator >> commentForParameterConcretization [
146148
'
147149
]
148150

149-
{ #category : #comments }
151+
{ #category : 'comments' }
150152
FamixTypeScriptGenerator >> commentForTCanBeInterface [
151153
^ 'I allow an entity to be an interface abstraction
152154
ex:
@@ -158,13 +160,13 @@ public interface Flyable {
158160
```'
159161
]
160162

161-
{ #category : #definition }
163+
{ #category : 'definition' }
162164
FamixTypeScriptGenerator >> commentForTWithInterfaces [
163165

164166
^ 'I can contain interfaces (Packages, Methods, Classes...)'
165167
]
166168

167-
{ #category : #definition }
169+
{ #category : 'definition' }
168170
FamixTypeScriptGenerator >> defineClasses [
169171

170172
super defineClasses.
@@ -221,7 +223,7 @@ FamixTypeScriptGenerator >> defineClasses [
221223
"self defineComments."
222224
]
223225

224-
{ #category : #definition }
226+
{ #category : 'definition' }
225227
FamixTypeScriptGenerator >> defineHierarchy [
226228

227229
super defineHierarchy.
@@ -283,6 +285,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
283285
function --|> #TDefinedInModule.
284286
function --|> #TInvocable.
285287
function --|> #TImportable.
288+
function --|> #TFunctionMetrics.
286289

287290
parametricFunction --|> function.
288291
parametricFunction --|> #TParametricEntity.
@@ -292,6 +295,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
292295
arrowFunction --|> #TDefinedInModule.
293296
arrowFunction --|> #TInvocable.
294297
arrowFunction --|> #TImportable.
298+
arrowFunction --|> #TFunctionMetrics. "Dublicate code for adding cyclomatic complexity"
295299

296300
parametricArrowFunction --|> arrowFunction.
297301
parametricArrowFunction --|> #TParametricEntity.
@@ -416,7 +420,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
416420
parameterType --|> #TWithInheritances.
417421
]
418422

419-
{ #category : #definition }
423+
{ #category : 'definition' }
420424
FamixTypeScriptGenerator >> defineProperties [
421425

422426
super defineProperties.
@@ -433,7 +437,16 @@ FamixTypeScriptGenerator >> defineProperties [
433437
comment: 'Properties may be postfixed with a private modifier that makes the property private even in JavaScript.'.
434438
(comment property: #isJSDoc type: #Boolean defaultValue: false)
435439
comment: 'Comments can have the form of JSDoc.'.
440+
441+
"Trait Properties can be exported into another function"
442+
"Adding the following for cyclomatic complexity property for TFunctionMetrics"
443+
(tTypeScriptFunctionMetrics property: #cyclomaticComplexity type: #Number defaultValue: 0)
444+
comment: 'Cyclomatic Complexity Property for Functions.'.
436445

446+
(module property: #isAmbient type: #Boolean defaultValue: false).
447+
(module property: #isModule type: #Boolean defaultValue: false).
448+
(module property: #isNamespace type: #Boolean defaultValue: false).
449+
437450
"The following are not need because of THasKind (?)"
438451

439452
"(method property: #isConstructor type: #Boolean defaultValue: false)
@@ -442,25 +455,28 @@ FamixTypeScriptGenerator >> defineProperties [
442455
comment: 'Method is a getter'.
443456
(method property: #isSetter type: #Boolean defaultValue: false)
444457
comment: 'Method is a setter'"
458+
459+
445460
]
446461

447-
{ #category : #definition }
462+
{ #category : 'definition' }
448463
FamixTypeScriptGenerator >> defineRelations [
449464
super defineRelations.
450465
(decorator property: #decoratedEntity) *- (namedEntity property: #decorators).
451466
]
452467

453-
{ #category : #definition }
468+
{ #category : 'definition' }
454469
FamixTypeScriptGenerator >> defineTraits [
455470

456471
super defineTraits.
457472
tWithInterfaces := builder newTraitNamed: #TWithInterfaces.
458473
tWithInterfaces comment: self commentForTWithInterfaces.
459474

460475
tTypeScriptClassMetrics := builder newTraitNamed: #TClassMetrics.
476+
tTypeScriptFunctionMetrics := builder newTraitNamed: #TFunctionMetrics.
461477
]
462478

463-
{ #category : #definition }
479+
{ #category : 'definition' }
464480
FamixTypeScriptGenerator >> newBuilder [
465481

466482
^ super newBuilder
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Package { #name : #'Famix-TypeScript-Generator' }
1+
Package { #name : 'Famix-TypeScript-Generator' }
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Class {
2+
#name : 'FamixTypeScriptModuleTest',
3+
#superclass : 'TestCase',
4+
#category : 'Famix-TypeScript-Tests',
5+
#package : 'Famix-TypeScript-Tests'
6+
}
7+
8+
{ #category : 'tests' }
9+
FamixTypeScriptModuleTest >> testIsAmbient [
10+
| m1 m2 model |
11+
model := FamixTypeScriptModel new.
12+
m1 := FamixTypeScriptModule named: 'module1' model: model.
13+
m2 := FamixTypeScriptModule named: 'module2' model: model.
14+
15+
m1 isAmbient: true.
16+
self assert: m1 isAmbient equals: true.
17+
18+
m1 isAmbient: false.
19+
self assert: m1 isAmbient equals: false.
20+
]
21+
22+
{ #category : 'tests' }
23+
FamixTypeScriptModuleTest >> testIsModule [
24+
| m1 m2 model |
25+
model := FamixTypeScriptModel new.
26+
m1 := FamixTypeScriptModule named: 'module1' model: model.
27+
m2 := FamixTypeScriptModule named: 'module2' model: model.
28+
29+
m1 isModule: true.
30+
self assert: m1 isModule equals: true.
31+
32+
m1 isModule: false.
33+
self assert: m1 isModule equals: false.
34+
]
35+
36+
{ #category : 'tests' }
37+
FamixTypeScriptModuleTest >> testIsNamespace [
38+
| m1 m2 model |
39+
model := FamixTypeScriptModel new.
40+
m1 := FamixTypeScriptModule named: 'module1' model: model.
41+
m2 := FamixTypeScriptModule named: 'module2' model: model.
42+
43+
m1 isNamespace: true.
44+
self assert: m1 isNamespace equals: true.
45+
46+
m1 isNamespace: false.
47+
self assert: m1 isNamespace equals: false.
48+
]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Class {
2+
#name : 'FamixTypeScriptTFunctionMetricsTest',
3+
#superclass : 'TestCase',
4+
#category : 'Famix-TypeScript-Tests-Entities',
5+
#package : 'Famix-TypeScript-Tests',
6+
#tag : 'Entities'
7+
}
8+
9+
{ #category : 'tests' }
10+
FamixTypeScriptTFunctionMetricsTest >> testCyclomaticComplexityPresence [
11+
| af1 f1 model |
12+
model := FamixTypeScriptModel new.
13+
f1 := FamixTypeScriptFunction named: 'func1' model: model.
14+
af1 := FamixTypeScriptArrowFunction named: 'arrowFunc1' model: model.
15+
16+
f1 cyclomaticComplexity: 100.
17+
self assert: f1 cyclomaticComplexity equals: 100.
18+
19+
af1 cyclomaticComplexity: 100.
20+
self assert: af1 cyclomaticComplexity equals: 100.
21+
22+
23+
]

0 commit comments

Comments
 (0)