ts2famix 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyze.js +102 -0
- package/dist/analyze_functions/processAccesses.js +47 -0
- package/dist/analyze_functions/processFiles.js +540 -0
- package/dist/analyze_functions/processImportClauses.js +70 -0
- package/dist/analyze_functions/processInheritances.js +73 -0
- package/dist/analyze_functions/processInvocations.js +49 -0
- package/dist/famix2puml.js +125 -0
- package/dist/famix_functions/famix_functions.js +513 -0
- package/dist/famix_functions/famix_functions_associations.js +205 -0
- package/dist/famix_functions/famix_functions_index.js +62 -0
- package/dist/famix_functions/famix_functions_types.js +110 -0
- package/dist/fqn.js +126 -0
- package/dist/fqp_implementation.js +73 -0
- package/dist/lib/famix/src/famix_JSON_exporter.js +54 -0
- package/dist/lib/famix/src/famix_base_element.js +13 -0
- package/dist/lib/famix/src/famix_repository.js +187 -0
- package/dist/lib/famix/src/index.js +30 -0
- package/dist/lib/famix/src/model/famix/access.js +39 -0
- package/dist/lib/famix/src/model/famix/accessor.js +16 -0
- package/dist/lib/famix/src/model/famix/alias.js +32 -0
- package/dist/lib/famix/src/model/famix/association.js +36 -0
- package/dist/lib/famix/src/model/famix/behavioral_entity.js +81 -0
- package/dist/lib/famix/src/model/famix/c_source_language.js +16 -0
- package/dist/lib/famix/src/model/famix/class.js +70 -0
- package/dist/lib/famix/src/model/famix/comment.js +38 -0
- package/dist/lib/famix/src/model/famix/container_entity.js +125 -0
- package/dist/lib/famix/src/model/famix/custom_source_language.js +23 -0
- package/dist/lib/famix/src/model/famix/decorator.js +31 -0
- package/dist/lib/famix/src/model/famix/entity.js +16 -0
- package/dist/lib/famix/src/model/famix/enum.js +30 -0
- package/dist/lib/famix/src/model/famix/enum_value.js +24 -0
- package/dist/lib/famix/src/model/famix/function.js +16 -0
- package/dist/lib/famix/src/model/famix/implicit_variable.js +16 -0
- package/dist/lib/famix/src/model/famix/import_clause.js +39 -0
- package/dist/lib/famix/src/model/famix/index.js +87 -0
- package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +37 -0
- package/dist/lib/famix/src/model/famix/inheritance.js +32 -0
- package/dist/lib/famix/src/model/famix/interface.js +63 -0
- package/dist/lib/famix/src/model/famix/invocation.js +53 -0
- package/dist/lib/famix/src/model/famix/method.js +66 -0
- package/dist/lib/famix/src/model/famix/module.js +30 -0
- package/dist/lib/famix/src/model/famix/named_entity.js +77 -0
- package/dist/lib/famix/src/model/famix/namespace.js +24 -0
- package/dist/lib/famix/src/model/famix/parameter.js +24 -0
- package/dist/lib/famix/src/model/famix/parameterizable_class.js +30 -0
- package/dist/lib/famix/src/model/famix/parameterizable_interface.js +30 -0
- package/dist/lib/famix/src/model/famix/parameterized_type.js +36 -0
- package/dist/lib/famix/src/model/famix/primitive_type.js +16 -0
- package/dist/lib/famix/src/model/famix/property.js +44 -0
- package/dist/lib/famix/src/model/famix/reference.js +32 -0
- package/dist/lib/famix/src/model/famix/scoping_entity.js +30 -0
- package/dist/lib/famix/src/model/famix/script_entity.js +30 -0
- package/dist/lib/famix/src/model/famix/source_anchor.js +26 -0
- package/dist/lib/famix/src/model/famix/source_language.js +30 -0
- package/dist/lib/famix/src/model/famix/sourced_entity.js +55 -0
- package/dist/lib/famix/src/model/famix/structural_entity.js +38 -0
- package/dist/lib/famix/src/model/famix/text_anchor.js +37 -0
- package/dist/lib/famix/src/model/famix/type.js +71 -0
- package/dist/lib/famix/src/model/famix/type_parameter.js +24 -0
- package/dist/lib/famix/src/model/famix/variable.js +23 -0
- package/dist/lib/ts-complex/cyclomatic-service.js +83 -0
- package/dist/ts2famix-cli.js +51 -0
- package/dist/ts2famix-tsconfig.js +53 -0
- package/doc-uml/.gitkeep +0 -0
- package/docs/.gitkeep +0 -0
- package/jest.config.json +10 -0
- package/package.json +1 -1
- package/tsconfig.json +1 -1
- package/.github/workflows/node.js.yml +0 -60
- package/doc-metamodel/skins.include.puml +0 -2
- package/test/abstractClassWithComments.test.ts +0 -58
- package/test/abstracts.test.ts +0 -53
- package/test/access.test.ts +0 -62
- package/test/accesses.test.ts +0 -42
- package/test/accessorsWithDecorators.test.ts +0 -98
- package/test/alias.test.ts +0 -39
- package/test/classExtendsUndefinedClass.test.ts +0 -41
- package/test/classImplementsUndefinedInterface.test.ts +0 -45
- package/test/classWithDecorators.test.ts +0 -65
- package/test/entities.test.ts +0 -232
- package/test/entities_json.test.ts +0 -48
- package/test/enum.test.ts +0 -55
- package/test/functionReturnsFunction.test.ts +0 -53
- package/test/functionWithParameters.test.ts +0 -38
- package/test/functionWithVariables.test.ts +0 -64
- package/test/functions.test.ts +0 -23
- package/test/functionsInFunction.test.ts +0 -40
- package/test/functionsInMethod.test.ts +0 -42
- package/test/genericClass.test.ts +0 -42
- package/test/genericClassInheritsInterface.test.ts +0 -47
- package/test/genericInterface.test.ts +0 -38
- package/test/genericMethod.test.ts +0 -65
- package/test/genericWithInvocation.test.ts +0 -71
- package/test/generics.test.ts +0 -68
- package/test/inheritance.test.ts +0 -50
- package/test/interfaceInheritsInterface.test.ts +0 -40
- package/test/interfaceInheritsUndefinedInterface.test.ts +0 -41
- package/test/invocation.test.ts +0 -94
- package/test/invocationWithFunction.test.ts +0 -42
- package/test/invocationWithVariable.test.ts +0 -46
- package/test/invocation_json.test.ts +0 -63
- package/test/invocations.test.ts +0 -131
- package/test/jsDoc.test.ts +0 -31
- package/test/methodWithDecorator.test.ts +0 -44
- package/test/methods.test.ts +0 -42
- package/test/metrics.test.ts +0 -51
- package/test/module.test.ts +0 -71
- package/test/namespaces.test.ts +0 -54
- package/test/namespacesAndClasses.test.ts +0 -66
- package/test/parameterWithDecorators.test.ts +0 -54
- package/test/propertyWithDecorators.test.ts +0 -80
- package/test/sample.test.ts +0 -13
- package/test/simpleFunction.test.ts +0 -32
- package/test/simpleTest.test.ts +0 -18
- package/test/simpleTest2.test.ts +0 -36
- package/test/types.test.ts +0 -58
- package/test_src/sample.ts +0 -103
- package/test_src/sampleForModule.ts +0 -10
- package/test_src/sampleForModule2.ts +0 -7
- package/test_src/sampleForModule3.ts +0 -2
- /package/{jest.config.ts → jest.config-old.ts} +0 -0
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Importer } from '../src/analyze';
|
|
2
|
-
import { Decorator } from '../src/lib/famix/src/model/famix/decorator';
|
|
3
|
-
import { Parameter } from '../src/lib/famix/src/model/famix/parameter';
|
|
4
|
-
|
|
5
|
-
const importer = new Importer();
|
|
6
|
-
|
|
7
|
-
const fmxRep = importer.famixRepFromSource("parameterWithDecorators",
|
|
8
|
-
'function deco2(bo: boolean) {\n\
|
|
9
|
-
return function(target: Object, propertyKey: string, parameterIndex: number) {\n\
|
|
10
|
-
console.log(bo);\n\
|
|
11
|
-
};\n\
|
|
12
|
-
}\n\
|
|
13
|
-
\n\
|
|
14
|
-
var tes = deco2(false);\n\
|
|
15
|
-
\n\
|
|
16
|
-
class BugReport2 {\n\
|
|
17
|
-
type = "report";\n\
|
|
18
|
-
title: string;\n\
|
|
19
|
-
\n\
|
|
20
|
-
constructor(t: string) {\n\
|
|
21
|
-
this.title = t;\n\
|
|
22
|
-
}\n\
|
|
23
|
-
\n\
|
|
24
|
-
print(@tes @deco2(true) verbose: boolean) {\n\
|
|
25
|
-
if (verbose) {\n\
|
|
26
|
-
return `type: ${this.type}, title: ${this.title}`;\n\
|
|
27
|
-
}\n\
|
|
28
|
-
else {\n\
|
|
29
|
-
return this.title;\n\
|
|
30
|
-
}\n\
|
|
31
|
-
}\n\
|
|
32
|
-
}\n\
|
|
33
|
-
');
|
|
34
|
-
|
|
35
|
-
describe('Tests for parameter with decorators', () => {
|
|
36
|
-
|
|
37
|
-
it("should contain one class", () => {
|
|
38
|
-
expect(fmxRep._getAllEntitiesWithType("Class").size).toBe(1);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should contain two decorators", () => {
|
|
42
|
-
expect(fmxRep._getAllEntitiesWithType("Decorator").size).toBe(2);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const theParam = (Array.from(fmxRep._getFamixMethod("print")?.getParameters() as Set<Parameter>) as Array<Parameter>).find((f) => f.getName() === "verbose");
|
|
46
|
-
const d1 = (Array.from(fmxRep._getAllEntitiesWithType("Decorator")) as Array<Decorator>).find((d) => d.getName() === "@tes");
|
|
47
|
-
const d2 = (Array.from(fmxRep._getAllEntitiesWithType("Decorator")) as Array<Decorator>).find((d) => d.getName() === "@deco2");
|
|
48
|
-
|
|
49
|
-
it("should contain a parameter with two decorators", () => {
|
|
50
|
-
expect(theParam?.getDecorators().size).toBe(2);
|
|
51
|
-
expect(d1?.getDecoratedEntity()).toBe(theParam);
|
|
52
|
-
expect(d2?.getDecoratedEntity()).toBe(theParam);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Importer } from '../src/analyze';
|
|
2
|
-
import { Decorator } from '../src/lib/famix/src/model/famix/decorator';
|
|
3
|
-
import { Property } from '../src/lib/famix/src/model/famix/property';
|
|
4
|
-
|
|
5
|
-
const importer = new Importer();
|
|
6
|
-
|
|
7
|
-
const fmxRep = importer.famixRepFromSource("propertyWithDecorators",
|
|
8
|
-
'import "reflect-metadata";\n\
|
|
9
|
-
\n\
|
|
10
|
-
const formatMetadataKey = Symbol("format");\n\
|
|
11
|
-
\n\
|
|
12
|
-
function format(formatString: string) {\n\
|
|
13
|
-
return Reflect.metadata(formatMetadataKey, formatString);\n\
|
|
14
|
-
}\n\
|
|
15
|
-
\n\
|
|
16
|
-
function getFormat(target: any, propertyKey: string) {\n\
|
|
17
|
-
return Reflect.getMetadata(formatMetadataKey, target, propertyKey);\n\
|
|
18
|
-
}\n\
|
|
19
|
-
\n\
|
|
20
|
-
function deco(bo: boolean) {\n\
|
|
21
|
-
return function(target: any, propertyKey: string) { // no property descriptor in the signature of the property decorator\n\
|
|
22
|
-
console.log(bo);\n\
|
|
23
|
-
};\n\
|
|
24
|
-
}\n\
|
|
25
|
-
\n\
|
|
26
|
-
var h = format("Hello, %s");\n\
|
|
27
|
-
var o = deco(true);\n\
|
|
28
|
-
var t = deco;\n\
|
|
29
|
-
\n\
|
|
30
|
-
class Greeter {\n\
|
|
31
|
-
@deco(true)\n\
|
|
32
|
-
@h\n\
|
|
33
|
-
@o\n\
|
|
34
|
-
@t(false)\n\
|
|
35
|
-
@format("Hello, %s")\n\
|
|
36
|
-
greeting: string;\n\
|
|
37
|
-
\n\
|
|
38
|
-
constructor(message: string) {\n\
|
|
39
|
-
this.greeting = message;\n\
|
|
40
|
-
}\n\
|
|
41
|
-
\n\
|
|
42
|
-
greet() {\n\
|
|
43
|
-
let formatString = getFormat(this, "greeting");\n\
|
|
44
|
-
return formatString.replace("%s", this.greeting);\n\
|
|
45
|
-
}\n\
|
|
46
|
-
}\n\
|
|
47
|
-
');
|
|
48
|
-
|
|
49
|
-
describe('Tests for property with decorators', () => {
|
|
50
|
-
|
|
51
|
-
it("should contain one class", () => {
|
|
52
|
-
expect(fmxRep._getAllEntitiesWithType("Class").size).toBe(1);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("should contain a property 'greeting'", () => {
|
|
56
|
-
expect(fmxRep._getAllEntitiesWithType("Property").size).toBe(1);
|
|
57
|
-
const theProperty = (Array.from(fmxRep._getFamixClass("Greeter")?.getProperties() as Set<Property>) as Array<Property>).find((f) => f.getName() === "greeting");
|
|
58
|
-
expect(theProperty).toBeTruthy();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should contain five decorators", () => {
|
|
62
|
-
expect(fmxRep._getAllEntitiesWithType("Decorator").size).toBe(5);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const theProperty = (Array.from(fmxRep._getFamixClass("Greeter")?.getProperties() as Set<Property>) as Array<Property>).find((f) => f.getName() === "greeting");
|
|
66
|
-
const d1 = (Array.from(fmxRep._getAllEntitiesWithType("Decorator")) as Array<Decorator>).find((d) => d.getName() === "@deco");
|
|
67
|
-
const d2 = (Array.from(fmxRep._getAllEntitiesWithType("Decorator")) as Array<Decorator>).find((d) => d.getName() === "@h");
|
|
68
|
-
const d3 = (Array.from(fmxRep._getAllEntitiesWithType("Decorator")) as Array<Decorator>).find((d) => d.getName() === "@o");
|
|
69
|
-
const d4 = (Array.from(fmxRep._getAllEntitiesWithType("Decorator")) as Array<Decorator>).find((d) => d.getName() === "@t");
|
|
70
|
-
const d5 = (Array.from(fmxRep._getAllEntitiesWithType("Decorator")) as Array<Decorator>).find((d) => d.getName() === "@format");
|
|
71
|
-
|
|
72
|
-
it("should contain a property with five decorators", () => {
|
|
73
|
-
expect(theProperty?.getDecorators().size).toBe(5);
|
|
74
|
-
expect(d1?.getDecoratedEntity()).toBe(theProperty);
|
|
75
|
-
expect(d2?.getDecoratedEntity()).toBe(theProperty);
|
|
76
|
-
expect(d3?.getDecoratedEntity()).toBe(theProperty);
|
|
77
|
-
expect(d4?.getDecoratedEntity()).toBe(theProperty);
|
|
78
|
-
expect(d5?.getDecoratedEntity()).toBe(theProperty);
|
|
79
|
-
});
|
|
80
|
-
});
|
package/test/sample.test.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Importer } from '../src/analyze';
|
|
2
|
-
|
|
3
|
-
const filePaths = ["test_src/sample.ts"];
|
|
4
|
-
const importer = new Importer();
|
|
5
|
-
|
|
6
|
-
const fmxRep = importer.famixRepFromPaths(filePaths);
|
|
7
|
-
|
|
8
|
-
describe('Tests for sample', () => {
|
|
9
|
-
|
|
10
|
-
it("should parse generics", () => {
|
|
11
|
-
expect(fmxRep).toBeTruthy();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Importer } from '../src/analyze';
|
|
2
|
-
import { Function } from "../src/lib/famix/src/model/famix/function";
|
|
3
|
-
|
|
4
|
-
const importer = new Importer();
|
|
5
|
-
|
|
6
|
-
const fmxRep = importer.famixRepFromSource("simpleFunction",
|
|
7
|
-
'function fct(): number {\n\
|
|
8
|
-
return 0;\n\
|
|
9
|
-
}\n\
|
|
10
|
-
');
|
|
11
|
-
|
|
12
|
-
describe('Tests for simple function', () => {
|
|
13
|
-
|
|
14
|
-
const functionList = fmxRep._getAllEntitiesWithType('Function');
|
|
15
|
-
it("should have one function", () => {
|
|
16
|
-
expect(functionList?.size).toBe(1);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const theFunction = Array.from(functionList)[0] as Function;
|
|
20
|
-
it("should contain a function 'fct'", () => {
|
|
21
|
-
expect(theFunction).toBeTruthy();
|
|
22
|
-
expect(theFunction?.getName()).toBe('fct');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should return number", () => {
|
|
26
|
-
expect(theFunction?.getDeclaredType().getName()).toBe("number");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should have no parameter", () => {
|
|
30
|
-
expect(theFunction?.getParameters().size).toBe(0);
|
|
31
|
-
});
|
|
32
|
-
});
|
package/test/simpleTest.test.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Importer } from '../src/analyze';
|
|
2
|
-
import { ScriptEntity } from '../src/lib/famix/src/model/famix/script_entity';
|
|
3
|
-
|
|
4
|
-
const importer = new Importer();
|
|
5
|
-
|
|
6
|
-
const fmxRep = importer.famixRepFromSource("simpleTest",
|
|
7
|
-
'console.log("Hello");\n\
|
|
8
|
-
');
|
|
9
|
-
|
|
10
|
-
describe('Tests for simple test', () => {
|
|
11
|
-
|
|
12
|
-
const scriptEntityList = Array.from(fmxRep._getAllEntitiesWithType('ScriptEntity')) as Array<ScriptEntity>;
|
|
13
|
-
const theFile = scriptEntityList.find(e => e.getName() === 'simpleTest.ts');
|
|
14
|
-
it("should have one file", () => {
|
|
15
|
-
expect(scriptEntityList?.length).toBe(1);
|
|
16
|
-
expect(theFile).toBeTruthy();
|
|
17
|
-
});
|
|
18
|
-
});
|
package/test/simpleTest2.test.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Importer } from '../src/analyze';
|
|
2
|
-
import { Access } from '../src/lib/famix/src/model/famix/access';
|
|
3
|
-
import { ScriptEntity } from '../src/lib/famix/src/model/famix/script_entity';
|
|
4
|
-
import { Variable } from '../src/lib/famix/src/model/famix/variable';
|
|
5
|
-
|
|
6
|
-
const importer = new Importer();
|
|
7
|
-
|
|
8
|
-
const fmxRep = importer.famixRepFromSource("simpleTest2",
|
|
9
|
-
'var a: number = 10;\n\
|
|
10
|
-
\n\
|
|
11
|
-
console.log(a);\n\
|
|
12
|
-
');
|
|
13
|
-
|
|
14
|
-
describe('Tests for simple test 2', () => {
|
|
15
|
-
|
|
16
|
-
const scriptEntityList = Array.from(fmxRep._getAllEntitiesWithType('ScriptEntity')) as Array<ScriptEntity>;
|
|
17
|
-
const theFile = scriptEntityList.find(e => e.getName() === 'simpleTest2.ts');
|
|
18
|
-
it("should have one file", () => {
|
|
19
|
-
expect(scriptEntityList?.length).toBe(1);
|
|
20
|
-
expect(theFile).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const variableList = Array.from(fmxRep._getAllEntitiesWithType('Variable')) as Array<Variable>;
|
|
24
|
-
const theVariable = variableList.find(e => e.getName() === 'a');
|
|
25
|
-
it("should have one variable", () => {
|
|
26
|
-
expect(scriptEntityList?.length).toBe(1);
|
|
27
|
-
expect(theVariable).toBeTruthy();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const accessList = Array.from(fmxRep._getAllEntitiesWithType('Access')) as Array<Access>;
|
|
31
|
-
const theAccess = accessList.find(e => e.getVariable() === theVariable && e.getAccessor() === theFile);
|
|
32
|
-
it("should have one access", () => {
|
|
33
|
-
expect(accessList?.length).toBe(1);
|
|
34
|
-
expect(theAccess).toBeTruthy();
|
|
35
|
-
});
|
|
36
|
-
});
|
package/test/types.test.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Importer } from '../src/analyze';
|
|
2
|
-
import { ParameterizedType } from '../src/lib/famix/src/model/famix/parameterized_type';
|
|
3
|
-
import { PrimitiveType } from '../src/lib/famix/src/model/famix/primitive_type';
|
|
4
|
-
import { Type } from '../src/lib/famix/src/model/famix/type';
|
|
5
|
-
|
|
6
|
-
const importer = new Importer();
|
|
7
|
-
|
|
8
|
-
const fmxRep = importer.famixRepFromSource("types",
|
|
9
|
-
'let a: string;\n\
|
|
10
|
-
let b: number;\n\
|
|
11
|
-
let c: Map<any, boolean>;\n\
|
|
12
|
-
class A {}\n\
|
|
13
|
-
let d = new A();\n\
|
|
14
|
-
');
|
|
15
|
-
|
|
16
|
-
describe('Tests for types', () => {
|
|
17
|
-
|
|
18
|
-
it("should contain one class", () => {
|
|
19
|
-
expect(fmxRep._getAllEntitiesWithType("Class").size).toBe(1);
|
|
20
|
-
expect(fmxRep._getFamixClass("A")).toBeTruthy();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should contain three types, three primitive types and one parameterized type", () => {
|
|
24
|
-
expect(fmxRep._getAllEntitiesWithType("Type").size).toBe(3);
|
|
25
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("Type") as Set<Type>).find(t => t.getName() === "Map")).toBeTruthy();
|
|
26
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("Type") as Set<Type>).find(t => t.getName() === "any")).toBeTruthy();
|
|
27
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("Type") as Set<Type>).find(t => t.getName() === "A")).toBeTruthy();
|
|
28
|
-
expect(fmxRep._getAllEntitiesWithType("PrimitiveType").size).toBe(3);
|
|
29
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set<PrimitiveType>).find(t => t.getName() === "string")).toBeTruthy();
|
|
30
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set<PrimitiveType>).find(t => t.getName() === "number")).toBeTruthy();
|
|
31
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set<PrimitiveType>).find(t => t.getName() === "boolean")).toBeTruthy();
|
|
32
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set<PrimitiveType>).find(t => t.getName() === "string")?.getIsStub()).toBe(true);
|
|
33
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set<PrimitiveType>).find(t => t.getName() === "number")?.getIsStub()).toBe(true);
|
|
34
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set<PrimitiveType>).find(t => t.getName() === "boolean")?.getIsStub()).toBe(true);
|
|
35
|
-
expect(fmxRep._getAllEntitiesWithType("ParameterizedType").size).toBe(1);
|
|
36
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("ParameterizedType") as Set<ParameterizedType>).find(t => t.getName() === "Map<any, boolean>")).toBeTruthy();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should have types.ts for container", () => {
|
|
40
|
-
const theFile = fmxRep._getFamixFile("types.ts");
|
|
41
|
-
expect(Array.from(fmxRep._getAllEntitiesWithType("Type") as Set<Type>)[0].getContainer()).toBe(theFile);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should have Map for base type of Map<any, boolean>", () => {
|
|
45
|
-
const theBaseType = Array.from(fmxRep._getAllEntitiesWithType("Type") as Set<Type>).find(t => t.getName() === "Map");
|
|
46
|
-
const theParameterizedType = Array.from(fmxRep._getAllEntitiesWithType("ParameterizedType") as Set<ParameterizedType>).find(t => t.getName() === "Map<any, boolean>");
|
|
47
|
-
expect(theParameterizedType?.getBaseType()).toBe(theBaseType);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("should have any and boolean for arguments of Map<any, boolean>", () => {
|
|
51
|
-
const theAnyType = Array.from(fmxRep._getAllEntitiesWithType("Type") as Set<Type>).find(t => t.getName() === "any");
|
|
52
|
-
const theBooleanType = Array.from(fmxRep._getAllEntitiesWithType("PrimitiveType") as Set<PrimitiveType>).find(t => t.getName() === "boolean");
|
|
53
|
-
const theParameterizedType = Array.from(fmxRep._getAllEntitiesWithType("ParameterizedType") as Set<ParameterizedType>).find(t => t.getName() === "Map<any, boolean>");
|
|
54
|
-
expect(theParameterizedType?.getArguments().size).toBe(2);
|
|
55
|
-
expect(Array.from(theParameterizedType?.getArguments() as Set<Type>)[0]).toBe(theAnyType);
|
|
56
|
-
expect(Array.from(theParameterizedType?.getArguments() as Set<Type>)[1]).toBe(theBooleanType);
|
|
57
|
-
});
|
|
58
|
-
});
|
package/test_src/sample.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
var x = "hello";
|
|
2
|
-
|
|
3
|
-
export class ClassA {
|
|
4
|
-
aFred: number;
|
|
5
|
-
aWilma: "green" | "blue" | 12;
|
|
6
|
-
aMethod1(aMethodArg1: string) {
|
|
7
|
-
return aMethodArg1 + "!";
|
|
8
|
-
function fInAMethod() {
|
|
9
|
-
function fInfInAMethod() {
|
|
10
|
-
var w = 0;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
namespace ANamespace {
|
|
17
|
-
var w = 15;
|
|
18
|
-
let x;
|
|
19
|
-
x = w;
|
|
20
|
-
class B {
|
|
21
|
-
bFred: number;
|
|
22
|
-
bWilma: "yellow" | "red";
|
|
23
|
-
bMethod1(bMethodArg1: number) {
|
|
24
|
-
let varInBMethod;
|
|
25
|
-
return bMethodArg1 + 1;
|
|
26
|
-
function fInBMethod() {
|
|
27
|
-
let varInFInBMethod;
|
|
28
|
-
function fInfInBMethod() {
|
|
29
|
-
var w = 0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
let b = new B();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const y = 12.5;
|
|
38
|
-
|
|
39
|
-
function f() {
|
|
40
|
-
var k = 0;
|
|
41
|
-
{ var blockVar = 66; }
|
|
42
|
-
switch (k) {
|
|
43
|
-
case 0:
|
|
44
|
-
var kSwitchCase = 99;
|
|
45
|
-
break;
|
|
46
|
-
default:
|
|
47
|
-
var kSwitchDefault = 90;
|
|
48
|
-
}
|
|
49
|
-
if (true) {
|
|
50
|
-
var ifBlockL = 12;
|
|
51
|
-
}
|
|
52
|
-
let cond = true;
|
|
53
|
-
do {
|
|
54
|
-
var doBlockL = 8;
|
|
55
|
-
cond = false;
|
|
56
|
-
} while (cond);
|
|
57
|
-
try {
|
|
58
|
-
var tryBlockL = 1;
|
|
59
|
-
} catch (error) {
|
|
60
|
-
var catchBlockL = 12;
|
|
61
|
-
}
|
|
62
|
-
while (false) {
|
|
63
|
-
var kWhile = 9;
|
|
64
|
-
}
|
|
65
|
-
let array = [1, 2, 3];
|
|
66
|
-
for (let forIndex = 0; forIndex < array.length; forIndex++) {
|
|
67
|
-
const elementInFor = array[forIndex];
|
|
68
|
-
}
|
|
69
|
-
let object = {};
|
|
70
|
-
for (const key in object) {
|
|
71
|
-
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
72
|
-
const elementInForIn = object[key];
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
for (const iterator of array) {
|
|
76
|
-
let elementInForOf = "blah";
|
|
77
|
-
}
|
|
78
|
-
g();
|
|
79
|
-
|
|
80
|
-
function g() {
|
|
81
|
-
var a_G: string;
|
|
82
|
-
h();
|
|
83
|
-
|
|
84
|
-
function h() {
|
|
85
|
-
var a_H: string;
|
|
86
|
-
i();
|
|
87
|
-
|
|
88
|
-
function i() {
|
|
89
|
-
var a_I: string;
|
|
90
|
-
|
|
91
|
-
console.info("Hello");
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
let tryX = 0;
|
|
95
|
-
} catch (error) {
|
|
96
|
-
let catchY = 15;
|
|
97
|
-
} finally {
|
|
98
|
-
let finallyZ = 99;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as Famix from "../src/lib/famix/src/model/famix";
|
|
2
|
-
import { ClassDeclaration, ConstructorDeclaration } from "ts-morph";
|
|
3
|
-
import { Importer } from "../test_src/sampleForModule";
|
|
4
|
-
import { ClassZ } from "../test_src/sampleForModule";
|
|
5
|
-
import Cls from "../test_src/sampleForModule";
|
|
6
|
-
import { Nsp } from "../test_src/sampleForModule";
|
|
7
|
-
import * as express from "express";
|
|
File without changes
|