From 38ae2411550b689a7ed6fb9baff60a7c23e036aa Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Thu, 27 Aug 2026 11:47:50 -0400 Subject: [PATCH 1/2] Added Parameterized entities as per new concretization structure in moose. --- .../FamixTypeScriptImportingContext.class.st | 56 +++++++++++++++++++ ...ypeScriptParametricImplementation.class.st | 29 ++++++++++ ...ixTypeScriptParametricInheritance.class.st | 29 ++++++++++ ...mixTypeScriptParametricInvocation.class.st | 29 ++++++++++ ...amixTypeScriptParametricReference.class.st | 29 ++++++++++ .../FamixTypeScriptTEntityCreator.trait.st | 28 ++++++++++ .../FamixTypeScriptGenerator.class.st | 20 ++++++- 7 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 src/Famix-TypeScript-Entities/FamixTypeScriptParametricImplementation.class.st create mode 100644 src/Famix-TypeScript-Entities/FamixTypeScriptParametricInheritance.class.st create mode 100644 src/Famix-TypeScript-Entities/FamixTypeScriptParametricInvocation.class.st create mode 100644 src/Famix-TypeScript-Entities/FamixTypeScriptParametricReference.class.st diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st index 65b08e9..9f73c55 100644 --- a/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st @@ -243,6 +243,20 @@ FamixTypeScriptImportingContext >> importParametricFunction [ ^ self importConcreteEntity: (self class fm3ClassNamed: #ParametricFunction) ] +{ #category : 'importing' } +FamixTypeScriptImportingContext >> importParametricImplementation [ + + + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParametricImplementation) +] + +{ #category : 'importing' } +FamixTypeScriptImportingContext >> importParametricInheritance [ + + + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParametricInheritance) +] + { #category : 'importing' } FamixTypeScriptImportingContext >> importParametricInterface [ @@ -250,6 +264,13 @@ FamixTypeScriptImportingContext >> importParametricInterface [ ^ self importConcreteEntity: (self class fm3ClassNamed: #ParametricInterface) ] +{ #category : 'importing' } +FamixTypeScriptImportingContext >> importParametricInvocation [ + + + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParametricInvocation) +] + { #category : 'importing' } FamixTypeScriptImportingContext >> importParametricMethod [ @@ -257,6 +278,13 @@ FamixTypeScriptImportingContext >> importParametricMethod [ ^ self importConcreteEntity: (self class fm3ClassNamed: #ParametricMethod) ] +{ #category : 'importing' } +FamixTypeScriptImportingContext >> importParametricReference [ + + + ^ self importConcreteEntity: (self class fm3ClassNamed: #ParametricReference) +] + { #category : 'importing' } FamixTypeScriptImportingContext >> importPrimitiveType [ @@ -558,6 +586,20 @@ FamixTypeScriptImportingContext >> shouldImportParametricFunction [ ^ self shouldImport: #ParametricFunction ] +{ #category : 'testing' } +FamixTypeScriptImportingContext >> shouldImportParametricImplementation [ + + + ^ self shouldImport: #ParametricImplementation +] + +{ #category : 'testing' } +FamixTypeScriptImportingContext >> shouldImportParametricInheritance [ + + + ^ self shouldImport: #ParametricInheritance +] + { #category : 'testing' } FamixTypeScriptImportingContext >> shouldImportParametricInterface [ @@ -565,6 +607,13 @@ FamixTypeScriptImportingContext >> shouldImportParametricInterface [ ^ self shouldImport: #ParametricInterface ] +{ #category : 'testing' } +FamixTypeScriptImportingContext >> shouldImportParametricInvocation [ + + + ^ self shouldImport: #ParametricInvocation +] + { #category : 'testing' } FamixTypeScriptImportingContext >> shouldImportParametricMethod [ @@ -572,6 +621,13 @@ FamixTypeScriptImportingContext >> shouldImportParametricMethod [ ^ self shouldImport: #ParametricMethod ] +{ #category : 'testing' } +FamixTypeScriptImportingContext >> shouldImportParametricReference [ + + + ^ self shouldImport: #ParametricReference +] + { #category : 'testing' } FamixTypeScriptImportingContext >> shouldImportPrimitiveType [ diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptParametricImplementation.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricImplementation.class.st new file mode 100644 index 0000000..f13f61b --- /dev/null +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricImplementation.class.st @@ -0,0 +1,29 @@ +" +## Relations +====================== + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `concretizations` | `FamixTParametricAssociation` | `triggeringAssociation` | `FamixTConcretization` | The parameter concretizations associated with this association.| + + + +" +Class { + #name : 'FamixTypeScriptParametricImplementation', + #superclass : 'FamixTypeScriptImplementation', + #traits : 'FamixTParametricAssociation', + #classTraits : 'FamixTParametricAssociation classTrait', + #category : 'Famix-TypeScript-Entities-Entities', + #package : 'Famix-TypeScript-Entities', + #tag : 'Entities' +} + +{ #category : 'meta' } +FamixTypeScriptParametricImplementation class >> annotation [ + + + + +] diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptParametricInheritance.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricInheritance.class.st new file mode 100644 index 0000000..159daa2 --- /dev/null +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricInheritance.class.st @@ -0,0 +1,29 @@ +" +## Relations +====================== + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `concretizations` | `FamixTParametricAssociation` | `triggeringAssociation` | `FamixTConcretization` | The parameter concretizations associated with this association.| + + + +" +Class { + #name : 'FamixTypeScriptParametricInheritance', + #superclass : 'FamixTypeScriptInheritance', + #traits : 'FamixTParametricAssociation', + #classTraits : 'FamixTParametricAssociation classTrait', + #category : 'Famix-TypeScript-Entities-Entities', + #package : 'Famix-TypeScript-Entities', + #tag : 'Entities' +} + +{ #category : 'meta' } +FamixTypeScriptParametricInheritance class >> annotation [ + + + + +] diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptParametricInvocation.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricInvocation.class.st new file mode 100644 index 0000000..9a42583 --- /dev/null +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricInvocation.class.st @@ -0,0 +1,29 @@ +" +## Relations +====================== + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `concretizations` | `FamixTParametricAssociation` | `triggeringAssociation` | `FamixTConcretization` | The parameter concretizations associated with this association.| + + + +" +Class { + #name : 'FamixTypeScriptParametricInvocation', + #superclass : 'FamixTypeScriptInvocation', + #traits : 'FamixTParametricAssociation', + #classTraits : 'FamixTParametricAssociation classTrait', + #category : 'Famix-TypeScript-Entities-Entities', + #package : 'Famix-TypeScript-Entities', + #tag : 'Entities' +} + +{ #category : 'meta' } +FamixTypeScriptParametricInvocation class >> annotation [ + + + + +] diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptParametricReference.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricReference.class.st new file mode 100644 index 0000000..c7dcccf --- /dev/null +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptParametricReference.class.st @@ -0,0 +1,29 @@ +" +## Relations +====================== + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `concretizations` | `FamixTParametricAssociation` | `triggeringAssociation` | `FamixTConcretization` | The parameter concretizations associated with this association.| + + + +" +Class { + #name : 'FamixTypeScriptParametricReference', + #superclass : 'FamixTypeScriptReference', + #traits : 'FamixTParametricAssociation', + #classTraits : 'FamixTParametricAssociation classTrait', + #category : 'Famix-TypeScript-Entities-Entities', + #package : 'Famix-TypeScript-Entities', + #tag : 'Entities' +} + +{ #category : 'meta' } +FamixTypeScriptParametricReference class >> annotation [ + + + + +] diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st b/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st index 5b3e605..d261f98 100644 --- a/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st @@ -390,6 +390,20 @@ FamixTypeScriptTEntityCreator >> newParametricFunctionNamed: aName [ ^ self add: (FamixTypeScriptParametricFunction named: aName) ] +{ #category : 'entity creation' } +FamixTypeScriptTEntityCreator >> newParametricImplementation [ + + + ^ self add: FamixTypeScriptParametricImplementation new +] + +{ #category : 'entity creation' } +FamixTypeScriptTEntityCreator >> newParametricInheritance [ + + + ^ self add: FamixTypeScriptParametricInheritance new +] + { #category : 'entity creation' } FamixTypeScriptTEntityCreator >> newParametricInterface [ @@ -404,6 +418,13 @@ FamixTypeScriptTEntityCreator >> newParametricInterfaceNamed: aName [ ^ self add: (FamixTypeScriptParametricInterface named: aName) ] +{ #category : 'entity creation' } +FamixTypeScriptTEntityCreator >> newParametricInvocation [ + + + ^ self add: FamixTypeScriptParametricInvocation new +] + { #category : 'entity creation' } FamixTypeScriptTEntityCreator >> newParametricMethod [ @@ -418,6 +439,13 @@ FamixTypeScriptTEntityCreator >> newParametricMethodNamed: aName [ ^ self add: (FamixTypeScriptParametricMethod named: aName) ] +{ #category : 'entity creation' } +FamixTypeScriptTEntityCreator >> newParametricReference [ + + + ^ self add: FamixTypeScriptParametricReference new +] + { #category : 'entity creation' } FamixTypeScriptTEntityCreator >> newPrimitiveType [ diff --git a/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st b/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st index a22d34c..2f9aac6 100644 --- a/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st +++ b/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st @@ -44,11 +44,14 @@ Class { 'parametricClass', 'parametricInterface', 'concretization', - 'parameterConcretization', 'tTypeScriptFunctionMetrics', 'entityTyping', 'parametricEntityTyping', - 'typeParameter' + 'typeParameter', + 'parametricInheritance', + 'parametricImplementation', + 'parametricInvocation', + 'parametricReference' ], #category : 'Famix-TypeScript-Generator', #package : 'Famix-TypeScript-Generator' @@ -214,6 +217,10 @@ FamixTypeScriptGenerator >> defineClasses [ parametricInterface := builder newClassNamed: #ParametricInterface. parameterType := builder newClassNamed: #ParameterType. parametricEntityTyping := builder newClassNamed: #ParametricEntityTyping. + parametricInheritance := self newClassNamed: #ParametricInheritance. + parametricImplementation := self newClassNamed: #ParametricImplementation. + parametricInvocation := self newClassNamed: #ParametricInvocation. + parametricReference := self newClassNamed: #ParametricReference. primitiveType := builder newClassNamed: #PrimitiveType comment: 'I represent a TypeScript primitive type (string, number, boolean).'. reference:= builder newClassNamed: #Reference. scriptEntity :=builder newClassNamed: #ScriptEntity. @@ -418,6 +425,15 @@ FamixTypeScriptGenerator >> defineHierarchy [ parametricEntityTyping --|> entityTyping. parametricEntityTyping --|> #TParametricAssociation. + parametricInheritance --|> inheritance. + parametricInheritance --|> #TParametricAssociation. + parametricImplementation --|> implementation. + parametricImplementation --|> #TParametricAssociation. + parametricInvocation --|> invocation. + parametricInvocation --|> #TParametricAssociation. + parametricReference --|> reference. + parametricReference --|> #TParametricAssociation. + variable --|> structuralEntity. variable --|> #TLocalVariable. From adb4b64e4001f945f5c2b529e65b7db3af38e1f5 Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Thu, 27 Aug 2026 15:49:45 -0400 Subject: [PATCH 2/2] Updated ParameterType to TypeParameter, mapping new moose structure --- .../FamixTypeScriptEntity.class.st | 7 ++ .../FamixTypeScriptImportingContext.class.st | 30 +++---- .../FamixTypeScriptReference.class.st | 26 ++++++ .../FamixTypeScriptTEntityCreator.trait.st | 28 +++---- ... => FamixTypeScriptTypeParameter.class.st} | 82 +++++++++---------- .../FamixTypeScriptParameterType.extension.st | 6 -- .../FamixTypeScriptGenerator.class.st | 14 ++-- .../FamixTypeScriptParametricTest.class.st | 70 ++++++++++------ 8 files changed, 156 insertions(+), 107 deletions(-) rename src/Famix-TypeScript-Entities/{FamixTypeScriptParameterType.class.st => FamixTypeScriptTypeParameter.class.st} (88%) delete mode 100644 src/Famix-TypeScript-Extensions/FamixTypeScriptParameterType.extension.st diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptEntity.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptEntity.class.st index 9c5a604..ec7ffb6 100644 --- a/src/Famix-TypeScript-Entities/FamixTypeScriptEntity.class.st +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptEntity.class.st @@ -183,6 +183,13 @@ FamixTypeScriptEntity >> isQueryable [ ^ false ] +{ #category : 'testing' } +FamixTypeScriptEntity >> isReference [ + + + ^ false +] + { #category : 'testing' } FamixTypeScriptEntity >> isStructuralEntity [ diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st index 9f73c55..6d30026 100644 --- a/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptImportingContext.class.st @@ -208,13 +208,6 @@ FamixTypeScriptImportingContext >> importParameter [ ^ self importConcreteEntity: (self class fm3ClassNamed: #Parameter) ] -{ #category : 'importing' } -FamixTypeScriptImportingContext >> importParameterType [ - - - ^ self importConcreteEntity: (self class fm3ClassNamed: #ParameterType) -] - { #category : 'importing' } FamixTypeScriptImportingContext >> importParametricArrowFunction [ @@ -303,7 +296,7 @@ FamixTypeScriptImportingContext >> importProperty [ FamixTypeScriptImportingContext >> importReference [ - ^ self importConcreteEntity: (self class fm3ClassNamed: #Reference) + ^ self importAssociation: (self class fm3ClassNamed: #Reference) ] { #category : 'importing' } @@ -348,6 +341,13 @@ FamixTypeScriptImportingContext >> importType [ ^ self importConcreteEntity: (self class fm3ClassNamed: #Type) ] +{ #category : 'importing' } +FamixTypeScriptImportingContext >> importTypeParameter [ + + + ^ self importConcreteEntity: (self class fm3ClassNamed: #TypeParameter) +] + { #category : 'importing' } FamixTypeScriptImportingContext >> importVariable [ @@ -551,13 +551,6 @@ FamixTypeScriptImportingContext >> shouldImportParameter [ ^ self shouldImport: #Parameter ] -{ #category : 'testing' } -FamixTypeScriptImportingContext >> shouldImportParameterType [ - - - ^ self shouldImport: #ParameterType -] - { #category : 'testing' } FamixTypeScriptImportingContext >> shouldImportParametricArrowFunction [ @@ -691,6 +684,13 @@ FamixTypeScriptImportingContext >> shouldImportType [ ^ self shouldImport: #Type ] +{ #category : 'testing' } +FamixTypeScriptImportingContext >> shouldImportTypeParameter [ + + + ^ self shouldImport: #TypeParameter +] + { #category : 'testing' } FamixTypeScriptImportingContext >> shouldImportVariable [ diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptReference.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptReference.class.st index f6b8fb9..8cd44bd 100644 --- a/src/Famix-TypeScript-Entities/FamixTypeScriptReference.class.st +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptReference.class.st @@ -1,6 +1,32 @@ +" +## Relations +====================== + +### Association source +| Relation | Origin | Opposite | Type | Comment | +|---| +| `referencer` | `FamixTReference` | `outgoingReferences` | `FamixTWithReferences` | Source entity making the reference. from-side of the association| + +### Association target +| Relation | Origin | Opposite | Type | Comment | +|---| +| `referredEntity` | `FamixTReference` | `incomingReferences` | `FamixTReferenceable` | Target entity referenced. to-side of the association| + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `next` | `FamixTAssociation` | `previous` | `FamixTAssociation` | Next association in an ordered collection of associations. Currently not supported by the Moose importer| +| `previous` | `FamixTAssociation` | `next` | `FamixTAssociation` | Previous association in an ordered collection of associations. Currently not supported by the Moose importer| +| `sourceAnchor` | `FamixTSourceEntity` | `element` | `FamixTSourceAnchor` | SourceAnchor entity linking to the original source code for this entity| + + + +" Class { #name : 'FamixTypeScriptReference', #superclass : 'FamixTypeScriptEntity', + #traits : 'FamixTReference', + #classTraits : 'FamixTReference classTrait', #category : 'Famix-TypeScript-Entities-Entities', #package : 'Famix-TypeScript-Entities', #tag : 'Entities' diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st b/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st index d261f98..6926969 100644 --- a/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptTEntityCreator.trait.st @@ -327,20 +327,6 @@ FamixTypeScriptTEntityCreator >> newParameterNamed: aName [ ^ self add: (FamixTypeScriptParameter named: aName) ] -{ #category : 'entity creation' } -FamixTypeScriptTEntityCreator >> newParameterType [ - - - ^ self add: FamixTypeScriptParameterType new -] - -{ #category : 'entity creation' } -FamixTypeScriptTEntityCreator >> newParameterTypeNamed: aName [ - - - ^ self add: (FamixTypeScriptParameterType named: aName) -] - { #category : 'entity creation' } FamixTypeScriptTEntityCreator >> newParametricArrowFunction [ @@ -551,6 +537,20 @@ FamixTypeScriptTEntityCreator >> newTypeNamed: aName [ ^ self add: (FamixTypeScriptType named: aName) ] +{ #category : 'entity creation' } +FamixTypeScriptTEntityCreator >> newTypeParameter [ + + + ^ self add: FamixTypeScriptTypeParameter new +] + +{ #category : 'entity creation' } +FamixTypeScriptTEntityCreator >> newTypeParameterNamed: aName [ + + + ^ self add: (FamixTypeScriptTypeParameter named: aName) +] + { #category : 'entity creation' } FamixTypeScriptTEntityCreator >> newVariable [ diff --git a/src/Famix-TypeScript-Entities/FamixTypeScriptParameterType.class.st b/src/Famix-TypeScript-Entities/FamixTypeScriptTypeParameter.class.st similarity index 88% rename from src/Famix-TypeScript-Entities/FamixTypeScriptParameterType.class.st rename to src/Famix-TypeScript-Entities/FamixTypeScriptTypeParameter.class.st index 7496db6..c7472ae 100644 --- a/src/Famix-TypeScript-Entities/FamixTypeScriptParameterType.class.st +++ b/src/Famix-TypeScript-Entities/FamixTypeScriptTypeParameter.class.st @@ -1,41 +1,41 @@ -" -## Relations -====================== - -### Outgoing dependencies -| Relation | Origin | Opposite | Type | Comment | -|---| -| `outgoingConcretizations` | `FamixTTypeArgument` | `typeArgument` | `FamixTConcretization` | Concretizations where this type is the type argument.| -| `superInheritances` | `FamixTWithInheritances` | `subclass` | `FamixTInheritance` | Superinheritance relationships, i.e. known superclasses of this type.| - -### Incoming dependencies -| Relation | Origin | Opposite | Type | Comment | -|---| -| `concretizations` | `FamixTTypeParameter` | `typeParameter` | `FamixTConcretization` | Known concretizations of this type parameter.| -| `subInheritances` | `FamixTWithInheritances` | `superclass` | `FamixTInheritance` | Subinheritance relationships, i.e. known subclasses of this type.| - -### Other -| Relation | Origin | Opposite | Type | Comment | -|---| -| `genericEntity` | `FamixTTypeParameter` | `typeParameters` | `FamixTParametricEntity` | Generic entity that declares this type parameter.| - - - -" -Class { - #name : 'FamixTypeScriptParameterType', - #superclass : 'FamixTypeScriptType', - #traits : 'FamixTTypeArgument + FamixTTypeParameter + FamixTWithInheritances', - #classTraits : 'FamixTTypeArgument classTrait + FamixTTypeParameter classTrait + FamixTWithInheritances classTrait', - #category : 'Famix-TypeScript-Entities-Entities', - #package : 'Famix-TypeScript-Entities', - #tag : 'Entities' -} - -{ #category : 'meta' } -FamixTypeScriptParameterType class >> annotation [ - - - - -] +" +## Relations +====================== + +### Outgoing dependencies +| Relation | Origin | Opposite | Type | Comment | +|---| +| `outgoingConcretizations` | `FamixTTypeArgument` | `typeArgument` | `FamixTConcretization` | Concretizations where this type is the type argument.| +| `superInheritances` | `FamixTWithInheritances` | `subclass` | `FamixTInheritance` | Superinheritance relationships, i.e. known superclasses of this type.| + +### Incoming dependencies +| Relation | Origin | Opposite | Type | Comment | +|---| +| `concretizations` | `FamixTTypeParameter` | `typeParameter` | `FamixTConcretization` | Known concretizations of this type parameter.| +| `subInheritances` | `FamixTWithInheritances` | `superclass` | `FamixTInheritance` | Subinheritance relationships, i.e. known subclasses of this type.| + +### Other +| Relation | Origin | Opposite | Type | Comment | +|---| +| `genericEntity` | `FamixTTypeParameter` | `typeParameters` | `FamixTParametricEntity` | Generic entity that declares this type parameter.| + + + +" +Class { + #name : 'FamixTypeScriptTypeParameter', + #superclass : 'FamixTypeScriptType', + #traits : 'FamixTTypeArgument + FamixTTypeParameter + FamixTWithInheritances', + #classTraits : 'FamixTTypeArgument classTrait + FamixTTypeParameter classTrait + FamixTWithInheritances classTrait', + #category : 'Famix-TypeScript-Entities-Entities', + #package : 'Famix-TypeScript-Entities', + #tag : 'Entities' +} + +{ #category : 'meta' } +FamixTypeScriptTypeParameter class >> annotation [ + + + + +] diff --git a/src/Famix-TypeScript-Extensions/FamixTypeScriptParameterType.extension.st b/src/Famix-TypeScript-Extensions/FamixTypeScriptParameterType.extension.st deleted file mode 100644 index 7f836f0..0000000 --- a/src/Famix-TypeScript-Extensions/FamixTypeScriptParameterType.extension.st +++ /dev/null @@ -1,6 +0,0 @@ -Extension { #name : 'FamixTypeScriptParameterType' } - -{ #category : '*Famix-TypeScript-Extensions' } -FamixTypeScriptParameterType >> isParameterType [ - ^ true -] diff --git a/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st b/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st index 2f9aac6..b4cc569 100644 --- a/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st +++ b/src/Famix-TypeScript-Generator/FamixTypeScriptGenerator.class.st @@ -215,7 +215,7 @@ FamixTypeScriptGenerator >> defineClasses [ parameter := builder newClassNamed: #Parameter. parametricClass := builder newClassNamed: #ParametricClass. parametricInterface := builder newClassNamed: #ParametricInterface. - parameterType := builder newClassNamed: #ParameterType. + typeParameter := builder newClassNamed: #TypeParameter. parametricEntityTyping := builder newClassNamed: #ParametricEntityTyping. parametricInheritance := self newClassNamed: #ParametricInheritance. parametricImplementation := self newClassNamed: #ParametricImplementation. @@ -368,10 +368,6 @@ FamixTypeScriptGenerator >> defineHierarchy [ parameter --|> structuralEntity. parameter --|> #TParameter. - - parameterType --|> type. - parameterType --|> #TTypeParameter. - parameterType --|> #TTypeArgument. parametricClass --|> class. "parameterizableClass --|> #TWithParameterizedTypes." @@ -423,6 +419,8 @@ FamixTypeScriptGenerator >> defineHierarchy [ entityTyping --|> #TEntityTyping. + reference --|> #TReference. + parametricEntityTyping --|> entityTyping. parametricEntityTyping --|> #TParametricAssociation. parametricInheritance --|> inheritance. @@ -434,12 +432,14 @@ FamixTypeScriptGenerator >> defineHierarchy [ parametricReference --|> reference. parametricReference --|> #TParametricAssociation. + typeParameter --|> type. + typeParameter --|> #TTypeParameter. + typeParameter --|> #TTypeArgument. + typeParameter --|> #TWithInheritances. variable --|> structuralEntity. variable --|> #TLocalVariable. variable --|> #TImportable. - - parameterType --|> #TWithInheritances. ] { #category : 'definition' } diff --git a/src/Famix-TypeScript-Tests/FamixTypeScriptParametricTest.class.st b/src/Famix-TypeScript-Tests/FamixTypeScriptParametricTest.class.st index ac03f09..1eb297a 100644 --- a/src/Famix-TypeScript-Tests/FamixTypeScriptParametricTest.class.st +++ b/src/Famix-TypeScript-Tests/FamixTypeScriptParametricTest.class.st @@ -16,7 +16,7 @@ Class { FamixTypeScriptParametricTest >> setUp [ super setUp. - self skip. + "self skip." parametricClass := FamixTypeScriptParametricClass new name: 'ParametricClass'. @@ -24,7 +24,7 @@ FamixTypeScriptParametricTest >> setUp [ stringClass := model newClassNamed: 'String'. - listTypeParameter := model newParameterType + listTypeParameter := model newTypeParameter name: 'E'; yourself. genericListClass := model newParametricClass @@ -67,7 +67,7 @@ FamixTypeScriptParametricTest >> test2 [ f := FamixTypeScriptParametricFunction new name: 'genericFunction'. af := FamixTypeScriptParametricArrowFunction new name: 'genericArrowFunction'. p := FamixTypeScriptParameter new name: 't'. - parameterType := FamixTypeScriptParameterType named: 'T'. + parameterType := FamixTypeScriptTypeParameter named: 'T'. p typing: (FamixTypeScriptEntityTyping new declaredType: parameterType). m addParameter: p. f addParameter: p. @@ -109,10 +109,10 @@ FamixTypeScriptParametricTest >> test3 [ classA := model newParametricClass name: 'ClassA'; yourself. - k := model newParameterType + k := model newTypeParameter name: 'K'; yourself. - vFromClassA := model newParameterType + vFromClassA := model newTypeParameter yourself. classA typeParameters: { k. @@ -122,7 +122,7 @@ FamixTypeScriptParametricTest >> test3 [ classB := model newParametricClass name: 'ClassB'; yourself. - vFromClassB := model newParameterType + vFromClassB := model newTypeParameter name: 'V'; yourself. classB addTypeParameter: vFromClassB. @@ -152,18 +152,27 @@ FamixTypeScriptParametricTest >> testConcreteAndGenericParameter [ class ClassB extends ClassA" - | parameter1 parameter2 | - parameter1 := FamixTypeScriptType new name: 'String'. - parameter2 := FamixTypeScriptParameterType new name: 'V'. + | classA classB v | + "ClassA" + classA := model newParametricClass name: 'ClassA'. + v := model newTypeParameter + name: 'V'; + yourself. + classA addTypeParameter: v. - parametricClass concreteParameters: { parameter1 }. - parametricClass genericParameters: { parameter2 }. - self - assertCollection: parametricClass concreteParameters - hasSameElements: { parameter1 }. - self - assertCollection: parametricClass genericParameters - hasSameElements: { parameter2 } + "ClassB" + classB := model newClassNamed: 'ClassB'. + + "Inheritance" + model newParametricInheritance + subclass: classB; + superclass: classA; + addConcretization: (model newConcretization + typeArgument: stringClass; + typeParameter: v). + + self assertCollection: classA typeParameters hasSameElements: { v }. + self deny: classB isParametricEntity ] { #category : 'tests' } @@ -171,14 +180,27 @@ FamixTypeScriptParametricTest >> testConcretizationEntity [ "class List class ClassB extends List" - | listT listString | + | listT listString e pInheritance | listT := FamixTypeScriptParametricClass new name: 'ListT'. listString := FamixTypeScriptParametricClass new name: 'ListString'. - FamixTypeScriptConcretization new - concreteEntity: listString; - genericEntity: listT. + + e := FamixTypeScriptTypeParameter new + name: 'E'; + genericEntity: listT; + yourself. + + pInheritance := FamixTypeScriptParametricInheritance new superclass: listT; + subclass: listString; + addConcretization: (FamixTypeScriptConcretization new + typeParameter: e; + typeArgument: listString). + self - assertCollection: (listT concretizations collect: #concreteEntity) + assertCollection: listT typeParameters + hasSameElements: { e }. + + self + assertCollection: (e concretizations collect: #typeArgument) hasSameElements: { listString } ] @@ -243,8 +265,8 @@ FamixTypeScriptParametricTest >> testInheritanceParameter [ " | supGeneric subGeneric subConcrete | - supGeneric := FamixTypeScriptParameterType new name: 'supGeneric'. - subGeneric := FamixTypeScriptParameterType new name: 'subGeneric'. + supGeneric := FamixTypeScriptTypeParameter new name: 'supGeneric'. + subGeneric := FamixTypeScriptTypeParameter new name: 'subGeneric'. subConcrete := FamixTypeScriptClass new name: 'String'. FamixTypeScriptInheritance new