ts2famix 1.0.1
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/.eslintrc.json +24 -0
- package/.github/workflows/node.js.yml +60 -0
- package/LICENSE +23 -0
- package/README.md +111 -0
- package/doc-metamodel/skins.include.puml +2 -0
- package/jest.config.ts +199 -0
- package/package.json +47 -0
- package/src/analyze.ts +90 -0
- package/src/analyze_functions/processAccesses.ts +50 -0
- package/src/analyze_functions/processFiles.ts +656 -0
- package/src/analyze_functions/processImportClauses.ts +77 -0
- package/src/analyze_functions/processInheritances.ts +84 -0
- package/src/analyze_functions/processInvocations.ts +51 -0
- package/src/famix2puml.ts +119 -0
- package/src/famix_functions/famix_functions.ts +552 -0
- package/src/famix_functions/famix_functions_associations.ts +208 -0
- package/src/famix_functions/famix_functions_index.ts +44 -0
- package/src/famix_functions/famix_functions_types.ts +100 -0
- package/src/fqn.ts +127 -0
- package/src/fqp_implementation.ts +66 -0
- package/src/generate_uml.sh +16 -0
- package/src/lib/famix/License.md +23 -0
- package/src/lib/famix/package-lock.json +301 -0
- package/src/lib/famix/package.json +28 -0
- package/src/lib/famix/readme.md +5 -0
- package/src/lib/famix/src/famix_JSON_exporter.ts +56 -0
- package/src/lib/famix/src/famix_base_element.ts +18 -0
- package/src/lib/famix/src/famix_repository.ts +199 -0
- package/src/lib/famix/src/index.ts +8 -0
- package/src/lib/famix/src/model/famix/access.ts +53 -0
- package/src/lib/famix/src/model/famix/accessor.ts +15 -0
- package/src/lib/famix/src/model/famix/alias.ts +41 -0
- package/src/lib/famix/src/model/famix/association.ts +44 -0
- package/src/lib/famix/src/model/famix/behavioral_entity.ts +107 -0
- package/src/lib/famix/src/model/famix/c_source_language.ts +15 -0
- package/src/lib/famix/src/model/famix/class.ts +86 -0
- package/src/lib/famix/src/model/famix/comment.ts +50 -0
- package/src/lib/famix/src/model/famix/container_entity.ts +165 -0
- package/src/lib/famix/src/model/famix/custom_source_language.ts +27 -0
- package/src/lib/famix/src/model/famix/decorator.ts +39 -0
- package/src/lib/famix/src/model/famix/entity.ts +15 -0
- package/src/lib/famix/src/model/famix/enum.ts +31 -0
- package/src/lib/famix/src/model/famix/enum_value.ts +29 -0
- package/src/lib/famix/src/model/famix/function.ts +15 -0
- package/src/lib/famix/src/model/famix/implicit_variable.ts +15 -0
- package/src/lib/famix/src/model/famix/import_clause.ts +53 -0
- package/src/lib/famix/src/model/famix/index.ts +42 -0
- package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +49 -0
- package/src/lib/famix/src/model/famix/inheritance.ts +42 -0
- package/src/lib/famix/src/model/famix/interface.ts +75 -0
- package/src/lib/famix/src/model/famix/invocation.ts +68 -0
- package/src/lib/famix/src/model/famix/method.ts +96 -0
- package/src/lib/famix/src/model/famix/module.ts +31 -0
- package/src/lib/famix/src/model/famix/named_entity.ts +98 -0
- package/src/lib/famix/src/model/famix/namespace.ts +28 -0
- package/src/lib/famix/src/model/famix/parameter.ts +29 -0
- package/src/lib/famix/src/model/famix/parameterizable_class.ts +31 -0
- package/src/lib/famix/src/model/famix/parameterizable_interface.ts +31 -0
- package/src/lib/famix/src/model/famix/parameterized_type.ts +40 -0
- package/src/lib/famix/src/model/famix/primitive_type.ts +15 -0
- package/src/lib/famix/src/model/famix/property.ts +54 -0
- package/src/lib/famix/src/model/famix/reference.ts +42 -0
- package/src/lib/famix/src/model/famix/scoping_entity.ts +31 -0
- package/src/lib/famix/src/model/famix/script_entity.ts +38 -0
- package/src/lib/famix/src/model/famix/source_anchor.ts +31 -0
- package/src/lib/famix/src/model/famix/source_language.ts +31 -0
- package/src/lib/famix/src/model/famix/sourced_entity.ts +70 -0
- package/src/lib/famix/src/model/famix/structural_entity.ts +44 -0
- package/src/lib/famix/src/model/famix/text_anchor.ts +49 -0
- package/src/lib/famix/src/model/famix/type.ts +88 -0
- package/src/lib/famix/src/model/famix/type_parameter.ts +33 -0
- package/src/lib/famix/src/model/famix/variable.ts +28 -0
- package/src/lib/famix/tsconfig.json +27 -0
- package/src/lib/famix/tslint.json +15 -0
- package/src/lib/ts-complex/cyclomatic-service.ts +85 -0
- package/src/ts2famix-cli.ts +26 -0
- package/src/ts2famix-tsconfig.ts +30 -0
- package/test/abstractClassWithComments.test.ts +58 -0
- package/test/abstracts.test.ts +53 -0
- package/test/access.test.ts +62 -0
- package/test/accesses.test.ts +42 -0
- package/test/accessorsWithDecorators.test.ts +98 -0
- package/test/alias.test.ts +39 -0
- package/test/classExtendsUndefinedClass.test.ts +41 -0
- package/test/classImplementsUndefinedInterface.test.ts +45 -0
- package/test/classWithDecorators.test.ts +65 -0
- package/test/entities.test.ts +232 -0
- package/test/entities_json.test.ts +48 -0
- package/test/enum.test.ts +55 -0
- package/test/functionReturnsFunction.test.ts +53 -0
- package/test/functionWithParameters.test.ts +38 -0
- package/test/functionWithVariables.test.ts +64 -0
- package/test/functions.test.ts +23 -0
- package/test/functionsInFunction.test.ts +40 -0
- package/test/functionsInMethod.test.ts +42 -0
- package/test/genericClass.test.ts +42 -0
- package/test/genericClassInheritsInterface.test.ts +47 -0
- package/test/genericInterface.test.ts +38 -0
- package/test/genericMethod.test.ts +65 -0
- package/test/genericWithInvocation.test.ts +71 -0
- package/test/generics.test.ts +68 -0
- package/test/inheritance.test.ts +50 -0
- package/test/interfaceInheritsInterface.test.ts +40 -0
- package/test/interfaceInheritsUndefinedInterface.test.ts +41 -0
- package/test/invocation.test.ts +94 -0
- package/test/invocationWithFunction.test.ts +42 -0
- package/test/invocationWithVariable.test.ts +46 -0
- package/test/invocation_json.test.ts +63 -0
- package/test/invocations.test.ts +131 -0
- package/test/jsDoc.test.ts +31 -0
- package/test/methodWithDecorator.test.ts +44 -0
- package/test/methods.test.ts +42 -0
- package/test/metrics.test.ts +51 -0
- package/test/module.test.ts +71 -0
- package/test/namespaces.test.ts +54 -0
- package/test/namespacesAndClasses.test.ts +66 -0
- package/test/parameterWithDecorators.test.ts +54 -0
- package/test/propertyWithDecorators.test.ts +80 -0
- package/test/sample.test.ts +13 -0
- package/test/simpleFunction.test.ts +32 -0
- package/test/simpleTest.test.ts +18 -0
- package/test/simpleTest2.test.ts +36 -0
- package/test/types.test.ts +58 -0
- package/test_src/sample.ts +103 -0
- package/test_src/sampleForModule.ts +10 -0
- package/test_src/sampleForModule2.ts +7 -0
- package/test_src/sampleForModule3.ts +2 -0
- package/tsconfig.json +70 -0
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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";
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Basic Options */
|
|
4
|
+
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
|
5
|
+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
6
|
+
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
7
|
+
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
8
|
+
// "checkJs": true, /* Report errors in .js files. */
|
|
9
|
+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
10
|
+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
11
|
+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
12
|
+
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
13
|
+
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
14
|
+
"outDir": "./dist", /* Redirect output structure to the directory. */
|
|
15
|
+
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
16
|
+
// "composite": true, /* Enable project compilation */
|
|
17
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
18
|
+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
19
|
+
// "removeComments": true, /* Do not emit comments to output. */
|
|
20
|
+
// "noEmit": true, /* Do not emit outputs. */
|
|
21
|
+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
22
|
+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
23
|
+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
24
|
+
|
|
25
|
+
/* Strict Type-Checking Options */
|
|
26
|
+
"strict": false, /* Enable all strict type-checking options. */
|
|
27
|
+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
28
|
+
// "strictNullChecks": true, /* Enable strict null checks. */
|
|
29
|
+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
30
|
+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
31
|
+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
32
|
+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
33
|
+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
34
|
+
|
|
35
|
+
/* Additional Checks */
|
|
36
|
+
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
|
37
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
38
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
39
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
40
|
+
|
|
41
|
+
/* Module Resolution Options */
|
|
42
|
+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
43
|
+
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
44
|
+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
45
|
+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
46
|
+
// "typeRoots": [], /* List of folders to include type definitions from. */
|
|
47
|
+
// "types": [], /* Type declaration files to be included in compilation. */
|
|
48
|
+
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
49
|
+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
50
|
+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
51
|
+
|
|
52
|
+
/* Source Map Options */
|
|
53
|
+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
54
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
55
|
+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
56
|
+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
57
|
+
|
|
58
|
+
/* Experimental Options */
|
|
59
|
+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
60
|
+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
61
|
+
},
|
|
62
|
+
"include": ["src"],
|
|
63
|
+
"exclude": ["node_modules", "**/*.spec.ts"],
|
|
64
|
+
"typedocOptions": {
|
|
65
|
+
"entryPoints": ["src/*"],
|
|
66
|
+
"entryPointStrategy": "expand",
|
|
67
|
+
"out": "docs",
|
|
68
|
+
"githubPages": false
|
|
69
|
+
}
|
|
70
|
+
}
|