From 74aeab9f3ce89e98eaa44f03543de338bc9be074 Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Thu, 27 Aug 2026 15:32:14 -0400 Subject: [PATCH 1/7] Replace ParameterType with TypeParameter due to Moose renaming --- src/analyze_functions/process_functions.ts | 4 ++-- src/famix_functions/EntityDictionary.ts | 22 +++++++++---------- .../famix/model/famix/behavioral_entity.ts | 8 +++---- src/lib/famix/model/famix/index.ts | 2 +- .../model/famix/parameter_concretization.ts | 6 ++--- src/lib/famix/model/famix/parametric_class.ts | 8 +++---- .../famix/model/famix/parametric_interface.ts | 8 +++---- .../{parameter_type.ts => type_parameter.ts} | 4 ++-- 8 files changed, 31 insertions(+), 31 deletions(-) rename src/lib/famix/model/famix/{parameter_type.ts => type_parameter.ts} (93%) diff --git a/src/analyze_functions/process_functions.ts b/src/analyze_functions/process_functions.ts index 9d51a587..3f43390e 100644 --- a/src/analyze_functions/process_functions.ts +++ b/src/analyze_functions/process_functions.ts @@ -684,8 +684,8 @@ function processTypeParameters( * @param tp A type parameter * @returns A Famix.TypeParameter representing the type parameter */ -function processTypeParameter(tp: TypeParameterDeclaration): Famix.ParameterType { - const fmxTypeParameter = entityDictionary.createFamixParameterType(tp); +function processTypeParameter(tp: TypeParameterDeclaration): Famix.TypeParameter { + const fmxTypeParameter = entityDictionary.createFamixTypeParameter(tp); logger.debug(`type parameter: ${tp.getName()}, (${tp.getType().getText()}), fqn = ${fmxTypeParameter.fullyQualifiedName}`); processComments(tp, fmxTypeParameter); return fmxTypeParameter; diff --git a/src/famix_functions/EntityDictionary.ts b/src/famix_functions/EntityDictionary.ts index df1bf54a..c2af2acb 100644 --- a/src/famix_functions/EntityDictionary.ts +++ b/src/famix_functions/EntityDictionary.ts @@ -36,7 +36,7 @@ export class EntityDictionary { private fmxInterfaceMap = new Map(); // Maps the interface names to their Famix model private fmxModuleMap = new Map(); // Maps the namespace names to their Famix model private fmxFileMap = new Map(); // Maps the source file names to their Famix model - private fmxTypeMap = new Map(); // Maps the types declarations to their Famix model + private fmxTypeMap = new Map(); // Maps the types declarations to their Famix model private fmxPrimitiveTypeMap = new Map(); // Maps the primitive type names to their Famix model private fmxFunctionAndMethodMap = new Map; // Maps the function names to their Famix model private fmxArrowFunctionMap = new Map; // Maps the function names to their Famix model @@ -744,19 +744,19 @@ export class EntityDictionary { * @param tp A type parameter * @returns The Famix model of the type parameter */ - public createFamixParameterType(tp: TypeParameterDeclaration): Famix.ParameterType { + public createFamixTypeParameter(tp: TypeParameterDeclaration): Famix.TypeParameter { - const fmxParameterType = new Famix.ParameterType(); + const fmxTypeParameter = new Famix.TypeParameter(); - fmxParameterType.name = tp.getName(); - initFQN(tp, fmxParameterType); - this.makeFamixIndexFileAnchor(tp, fmxParameterType); + fmxTypeParameter.name = tp.getName(); + initFQN(tp, fmxTypeParameter); + this.makeFamixIndexFileAnchor(tp, fmxTypeParameter); - this.famixRep.addElement(fmxParameterType); + this.famixRep.addElement(fmxTypeParameter); - this.fmxElementObjectMap.set(fmxParameterType,tp); + this.fmxElementObjectMap.set(fmxTypeParameter,tp); - return fmxParameterType; + return fmxTypeParameter; } @@ -1668,8 +1668,8 @@ export class EntityDictionary { let fmxParameterConcretization : Famix.ParameterConcretization | undefined = undefined; for (let i = 0; i < genericParameters.size; i++) { - const conClassTypeParameter = conClassTypeParametersIterator.next().value as Famix.ParameterType; - const genClassTypeParameter = genClassTypeParametersIterator.next().value as Famix.ParameterType; + const conClassTypeParameter = conClassTypeParametersIterator.next().value as Famix.TypeParameter; + const genClassTypeParameter = genClassTypeParametersIterator.next().value as Famix.TypeParameter; let createParameterConcretization : boolean = true; if(conClassTypeParameter && genClassTypeParameter && conClassTypeParameter.name != genClassTypeParameter.name){ parameterConcretizations.forEach((param : Famix.ParameterConcretization) => { diff --git a/src/lib/famix/model/famix/behavioral_entity.ts b/src/lib/famix/model/famix/behavioral_entity.ts index 3ab1bc80..560152e3 100644 --- a/src/lib/famix/model/famix/behavioral_entity.ts +++ b/src/lib/famix/model/famix/behavioral_entity.ts @@ -2,7 +2,7 @@ import { FamixJSONExporter } from "../../famix_JSON_exporter"; import { ContainerEntity } from "./container_entity"; import { Parameter } from "./parameter"; import { Invocation } from "./invocation"; -import { ParameterType } from "./parameter_type"; +import { TypeParameter } from "./type_parameter"; import { EntityTyping } from "./entity_typing"; export class BehavioralEntity extends ContainerEntity { @@ -28,9 +28,9 @@ export class BehavioralEntity extends ContainerEntity { } private _typing!: EntityTyping; - private _genericParameters: Set = new Set(); + private _genericParameters: Set = new Set(); - public addGenericParameter(genericParameter: ParameterType): void { + public addGenericParameter(genericParameter: TypeParameter): void { if (!this._genericParameters.has(genericParameter)) { this._genericParameters.add(genericParameter); genericParameter.parentGeneric = this; @@ -87,7 +87,7 @@ export class BehavioralEntity extends ContainerEntity { this._typing = typing; } - get genericParameters(): Set { + get genericParameters(): Set { return this._genericParameters; } } diff --git a/src/lib/famix/model/famix/index.ts b/src/lib/famix/model/famix/index.ts index 5b1d0d0b..a2b3aee2 100644 --- a/src/lib/famix/model/famix/index.ts +++ b/src/lib/famix/model/famix/index.ts @@ -20,7 +20,7 @@ export { Invocation } from "./invocation"; export { Method } from "./method"; export { Module } from "./module"; export { NamedEntity } from "./named_entity"; -export { ParameterType } from "./parameter_type"; +export { TypeParameter } from "./type_parameter"; export { Parameter } from "./parameter"; export { ParametricClass } from "./parametric_class"; export { ParametricInterface } from "./parametric_interface"; diff --git a/src/lib/famix/model/famix/parameter_concretization.ts b/src/lib/famix/model/famix/parameter_concretization.ts index fc24b6fb..8d46695b 100644 --- a/src/lib/famix/model/famix/parameter_concretization.ts +++ b/src/lib/famix/model/famix/parameter_concretization.ts @@ -1,12 +1,12 @@ import { FamixJSONExporter } from "../../famix_JSON_exporter"; import { Concretization } from "./concretization"; import { Entity } from "./entity"; -import { ParameterType } from "./parameter_type"; +import { TypeParameter } from "./type_parameter"; import { PrimitiveType } from "./primitive_type"; export class ParameterConcretization extends Entity { - private _genericParameter!: ParameterType; + private _genericParameter!: TypeParameter; private _concreteParameter!: PrimitiveType; private _concretizations: Set = new Set(); @@ -33,7 +33,7 @@ export class ParameterConcretization extends Entity { return this._genericParameter; } - set genericParameter(genericEntity: ParameterType) { + set genericParameter(genericEntity: TypeParameter) { this._genericParameter = genericEntity; } diff --git a/src/lib/famix/model/famix/parametric_class.ts b/src/lib/famix/model/famix/parametric_class.ts index ca532c1f..0c49e574 100644 --- a/src/lib/famix/model/famix/parametric_class.ts +++ b/src/lib/famix/model/famix/parametric_class.ts @@ -1,14 +1,14 @@ import { Interface } from "./interface"; import { FamixJSONExporter } from "../../famix_JSON_exporter"; import { Class } from "./class"; -import { ParameterType } from "./parameter_type"; +import { TypeParameter } from "./type_parameter"; import { PrimitiveType } from "./primitive_type"; export class ParametricClass extends Class { - private _genericParameters: Set = new Set(); + private _genericParameters: Set = new Set(); - public addGenericParameter(genericParameter: ParameterType): void { + public addGenericParameter(genericParameter: TypeParameter): void { if (!this._genericParameters.has(genericParameter)) { this._genericParameters.add(genericParameter); genericParameter.parentGeneric = this; @@ -39,7 +39,7 @@ export class ParametricClass extends Class { exporter.addProperty("concreteParameters", this.concreteParameters); } - get genericParameters(): Set { + get genericParameters(): Set { return this._genericParameters; } diff --git a/src/lib/famix/model/famix/parametric_interface.ts b/src/lib/famix/model/famix/parametric_interface.ts index 9b337e3e..9c562cf2 100644 --- a/src/lib/famix/model/famix/parametric_interface.ts +++ b/src/lib/famix/model/famix/parametric_interface.ts @@ -1,14 +1,14 @@ import { FamixJSONExporter } from "../../famix_JSON_exporter"; import { Class } from "./class"; import { Interface } from "./interface"; -import { ParameterType } from "./parameter_type"; +import { TypeParameter } from "./type_parameter"; import { PrimitiveType } from "./primitive_type"; export class ParametricInterface extends Interface { - private _genericParameters: Set = new Set(); + private _genericParameters: Set = new Set(); - public addGenericParameter(genericParameter: ParameterType): void { + public addGenericParameter(genericParameter: TypeParameter): void { if (!this._genericParameters.has(genericParameter)) { this._genericParameters.add(genericParameter); genericParameter.parentGeneric = this; @@ -39,7 +39,7 @@ export class ParametricInterface extends Interface { exporter.addProperty("concreteParameters", this.concreteParameters); } - get genericParameters(): Set { + get genericParameters(): Set { return this._genericParameters; } diff --git a/src/lib/famix/model/famix/parameter_type.ts b/src/lib/famix/model/famix/type_parameter.ts similarity index 93% rename from src/lib/famix/model/famix/parameter_type.ts rename to src/lib/famix/model/famix/type_parameter.ts index 804bf958..a51a0bc9 100644 --- a/src/lib/famix/model/famix/parameter_type.ts +++ b/src/lib/famix/model/famix/type_parameter.ts @@ -10,7 +10,7 @@ import { ParametricFunction } from "./parametric_function"; import { ArrowFunction } from "./arrow_function"; import { ParametricArrowFunction } from "./parametric_arrow_function"; -export class ParameterType extends Type { +export class TypeParameter extends Type { private _parentGeneric!: ParametricClass | ParametricInterface | Method | ParametricMethod | Accessor | FamixFunction | ParametricFunction | ArrowFunction | ParametricArrowFunction; private _baseType!: Type; @@ -23,7 +23,7 @@ export class ParameterType extends Type { } public getJSON(): string { - const json: FamixJSONExporter = new FamixJSONExporter("ParameterType", this); + const json: FamixJSONExporter = new FamixJSONExporter("TypeParameter", this); this.addPropertiesToExporter(json); return json.getJSON(); } From 0a2be909c798afcbd7bad7ac1d2e1bf5702216c1 Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Thu, 3 Sep 2026 23:28:12 -0400 Subject: [PATCH 2/7] tests updated to reflect new moose rename from parameterType to TypeParameter --- test/genericClass.test.ts | 6 +++--- test/genericInterface.test.ts | 4 ++-- test/generics.test.ts | 6 +++--- test/parametricArrowFunction.test.ts | 6 +++--- test/parametricMethod.test.ts | 8 ++++---- test/types.test.ts | 14 +++++++------- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/test/genericClass.test.ts b/test/genericClass.test.ts index 426a0073..c0f57227 100644 --- a/test/genericClass.test.ts +++ b/test/genericClass.test.ts @@ -1,5 +1,5 @@ import { Importer } from '../src/analyze'; -import { ParametricClass, ParameterType } from '../src/lib/famix/model/famix'; +import { ParametricClass, TypeParameter } from '../src/lib/famix/model/famix'; import { project, exportProjectSourceFilesForEndtoEndPharoTests } from './testUtils'; const importer = new Importer(); @@ -34,8 +34,8 @@ describe('Tests for generic class', () => { expect(MyClass).toBeTruthy(); expect(MyClass?.genericParameters.size).toBe(1); if (MyClass) { - expect((Array.from(MyClass.genericParameters)[0] as ParameterType).name).toBe("T"); - expect((Array.from(MyClass.genericParameters)[0] as ParameterType).parentGeneric).toBe(MyClass); + expect((Array.from(MyClass.genericParameters)[0] as TypeParameter).name).toBe("T"); + expect((Array.from(MyClass.genericParameters)[0] as TypeParameter).parentGeneric).toBe(MyClass); } }); diff --git a/test/genericInterface.test.ts b/test/genericInterface.test.ts index 237a8901..f6669d39 100644 --- a/test/genericInterface.test.ts +++ b/test/genericInterface.test.ts @@ -1,5 +1,5 @@ import { Importer } from '../src/analyze'; -import { ParametricInterface, ParameterType } from '../src/lib/famix/model/famix'; +import { ParametricInterface, TypeParameter } from '../src/lib/famix/model/famix'; import { project, exportProjectSourceFilesForEndtoEndPharoTests } from './testUtils'; const importer = new Importer(); @@ -37,7 +37,7 @@ describe('Tests for generic interface', () => { expect(MyInterface).toBeTruthy(); expect(MyInterface?.genericParameters.size).toBe(1); if (MyInterface) { - expect((Array.from(MyInterface.genericParameters)[0] as ParameterType).name).toBe("T"); + expect((Array.from(MyInterface.genericParameters)[0] as TypeParameter).name).toBe("T"); } }); }); diff --git a/test/generics.test.ts b/test/generics.test.ts index d41bba25..ea5d0f08 100644 --- a/test/generics.test.ts +++ b/test/generics.test.ts @@ -1,5 +1,5 @@ import { Importer } from '../src/analyze'; -import { ParametricClass, ParametricInterface, ParameterType } from '../src/lib/famix/model/famix'; +import { ParametricClass, ParametricInterface, TypeParameter } from '../src/lib/famix/model/famix'; import { project, exportProjectSourceFilesForEndtoEndPharoTests } from './testUtils'; const importer = new Importer(); @@ -39,7 +39,7 @@ describe('Generics', () => { expect(myDao).toBeTruthy(); expect(myDao?.genericParameters.size).toBe(1); if (myDao) { - expect((Array.from(myDao.genericParameters)[0] as ParameterType).name).toBe("T"); + expect((Array.from(myDao.genericParameters)[0] as TypeParameter).name).toBe("T"); } }); @@ -50,7 +50,7 @@ describe('Generics', () => { expect(myDaoInterface).toBeTruthy(); expect(myDaoInterface?.genericParameters.size).toBe(1); if (myDaoInterface) { - expect((Array.from(myDaoInterface.genericParameters)[0] as ParameterType).name).toBe("T"); + expect((Array.from(myDaoInterface.genericParameters)[0] as TypeParameter).name).toBe("T"); } }); diff --git a/test/parametricArrowFunction.test.ts b/test/parametricArrowFunction.test.ts index 1aab5e63..24b35731 100644 --- a/test/parametricArrowFunction.test.ts +++ b/test/parametricArrowFunction.test.ts @@ -1,5 +1,5 @@ import { Importer } from '../src/analyze'; -import { ParameterType, ParametricArrowFunction } from '../src/lib/famix/model/famix'; +import { TypeParameter, ParametricArrowFunction } from '../src/lib/famix/model/famix'; import { project, exportProjectSourceFilesForEndtoEndPharoTests } from './testUtils'; const importer = new Importer(); @@ -42,8 +42,8 @@ describe('ArrowFunctions', () => { }); it("should contain a type parameter T", () => { - const parameterType = theFunction?.genericParameters.values().next().value as ParameterType; - expect(parameterType.name).toBe('T'); + const typeParameter = theFunction?.genericParameters.values().next().value as TypeParameter; + expect(typeParameter.name).toBe('T'); }); }); diff --git a/test/parametricMethod.test.ts b/test/parametricMethod.test.ts index 1ce58309..64475bb0 100644 --- a/test/parametricMethod.test.ts +++ b/test/parametricMethod.test.ts @@ -40,8 +40,8 @@ describe('Tests for generics', () => { const pcList = Array.from(fmxRep._getAllEntitiesWithType("ParametricClass") as Set); expect(pcList).toBeTruthy(); const parametricClass = pcList.find(c => c.name === "ClassParametric"); - const parameterTypes = parametricClass?.genericParameters; - expect(parameterTypes?.values().next().value.name).toBe('T'); + const typeParameters = parametricClass?.genericParameters; + expect(typeParameters?.values().next().value.name).toBe('T'); }); const theClass = fmxRep._getFamixClass("{parametricMethod.ts}.ClassParametric[ClassDeclaration]"); @@ -73,8 +73,8 @@ describe('Tests for generics', () => { const pmList = Array.from(fmxRep._getAllEntitiesWithType("ParametricMethod") as Set); expect(pmList).toBeTruthy(); const parametricMethod = pmList.find(m => m.name === "methodParametric"); - const parameterTypes = parametricMethod?.genericParameters; - expect(parameterTypes?.values().next().value.name).toBe('V'); + const typeParameters = parametricMethod?.genericParameters; + expect(typeParameters?.values().next().value.name).toBe('V'); }); }); diff --git a/test/types.test.ts b/test/types.test.ts index 68dac7b7..e8e2839c 100644 --- a/test/types.test.ts +++ b/test/types.test.ts @@ -1,5 +1,5 @@ import { Importer } from '../src/analyze'; -import { ParameterType } from '../src/lib/famix/model/famix/parameter_type'; +import { TypeParameter } from '../src/lib/famix/model/famix/type_parameter'; import { PrimitiveType } from '../src/lib/famix/model/famix/primitive_type'; import { Type } from '../src/lib/famix/model/famix/type'; import { IndexedFileAnchor } from '../src/lib/famix/model/famix'; @@ -35,8 +35,8 @@ describe('Tests for types', () => { const types = Array.from(fmxRep._getAllEntitiesWithType("Type") as Set); const primitiveTypes = Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set); - const parameterTypes = Array.from(fmxRep._getAllEntitiesWithType("ParameterType") as Set); - const theParameterType = parameterTypes.find(t => t.name === "T"); + const typeParameters = Array.from(fmxRep._getAllEntitiesWithType("TypeParameter") as Set); + const theTypeParameter = typeParameters.find(t => t.name === "T"); const theBaseType = types.find(t => t.name === "Map"); const theFile = fmxRep._getFamixFile("types.ts"); const theAnyType = primitiveTypes.find(t => t.name === "any"); @@ -78,12 +78,12 @@ describe('Tests for types', () => { }); it("should contain a parameterized type 'T' from 'class B'", () => { - expect(parameterTypes.length).toBe(1); - expect(parameterTypes.find(t => t.name === "T")).toBeTruthy(); + expect(typeParameters.length).toBe(1); + expect(typeParameters.find(t => t.name === "T")).toBeTruthy(); }); it("should have B for base type of B", () => { - expect(theParameterType?.baseType).toBe(theBaseType); + expect(theTypeParameter?.baseType).toBe(theBaseType); }); it("should have types.ts for container", () => { @@ -91,7 +91,7 @@ describe('Tests for types', () => { }); it("should have an IndexedFileAnchor with a filename of 'types.ts' for B", () => { - const indexedFileAnchor = theParameterType?.sourceAnchor; + const indexedFileAnchor = theTypeParameter?.sourceAnchor; expect(indexedFileAnchor).toBeTruthy(); expect((indexedFileAnchor as IndexedFileAnchor).fileName.endsWith("types.ts")).toBe(true); }); From 65745314c86bbba975dcca0a01405190c6a0a7bf Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Thu, 10 Sep 2026 12:13:47 -0400 Subject: [PATCH 3/7] Update to 3.3.0 to include Entity Typing --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1768947..af44f834 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ts2famix", - "version": "3.2.0", + "version": "3.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ts2famix", - "version": "3.2.0", + "version": "3.3.0", "license": "MIT", "dependencies": { "grapheme-splitter": "^1.0.4", diff --git a/package.json b/package.json index 9a404c1f..937be53e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts2famix", - "version": "3.2.0", + "version": "3.3.0", "description": "A TypeScript to JSON importer for Moose.", "main": "dist/index.js", "types": "dist/index.d.ts", From 4922015900392b917b4f54bc62fcbac455eb372a Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Fri, 11 Sep 2026 12:36:55 -0400 Subject: [PATCH 4/7] merged sunit tests to importer --- .github/sunit/.properties | 3 + ...ineOfFamixTypeScriptImporterTests.class.st | 36 ++++++++++ .../package.st | 1 + .../AbstractClassWithCommentsTests.class.st | 60 ++++++++++++++++ .../AbstractTests.class.st | 70 +++++++++++++++++++ .../package.st | 1 + .project | 3 + 7 files changed, 174 insertions(+) create mode 100644 .github/sunit/.properties create mode 100644 .github/sunit/BaselineOfFamixTypeScriptImporterTests/BaselineOfFamixTypeScriptImporterTests.class.st create mode 100644 .github/sunit/BaselineOfFamixTypeScriptImporterTests/package.st create mode 100644 .github/sunit/Famix-TypeScript-Importer-Tests/AbstractClassWithCommentsTests.class.st create mode 100644 .github/sunit/Famix-TypeScript-Importer-Tests/AbstractTests.class.st create mode 100644 .github/sunit/Famix-TypeScript-Importer-Tests/package.st create mode 100644 .project diff --git a/.github/sunit/.properties b/.github/sunit/.properties new file mode 100644 index 00000000..ad0471de --- /dev/null +++ b/.github/sunit/.properties @@ -0,0 +1,3 @@ +{ + #format : #tonel +} \ No newline at end of file diff --git a/.github/sunit/BaselineOfFamixTypeScriptImporterTests/BaselineOfFamixTypeScriptImporterTests.class.st b/.github/sunit/BaselineOfFamixTypeScriptImporterTests/BaselineOfFamixTypeScriptImporterTests.class.st new file mode 100644 index 00000000..518853c4 --- /dev/null +++ b/.github/sunit/BaselineOfFamixTypeScriptImporterTests/BaselineOfFamixTypeScriptImporterTests.class.st @@ -0,0 +1,36 @@ +Class { + #name : 'BaselineOfFamixTypeScriptImporterTests', + #superclass : 'BaselineOf', + #category : 'BaselineOfFamixTypeScriptImporterTests', + #package : 'BaselineOfFamixTypeScriptImporterTests' +} + +{ #category : 'baselines' } +BaselineOfFamixTypeScriptImporterTests >> baseline: spec [ + + spec + for: #common + do: [ + self defineDependencies: spec. + self definePackages: spec. + self defineGroups: spec ] +] + +{ #category : 'dependencies' } +BaselineOfFamixTypeScriptImporterTests >> defineDependencies: spec [ + spec + baseline: 'FamixTypeScript' + with: [ spec + repository: 'github://fuhrmanator/FamixTypeScript:master/src' ]. +] + +{ #category : 'groups' } +BaselineOfFamixTypeScriptImporterTests >> defineGroups: spec [ + +] + +{ #category : 'packages' } +BaselineOfFamixTypeScriptImporterTests >> definePackages: spec [ + spec + package: 'Famix-TypeScript-Importer-Tests'. +] diff --git a/.github/sunit/BaselineOfFamixTypeScriptImporterTests/package.st b/.github/sunit/BaselineOfFamixTypeScriptImporterTests/package.st new file mode 100644 index 00000000..ef058c7f --- /dev/null +++ b/.github/sunit/BaselineOfFamixTypeScriptImporterTests/package.st @@ -0,0 +1 @@ +Package { #name : 'BaselineOfFamixTypeScriptImporterTests' } diff --git a/.github/sunit/Famix-TypeScript-Importer-Tests/AbstractClassWithCommentsTests.class.st b/.github/sunit/Famix-TypeScript-Importer-Tests/AbstractClassWithCommentsTests.class.st new file mode 100644 index 00000000..7d47ae00 --- /dev/null +++ b/.github/sunit/Famix-TypeScript-Importer-Tests/AbstractClassWithCommentsTests.class.st @@ -0,0 +1,60 @@ +Class { + #name : 'AbstractClassWithCommentsTests', + #superclass : 'TestCase', + #instVars : [ + 'model', + 'theClass' + ], + #category : 'Famix-TypeScript-Importer-Tests', + #package : 'Famix-TypeScript-Importer-Tests' +} + +{ #category : 'running' } +AbstractClassWithCommentsTests >> setUp [ + | file modelPath candidateClasses | + super setUp. + + modelPath := OSEnvironment current + at: 'MODEL_JSON_PATH' + ifAbsent: [ nil ]. + + file := modelPath asFileReference. + + self assert: file exists description: 'The Json file is missing'. + + file readStreamDo: [ :stream | + model := FamixTypeScriptModel new importFromJSONStream: stream + ]. + + + "Finding the Abstract Class" + candidateClasses := (model allWithSubTypesOf: FamixTypeScriptClass) select: [ :each | + each name = 'MyAbstractClass' ]. + + theClass := candidateClasses + detect: [ :each | + | fileName | + fileName := each sourceAnchor ifNotNil: [ :anchor | + anchor fileName ]. + fileName notNil and: [ + fileName endsWith: + 'src/abstractClassWithComments/abstractClassWithComments.ts' ] ]. +] + +{ #category : 'tests' } +AbstractClassWithCommentsTests >> testClassHasTwoComments [ + + | comments | + self assert: theClass isNotNil. + + comments := theClass comments. + self assert: comments size equals: 2. +] + +{ #category : 'tests' } +AbstractClassWithCommentsTests >> testContainsAbstractClass [ [ + + self assert: theClass isNotNil. + self assert: theClass isAbstract +] +] diff --git a/.github/sunit/Famix-TypeScript-Importer-Tests/AbstractTests.class.st b/.github/sunit/Famix-TypeScript-Importer-Tests/AbstractTests.class.st new file mode 100644 index 00000000..c220fd23 --- /dev/null +++ b/.github/sunit/Famix-TypeScript-Importer-Tests/AbstractTests.class.st @@ -0,0 +1,70 @@ +Class { + #name : 'AbstractTests', + #superclass : 'TestCase', + #instVars : [ + 'model', + 'theClass' + ], + #category : 'Famix-TypeScript-Importer-Tests', + #package : 'Famix-TypeScript-Importer-Tests' +} + +{ #category : 'running' } +AbstractTests >> setUp [ + | file modelPath candidateClasses | + super setUp. + + modelPath := OSEnvironment current + at: 'MODEL_JSON_PATH' + ifAbsent: [ nil ]. + + file := modelPath asFileReference. + + self assert: file exists description: 'The Json file is missing'. + + file readStreamDo: [ :stream | + model := FamixTypeScriptModel new importFromJSONStream: stream + ]. + + + "Finding the Abstract Class" + candidateClasses := (model allWithSubTypesOf: FamixTypeScriptClass) select: [ :each | + each name = 'MyAbstractClass' ]. + + theClass := candidateClasses + detect: [ :each | + | fileName | + fileName := each sourceAnchor ifNotNil: [ :anchor | + anchor fileName ]. + fileName notNil and: [ + fileName endsWith: + 'src/abstracts/abstracts.ts' ] ]. +] + +{ #category : 'tests' } +AbstractTests >> testContainsAbstractClass [ [ + + self assert: theClass isNotNil. + self assert: theClass isAbstract +] +] + +{ #category : 'tests' } +AbstractTests >> testContainsAbstractMethods [ + | abstractMethod1 abstractmethod2 concreteMethod | + + self assert: theClass methods size equals: 3. + + abstractMethod1 := theClass methods detect: [ :each | each name = 'abstractMethod1' ] ifNone: [ nil ]. + abstractmethod2 := theClass methods detect: [ :each | each name = 'abstractMethod2' ] ifNone: [ nil ]. + concreteMethod := theClass methods detect: [ :each | each name = 'concreteMethod' ] ifNone: [ nil ]. + + self assert: abstractMethod1 isNotNil. + self assert: abstractMethod1 isAbstract. + + self assert: abstractmethod2 isNotNil. + self assert: abstractmethod2 isAbstract. + + self assert: concreteMethod isNotNil. + self deny: concreteMethod isAbstract. +] diff --git a/.github/sunit/Famix-TypeScript-Importer-Tests/package.st b/.github/sunit/Famix-TypeScript-Importer-Tests/package.st new file mode 100644 index 00000000..91525a3c --- /dev/null +++ b/.github/sunit/Famix-TypeScript-Importer-Tests/package.st @@ -0,0 +1 @@ +Package { #name : 'Famix-TypeScript-Importer-Tests' } diff --git a/.project b/.project new file mode 100644 index 00000000..e1518461 --- /dev/null +++ b/.project @@ -0,0 +1,3 @@ +{ + 'srcDirectory': '.github/sunit' +} \ No newline at end of file From 167b285e15a8ac0ee46a2d323ffe4fb9533bca2e Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Fri, 11 Sep 2026 12:41:00 -0400 Subject: [PATCH 5/7] removed unnecessary clone of importer tests and using local --- .github/pharo-setup.smalltalk.ston | 2 +- .github/workflows/run-sunit-tests.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pharo-setup.smalltalk.ston b/.github/pharo-setup.smalltalk.ston index 6741f841..36ab98e6 100644 --- a/.github/pharo-setup.smalltalk.ston +++ b/.github/pharo-setup.smalltalk.ston @@ -2,7 +2,7 @@ SmalltalkCISpec { #loading : [ SCIMetacelloLoadSpec { #baseline : 'FamixTypeScriptImporterTests', - #repository : 'github://MTahaCode/FamixTypeScriptImporterTests/master', + #directory : 'tests_sunit', #platforms : [ #pharo ] } ], diff --git a/.github/workflows/run-sunit-tests.yml b/.github/workflows/run-sunit-tests.yml index f34afe6b..df3e829c 100644 --- a/.github/workflows/run-sunit-tests.yml +++ b/.github/workflows/run-sunit-tests.yml @@ -2,9 +2,9 @@ name: Pharo/Moose Tests on: push: - branches: [ master, update-for-moose13, MTahaCode/issue99 ] + branches: [ master, merge-importer-tests ] pull_request: - branches: [ master, update-for-moose13 ] + branches: [ master, merge-importer-tests ] jobs: test: From 23923c892b747be590cd4c516945d49a6d607ff4 Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Fri, 11 Sep 2026 12:48:25 -0400 Subject: [PATCH 6/7] updated wrong path to tests --- .github/pharo-setup.smalltalk.ston | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pharo-setup.smalltalk.ston b/.github/pharo-setup.smalltalk.ston index 36ab98e6..e5ec3993 100644 --- a/.github/pharo-setup.smalltalk.ston +++ b/.github/pharo-setup.smalltalk.ston @@ -2,7 +2,7 @@ SmalltalkCISpec { #loading : [ SCIMetacelloLoadSpec { #baseline : 'FamixTypeScriptImporterTests', - #directory : 'tests_sunit', + #directory : 'sunit', #platforms : [ #pharo ] } ], From 0e2045b9ddbd2acbab55a63403744877a632caab Mon Sep 17 00:00:00 2001 From: MTahaCode Date: Fri, 11 Sep 2026 13:46:42 -0400 Subject: [PATCH 7/7] added developer docs for importer sunit tests --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 506be34e..53cb1c06 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,14 @@ To run the locally built version (not the globally installed one with npm).: npx ts2famix [options] ``` +To import sunit test inside moose: +```smalltalk + Metacello new + baseline: 'FamixTypeScriptImporterTests'; + repository: 'github://fuhrmanator/FamixTypeScriptImporter:master'; + load. + ``` + ## TypeScript Metamodel API documentation (visualization) The following was generated by CI using [tplant](https://github.com/bafolts/tplant), in a similar fashion described [here](https://modularmoose.org/posts/2021-07-19-automatic-metamodel-documentation-generation).