Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
strategy:
matrix:
# List of images at https://github.com/hpi-swa/smalltalkCI#images
# Use Moose64-11 that includes our visualization tool
smalltalk: [Moose64-11]
# Use Moose64-12 that includes our visualization tool
smalltalk: [Moose64-12]
name: ${{ matrix.smalltalk }}
steps:
- name: Checkout code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ I represent a TypeScript arrow function.

| Name | Type | Default value | Comment |
|---|
| `cyclomaticComplexity` | `Number` | 0 | Cyclomatic Complexity Property for Functions.|
| `isStub` | `Boolean` | false | Flag true if the entity attributes are incomplete, either because the entity is missing or not imported.|
| `name` | `String` | nil | Basic name of the entity, not full reference.|
| `signature` | `String` | nil | Signature of the message being sent|
Expand All @@ -49,8 +50,8 @@ I represent a TypeScript arrow function.
Class {
#name : 'FamixTypeScriptArrowFunction',
#superclass : 'FamixTypeScriptBehaviouralEntity',
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable',
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait',
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable + FamixTypeScriptTFunctionMetrics',
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait + FamixTypeScriptTFunctionMetrics classTrait',
#category : 'Famix-TypeScript-Entities-Entities',
#package : 'Famix-TypeScript-Entities',
#tag : 'Entities'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ I represent a TypeScript function.

| Name | Type | Default value | Comment |
|---|
| `cyclomaticComplexity` | `Number` | 0 | Cyclomatic Complexity Property for Functions.|
| `isStub` | `Boolean` | false | Flag true if the entity attributes are incomplete, either because the entity is missing or not imported.|
| `name` | `String` | nil | Basic name of the entity, not full reference.|
| `signature` | `String` | nil | Signature of the message being sent|
Expand All @@ -49,8 +50,8 @@ I represent a TypeScript function.
Class {
#name : 'FamixTypeScriptFunction',
#superclass : 'FamixTypeScriptBehaviouralEntity',
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable',
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait',
#traits : 'FamixTDefinedInModule + FamixTFunction + FamixTImportable + FamixTInvocable + FamixTypeScriptTFunctionMetrics',
#classTraits : 'FamixTDefinedInModule classTrait + FamixTFunction classTrait + FamixTImportable classTrait + FamixTInvocable classTrait + FamixTypeScriptTFunctionMetrics classTrait',
#category : 'Famix-TypeScript-Entities-Entities',
#package : 'Famix-TypeScript-Entities',
#tag : 'Entities'
Expand Down
13 changes: 13 additions & 0 deletions src/Famix-TypeScript-Entities/FamixTypeScriptModule.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,26 @@
| `incomingImports` | `FamixTImportable` | `importedEntity` | `FamixTImport` | List of imports of this entity|


## Properties
======================

| Name | Type | Default value | Comment |
|---|
| `isAmbient` | `Boolean` | false | |
| `isModule` | `Boolean` | false | |
| `isNamespace` | `Boolean` | false | |

"
Class {
#name : 'FamixTypeScriptModule',
#superclass : 'FamixTypeScriptScriptEntity',
#traits : 'FamixTImportable + FamixTWithImports + FamixTWithLocalVariables',
#classTraits : 'FamixTImportable classTrait + FamixTWithImports classTrait + FamixTWithLocalVariables classTrait',
#instVars : [
'#isAmbient => FMProperty defaultValue: false',
'#isModule => FMProperty defaultValue: false',
'#isNamespace => FMProperty defaultValue: false'
],
#category : 'Famix-TypeScript-Entities-Entities',
#package : 'Famix-TypeScript-Entities',
#tag : 'Entities'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"
## Properties
======================

| Name | Type | Default value | Comment |
|---|
| `cyclomaticComplexity` | `Number` | 0 | Cyclomatic Complexity Property for Functions.|

"
Trait {
#name : 'FamixTypeScriptTFunctionMetrics',
#instVars : [
'#cyclomaticComplexity => FMProperty defaultValue: 0'
],
#category : 'Famix-TypeScript-Entities-Traits',
#package : 'Famix-TypeScript-Entities',
#tag : 'Traits'
}

{ #category : 'meta' }
FamixTypeScriptTFunctionMetrics classSide >> annotation [

<FMClass: #TFunctionMetrics super: #Object>
<package: #FamixTypeScript>
<generated>
^ self
]

{ #category : 'accessing' }
FamixTypeScriptTFunctionMetrics >> cyclomaticComplexity [

<FMProperty: #cyclomaticComplexity type: #Number defaultValue: 0>
<generated>
<FMComment: 'Cyclomatic Complexity Property for Functions.'>
^ cyclomaticComplexity ifNil: [ cyclomaticComplexity := 0 ]
]

{ #category : 'accessing' }
FamixTypeScriptTFunctionMetrics >> cyclomaticComplexity: anObject [
<generated>
cyclomaticComplexity := anObject
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #FamixTWithSourceLanguages }
Extension { #name : 'FamixTWithSourceLanguages' }

{ #category : #'*Famix-TypeScript-Generator' }
{ #category : '*Famix-TypeScript-Generator' }
FamixTWithSourceLanguages >> formattedSourceText [
^ self sourceLanguage
ifNotNil: [ :language | language format: self sourceText from: self ]
Expand Down
52 changes: 34 additions & 18 deletions src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #FamixTypeScriptGenerator,
#superclass : #FamixBasicInfrastructureGenerator,
#name : 'FamixTypeScriptGenerator',
#superclass : 'FamixBasicInfrastructureGenerator',
#instVars : [
'access',
'class',
Expand Down Expand Up @@ -44,30 +44,32 @@ Class {
'parametricClass',
'parametricInterface',
'concretization',
'parameterConcretization'
'parameterConcretization',
'tTypeScriptFunctionMetrics'
],
#category : #'Famix-TypeScript-Generator'
#category : 'Famix-TypeScript-Generator',
#package : 'Famix-TypeScript-Generator'
}

{ #category : #accessing }
{ #category : 'accessing' }
FamixTypeScriptGenerator class >> packageName [

^ #'Famix-TypeScript-Entities'
]

{ #category : #accessing }
{ #category : 'accessing' }
FamixTypeScriptGenerator class >> packageNameForAnnotations [

^ #'FamixTypeScript'
]

{ #category : #accessing }
{ #category : 'accessing' }
FamixTypeScriptGenerator class >> prefix [

^ #'FamixTypeScript'
]

{ #category : #accessing }
{ #category : 'accessing' }
FamixTypeScriptGenerator class >> translationDictionary [

| classNames associations |
Expand All @@ -79,7 +81,7 @@ FamixTypeScriptGenerator class >> translationDictionary [
^ Dictionary newFrom: associations.
]

{ #category : #comments }
{ #category : 'comments' }
FamixTypeScriptGenerator >> commentForConcretization [
"To verify"
^ '## Relations
Expand Down Expand Up @@ -113,7 +115,7 @@ FamixTypeScriptGenerator >> commentForConcretization [
'
]

{ #category : #'as yet unclassified' }
{ #category : 'as yet unclassified' }
FamixTypeScriptGenerator >> commentForParameterConcretization [
^ '## Relations
======================
Expand Down Expand Up @@ -146,7 +148,7 @@ FamixTypeScriptGenerator >> commentForParameterConcretization [
'
]

{ #category : #comments }
{ #category : 'comments' }
FamixTypeScriptGenerator >> commentForTCanBeInterface [
^ 'I allow an entity to be an interface abstraction
ex:
Expand All @@ -158,13 +160,13 @@ public interface Flyable {
```'
]

{ #category : #definition }
{ #category : 'definition' }
FamixTypeScriptGenerator >> commentForTWithInterfaces [

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

{ #category : #definition }
{ #category : 'definition' }
FamixTypeScriptGenerator >> defineClasses [

super defineClasses.
Expand Down Expand Up @@ -221,7 +223,7 @@ FamixTypeScriptGenerator >> defineClasses [
"self defineComments."
]

{ #category : #definition }
{ #category : 'definition' }
FamixTypeScriptGenerator >> defineHierarchy [

super defineHierarchy.
Expand Down Expand Up @@ -283,6 +285,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
function --|> #TDefinedInModule.
function --|> #TInvocable.
function --|> #TImportable.
function --|> #TFunctionMetrics.

parametricFunction --|> function.
parametricFunction --|> #TParametricEntity.
Expand All @@ -292,6 +295,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
arrowFunction --|> #TDefinedInModule.
arrowFunction --|> #TInvocable.
arrowFunction --|> #TImportable.
arrowFunction --|> #TFunctionMetrics. "Dublicate code for adding cyclomatic complexity"

parametricArrowFunction --|> arrowFunction.
parametricArrowFunction --|> #TParametricEntity.
Expand Down Expand Up @@ -416,7 +420,7 @@ FamixTypeScriptGenerator >> defineHierarchy [
parameterType --|> #TWithInheritances.
]

{ #category : #definition }
{ #category : 'definition' }
FamixTypeScriptGenerator >> defineProperties [

super defineProperties.
Expand All @@ -433,7 +437,16 @@ FamixTypeScriptGenerator >> defineProperties [
comment: 'Properties may be postfixed with a private modifier that makes the property private even in JavaScript.'.
(comment property: #isJSDoc type: #Boolean defaultValue: false)
comment: 'Comments can have the form of JSDoc.'.

"Trait Properties can be exported into another function"
"Adding the following for cyclomatic complexity property for TFunctionMetrics"
(tTypeScriptFunctionMetrics property: #cyclomaticComplexity type: #Number defaultValue: 0)
comment: 'Cyclomatic Complexity Property for Functions.'.

(module property: #isAmbient type: #Boolean defaultValue: false).
(module property: #isModule type: #Boolean defaultValue: false).
(module property: #isNamespace type: #Boolean defaultValue: false).

"The following are not need because of THasKind (?)"

"(method property: #isConstructor type: #Boolean defaultValue: false)
Expand All @@ -442,25 +455,28 @@ FamixTypeScriptGenerator >> defineProperties [
comment: 'Method is a getter'.
(method property: #isSetter type: #Boolean defaultValue: false)
comment: 'Method is a setter'"


]

{ #category : #definition }
{ #category : 'definition' }
FamixTypeScriptGenerator >> defineRelations [
super defineRelations.
(decorator property: #decoratedEntity) *- (namedEntity property: #decorators).
]

{ #category : #definition }
{ #category : 'definition' }
FamixTypeScriptGenerator >> defineTraits [

super defineTraits.
tWithInterfaces := builder newTraitNamed: #TWithInterfaces.
tWithInterfaces comment: self commentForTWithInterfaces.

tTypeScriptClassMetrics := builder newTraitNamed: #TClassMetrics.
tTypeScriptFunctionMetrics := builder newTraitNamed: #TFunctionMetrics.
]

{ #category : #definition }
{ #category : 'definition' }
FamixTypeScriptGenerator >> newBuilder [

^ super newBuilder
Expand Down
2 changes: 1 addition & 1 deletion src/Famix-TypeScript-Generator/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Famix-TypeScript-Generator' }
Package { #name : 'Famix-TypeScript-Generator' }
48 changes: 48 additions & 0 deletions src/Famix-TypeScript-Tests/FamixTypeScriptModuleTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Class {
#name : 'FamixTypeScriptModuleTest',
#superclass : 'TestCase',
#category : 'Famix-TypeScript-Tests',
#package : 'Famix-TypeScript-Tests'
}

{ #category : 'tests' }
FamixTypeScriptModuleTest >> testIsAmbient [
| m1 m2 model |
model := FamixTypeScriptModel new.
m1 := FamixTypeScriptModule named: 'module1' model: model.
m2 := FamixTypeScriptModule named: 'module2' model: model.

m1 isAmbient: true.
self assert: m1 isAmbient equals: true.

m1 isAmbient: false.
self assert: m1 isAmbient equals: false.
]

{ #category : 'tests' }
FamixTypeScriptModuleTest >> testIsModule [
| m1 m2 model |
model := FamixTypeScriptModel new.
m1 := FamixTypeScriptModule named: 'module1' model: model.
m2 := FamixTypeScriptModule named: 'module2' model: model.

m1 isModule: true.
self assert: m1 isModule equals: true.

m1 isModule: false.
self assert: m1 isModule equals: false.
]

{ #category : 'tests' }
FamixTypeScriptModuleTest >> testIsNamespace [
| m1 m2 model |
model := FamixTypeScriptModel new.
m1 := FamixTypeScriptModule named: 'module1' model: model.
m2 := FamixTypeScriptModule named: 'module2' model: model.

m1 isNamespace: true.
self assert: m1 isNamespace equals: true.

m1 isNamespace: false.
self assert: m1 isNamespace equals: false.
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Class {
#name : 'FamixTypeScriptTFunctionMetricsTest',
#superclass : 'TestCase',
#category : 'Famix-TypeScript-Tests-Entities',
#package : 'Famix-TypeScript-Tests',
#tag : 'Entities'
}

{ #category : 'tests' }
FamixTypeScriptTFunctionMetricsTest >> testCyclomaticComplexityPresence [
| af1 f1 model |
model := FamixTypeScriptModel new.
f1 := FamixTypeScriptFunction named: 'func1' model: model.
af1 := FamixTypeScriptArrowFunction named: 'arrowFunc1' model: model.

f1 cyclomaticComplexity: 100.
self assert: f1 cyclomaticComplexity equals: 100.

af1 cyclomaticComplexity: 100.
self assert: af1 cyclomaticComplexity equals: 100.


]
Loading