ts2famix 2.0.1 → 2.1.0-beta.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 -24
- package/.vscode/settings.json +4 -0
- package/LICENSE +24 -24
- package/README.md +78 -78
- package/TODO +1 -0
- package/arwea-fix.json +1 -0
- package/bogus.ts +3 -0
- package/class-diagram.puml +792 -0
- package/debug.txt +13332 -0
- package/debuglog.txt +12073 -0
- package/dist/analyze.js +2 -2
- package/dist/analyze_functions/process_functions.js +84 -64
- package/dist/famix2puml.js +126 -0
- package/dist/famix_functions/EntityDictionary.js +865 -503
- package/dist/famix_functions/helpers_creation.js +1 -1
- package/dist/fqn.js +44 -11
- package/dist/getClasses-arrow-body.js +43 -0
- package/dist/lib/famix/famix_JSON_exporter.js +1 -1
- package/dist/lib/famix/famix_base_element.js +1 -1
- package/dist/lib/famix/famix_repository.js +57 -2
- package/dist/lib/famix/index.js +1 -1
- package/dist/lib/famix/model/famix/access.js +1 -1
- package/dist/lib/famix/model/famix/accessor.js +1 -1
- package/dist/lib/famix/model/famix/alias.js +1 -1
- package/dist/lib/famix/model/famix/arrow_function.js +1 -1
- package/dist/lib/famix/model/famix/behavioral_entity.js +1 -1
- package/dist/lib/famix/model/famix/class.js +1 -1
- package/dist/lib/famix/model/famix/comment.js +1 -1
- package/dist/lib/famix/model/famix/concretisation.js +1 -1
- package/dist/lib/famix/model/famix/container_entity.js +1 -1
- package/dist/lib/famix/model/famix/decorator.js +1 -1
- package/dist/lib/famix/model/famix/entity.js +1 -1
- package/dist/lib/famix/model/famix/enum.js +1 -1
- package/dist/lib/famix/model/famix/enum_value.js +1 -1
- package/dist/lib/famix/model/famix/function.js +1 -1
- package/dist/lib/famix/model/famix/import_clause.js +1 -1
- package/dist/lib/famix/model/famix/index.js +1 -1
- package/dist/lib/famix/model/famix/indexed_file_anchor.js +1 -1
- package/dist/lib/famix/model/famix/inheritance.js +1 -1
- package/dist/lib/famix/model/famix/interface.js +1 -1
- package/dist/lib/famix/model/famix/invocation.js +1 -1
- package/dist/lib/famix/model/famix/method.js +1 -1
- package/dist/lib/famix/model/famix/module.js +1 -1
- package/dist/lib/famix/model/famix/named_entity.js +1 -1
- package/dist/lib/famix/model/famix/parameter.js +1 -1
- package/dist/lib/famix/model/famix/parameter_concretisation.js +1 -1
- package/dist/lib/famix/model/famix/parameter_type.js +1 -1
- package/dist/lib/famix/model/famix/parametric_arrow_function.js +1 -1
- package/dist/lib/famix/model/famix/parametric_class.js +1 -1
- package/dist/lib/famix/model/famix/parametric_function.js +1 -1
- package/dist/lib/famix/model/famix/parametric_interface.js +1 -1
- package/dist/lib/famix/model/famix/parametric_method.js +1 -1
- package/dist/lib/famix/model/famix/primitive_type.js +1 -1
- package/dist/lib/famix/model/famix/property.js +1 -1
- package/dist/lib/famix/model/famix/reference.js +1 -1
- package/dist/lib/famix/model/famix/scoping_entity.js +1 -1
- package/dist/lib/famix/model/famix/script_entity.js +1 -1
- package/dist/lib/famix/model/famix/source_anchor.js +1 -1
- package/dist/lib/famix/model/famix/source_language.js +1 -1
- package/dist/lib/famix/model/famix/sourced_entity.js +1 -1
- package/dist/lib/famix/model/famix/structural_entity.js +1 -1
- package/dist/lib/famix/model/famix/type.js +1 -1
- package/dist/lib/famix/model/famix/variable.js +1 -1
- package/dist/lib/famix/src/famix_JSON_exporter.js +55 -0
- package/dist/lib/famix/src/famix_base_element.js +18 -0
- package/dist/lib/famix/src/famix_repository.js +224 -0
- package/dist/lib/famix/src/index.js +31 -0
- package/dist/lib/famix/src/model/famix/access.js +40 -0
- package/dist/lib/famix/src/model/famix/accessor.js +17 -0
- package/dist/lib/famix/src/model/famix/alias.js +33 -0
- package/dist/lib/famix/src/model/famix/arrowFunction.js +17 -0
- package/dist/lib/famix/src/model/famix/arrow_function.js +17 -0
- package/dist/lib/famix/src/model/famix/behavioral_entity.js +79 -0
- package/dist/lib/famix/src/model/famix/class.js +71 -0
- package/dist/lib/famix/src/model/famix/comment.js +39 -0
- package/dist/lib/famix/src/model/famix/concretisation.js +31 -0
- package/dist/lib/famix/src/model/famix/container_entity.js +126 -0
- package/dist/lib/famix/src/model/famix/decorator.js +32 -0
- package/dist/lib/famix/src/model/famix/entity.js +17 -0
- package/dist/lib/famix/src/model/famix/enum.js +31 -0
- package/dist/lib/famix/src/model/famix/enum_value.js +25 -0
- package/dist/lib/famix/src/model/famix/function.js +17 -0
- package/dist/lib/famix/src/model/famix/implicit_variable.js +17 -0
- package/dist/lib/famix/src/model/famix/import_clause.js +41 -0
- package/dist/lib/famix/src/model/famix/index.js +86 -0
- package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +38 -0
- package/dist/lib/famix/src/model/famix/inheritance.js +33 -0
- package/dist/lib/famix/src/model/famix/interface.js +64 -0
- package/dist/lib/famix/src/model/famix/invocation.js +54 -0
- package/dist/lib/famix/src/model/famix/method.js +67 -0
- package/dist/lib/famix/src/model/famix/module.js +60 -0
- package/dist/lib/famix/src/model/famix/named_entity.js +78 -0
- package/dist/lib/famix/src/model/famix/parameter.js +25 -0
- package/dist/lib/famix/src/model/famix/parameterConcretisation.js +44 -0
- package/dist/lib/famix/src/model/famix/parameter_concretisation.js +44 -0
- package/dist/lib/famix/src/model/famix/parameter_type.js +45 -0
- package/dist/lib/famix/src/model/famix/parametricArrowFunction.js +29 -0
- package/dist/lib/famix/src/model/famix/parametric_arrow_function.js +31 -0
- package/dist/lib/famix/src/model/famix/parametric_class.js +44 -0
- package/dist/lib/famix/src/model/famix/parametric_function.js +31 -0
- package/dist/lib/famix/src/model/famix/parametric_interface.js +44 -0
- package/dist/lib/famix/src/model/famix/parametric_method.js +31 -0
- package/dist/lib/famix/src/model/famix/primitive_type.js +17 -0
- package/dist/lib/famix/src/model/famix/property.js +73 -0
- package/dist/lib/famix/src/model/famix/reference.js +33 -0
- package/dist/lib/famix/src/model/famix/scoping_entity.js +36 -0
- package/dist/lib/famix/src/model/famix/script_entity.js +29 -0
- package/dist/lib/famix/src/model/famix/source_anchor.js +27 -0
- package/dist/lib/famix/src/model/famix/source_language.js +35 -0
- package/dist/lib/famix/src/model/famix/sourced_entity.js +60 -0
- package/dist/lib/famix/src/model/famix/structural_entity.js +39 -0
- package/dist/lib/famix/src/model/famix/text_anchor.js +38 -0
- package/dist/lib/famix/src/model/famix/type.js +73 -0
- package/dist/lib/famix/src/model/famix/variable.js +24 -0
- package/dist/lib/ts-complex/cyclomatic-service.js +1 -1
- package/dist/refactorer/refactor-getter-setter.js +1 -1
- package/dist/ts2famix-cli-wrapper.js +1 -1
- package/dist/ts2famix-cli.js +1 -1
- package/doc-uml/famix-typescript-model.puml +607 -607
- package/eslint.config.mjs +28 -0
- package/fqn-model.json +1 -0
- package/iterateGenericTypes.ts +69 -0
- package/out/class-diagram/class-diagram.svg +1 -0
- package/package.json +70 -50
- package/sample.json +1 -0
- package/sample.ts +1 -0
- package/src/analyze.ts +120 -120
- package/src/analyze_functions/process_functions.ts +1040 -1019
- package/src/famix_functions/EntityDictionary.ts +2016 -1593
- package/src/famix_functions/helpers_creation.ts +135 -135
- package/src/fqn.ts +50 -16
- package/src/generate_uml.sh +20 -20
- package/src/lib/famix/License.md +22 -22
- package/src/lib/famix/famix_JSON_exporter.ts +56 -56
- package/src/lib/famix/famix_base_element.ts +22 -22
- package/src/lib/famix/famix_repository.ts +278 -243
- package/src/lib/famix/index.ts +8 -8
- package/src/lib/famix/model/famix/access.ts +50 -50
- package/src/lib/famix/model/famix/accessor.ts +15 -15
- package/src/lib/famix/model/famix/alias.ts +39 -39
- package/src/lib/famix/model/famix/arrow_function.ts +15 -15
- package/src/lib/famix/model/famix/behavioral_entity.ts +97 -97
- package/src/lib/famix/model/famix/class.ts +85 -85
- package/src/lib/famix/model/famix/comment.ts +47 -47
- package/src/lib/famix/model/famix/concretisation.ts +40 -40
- package/src/lib/famix/model/famix/container_entity.ts +160 -160
- package/src/lib/famix/model/famix/decorator.ts +37 -37
- package/src/lib/famix/model/famix/entity.ts +15 -15
- package/src/lib/famix/model/famix/enum.ts +30 -30
- package/src/lib/famix/model/famix/enum_value.ts +28 -28
- package/src/lib/famix/model/famix/function.ts +15 -15
- package/src/lib/famix/model/famix/import_clause.ts +51 -51
- package/src/lib/famix/model/famix/index.ts +41 -41
- package/src/lib/famix/model/famix/indexed_file_anchor.ts +46 -46
- package/src/lib/famix/model/famix/inheritance.ts +40 -40
- package/src/lib/famix/model/famix/interface.ts +75 -75
- package/src/lib/famix/model/famix/invocation.ts +65 -65
- package/src/lib/famix/model/famix/method.ts +89 -89
- package/src/lib/famix/model/famix/module.ts +71 -71
- package/src/lib/famix/model/famix/named_entity.ts +95 -95
- package/src/lib/famix/model/famix/parameter.ts +28 -28
- package/src/lib/famix/model/famix/parameter_concretisation.ts +51 -51
- package/src/lib/famix/model/famix/parameter_type.ts +58 -58
- package/src/lib/famix/model/famix/parametric_arrow_function.ts +32 -32
- package/src/lib/famix/model/famix/parametric_class.ts +49 -49
- package/src/lib/famix/model/famix/parametric_function.ts +32 -32
- package/src/lib/famix/model/famix/parametric_interface.ts +49 -49
- package/src/lib/famix/model/famix/parametric_method.ts +32 -32
- package/src/lib/famix/model/famix/primitive_type.ts +15 -15
- package/src/lib/famix/model/famix/property.ts +94 -94
- package/src/lib/famix/model/famix/reference.ts +40 -40
- package/src/lib/famix/model/famix/scoping_entity.ts +35 -35
- package/src/lib/famix/model/famix/script_entity.ts +34 -34
- package/src/lib/famix/model/famix/source_anchor.ts +30 -30
- package/src/lib/famix/model/famix/source_language.ts +35 -35
- package/src/lib/famix/model/famix/sourced_entity.ts +70 -70
- package/src/lib/famix/model/famix/structural_entity.ts +43 -43
- package/src/lib/famix/model/famix/type.ts +87 -87
- package/src/lib/famix/model/famix/variable.ts +27 -27
- package/src/lib/famix/package.json +28 -28
- package/src/lib/ts-complex/cyclomatic-service.ts +83 -83
- package/src/refactorer/refactor-getter-setter.ts +140 -140
- package/src/ts2famix-cli-wrapper.ts +21 -21
- package/src/ts2famix-cli.ts +60 -60
- package/stats.txt +3091 -0
- package/tabby-debug-output.txt +19433 -0
- package/ts2famix.log +22656 -0
- package/tsconfig.check-tests.json +14 -14
- package/tsconfig.json +72 -72
- package/validate-references.js +103 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import pluginJs from "@eslint/js";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
|
|
5
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
6
|
+
export default [
|
|
7
|
+
{ ignores: [ "node_modules", "test_src", "src/lib" ] },
|
|
8
|
+
{
|
|
9
|
+
files: [ "**/*.{js,mjs,cjs,ts}" ],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
globals: {
|
|
12
|
+
...globals.browser,
|
|
13
|
+
...globals.es2021
|
|
14
|
+
},
|
|
15
|
+
parser: tseslint.parser,
|
|
16
|
+
parserOptions: {
|
|
17
|
+
ecmaVersion: "latest",
|
|
18
|
+
sourceType: "module"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
rules: {
|
|
22
|
+
"@typescript-eslint/no-namespace": "off",
|
|
23
|
+
"semi": [ 1, "always" ]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
pluginJs.configs.recommended,
|
|
27
|
+
...tseslint.configs.recommended
|
|
28
|
+
];
|
package/fqn-model.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"FM3":"FamixTypeScript.SourceLanguage","id":1,"sourcedEntities":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":2,"element":{"ref":3},"startPos":1,"endPos":658,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Module","id":3,"sourceAnchor":{"ref":2},"comments":[],"incomingImports":[],"name":"sample.ts","decorators":[],"types":[{"ref":5},{"ref":10},{"ref":14},{"ref":18},{"ref":22},{"ref":26},{"ref":30},{"ref":40},{"ref":44},{"ref":65},{"ref":69},{"ref":73},{"ref":77}],"functions":[{"ref":32},{"ref":42},{"ref":46},{"ref":38},{"ref":48},{"ref":57},{"ref":67},{"ref":75}],"localVariables":[{"ref":12},{"ref":16},{"ref":20},{"ref":24},{"ref":28}],"outgoingImports":[{"ref":83}]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":4,"element":{"ref":5},"startPos":32,"endPos":67,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Class","id":5,"sourceAnchor":{"ref":4},"comments":[],"incomingImports":[],"name":"MyClass","decorators":[],"types":[],"functions":[],"localVariables":[],"incomingReferences":[],"isAbstract":false,"attributes":[],"methods":[{"ref":7}],"superInheritances":[],"subInheritances":[]},{"FM3":"FamixTypeScript.PrimitiveType","id":6,"isStub":true,"comments":[],"incomingImports":[],"name":"void","decorators":[],"types":[],"functions":[],"localVariables":[],"incomingReferences":[]},{"FM3":"FamixTypeScript.Method","id":7,"sourceAnchor":{"ref":8},"comments":[],"incomingImports":[],"name":"myMethod","decorators":[],"cyclomaticComplexity":1,"numberOfStatements":0,"numberOfLinesOfCode":0,"types":[],"functions":[],"localVariables":[],"signature":"myMethod()","parameters":[],"numberOfParameters":0,"incomingInvocations":[{"ref":87}],"declaredType":{"ref":6},"parentType":{"ref":5},"isAbstract":false,"isClassSide":false,"isPrivate":false,"isPublic":true,"isProtected":false},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":8,"element":{"ref":7},"startPos":51,"endPos":64,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":9,"element":{"ref":10},"startPos":75,"endPos":144,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":10,"sourceAnchor":{"ref":9},"comments":[],"incomingImports":[],"name":"() => typeof A","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":11,"element":{"ref":12},"startPos":75,"endPos":144,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Variable","id":12,"sourceAnchor":{"ref":11},"comments":[],"incomingImports":[],"name":"createClassA1","decorators":[],"incomingAccesses":[{"ref":84}],"declaredType":{"ref":10},"parentBehaviouralEntity":{"ref":3}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":13,"element":{"ref":14},"startPos":153,"endPos":222,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":14,"sourceAnchor":{"ref":13},"comments":[],"incomingImports":[],"name":"() => typeof A","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":15,"element":{"ref":16},"startPos":153,"endPos":222,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Variable","id":16,"sourceAnchor":{"ref":15},"comments":[],"incomingImports":[],"name":"createClassA2","decorators":[],"incomingAccesses":[{"ref":85}],"declaredType":{"ref":14},"parentBehaviouralEntity":{"ref":3}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":17,"element":{"ref":18},"startPos":231,"endPos":258,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":18,"sourceAnchor":{"ref":17},"comments":[],"incomingImports":[],"name":"typeof A","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":19,"element":{"ref":20},"startPos":231,"endPos":258,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Variable","id":20,"sourceAnchor":{"ref":19},"comments":[],"incomingImports":[],"name":"instance1","decorators":[],"incomingAccesses":[],"declaredType":{"ref":18},"parentBehaviouralEntity":{"ref":3}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":21,"element":{"ref":22},"startPos":267,"endPos":294,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":22,"sourceAnchor":{"ref":21},"comments":[],"incomingImports":[],"name":"typeof A","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":23,"element":{"ref":24},"startPos":267,"endPos":294,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Variable","id":24,"sourceAnchor":{"ref":23},"comments":[],"incomingImports":[],"name":"instance2","decorators":[],"incomingAccesses":[],"declaredType":{"ref":22},"parentBehaviouralEntity":{"ref":3}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":25,"element":{"ref":26},"startPos":382,"endPos":539,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":26,"sourceAnchor":{"ref":25},"comments":[],"incomingImports":[],"name":"any[]","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":27,"element":{"ref":28},"startPos":382,"endPos":539,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Variable","id":28,"sourceAnchor":{"ref":27},"comments":[],"incomingImports":[],"name":"handlers","decorators":[],"incomingAccesses":[],"declaredType":{"ref":26},"parentBehaviouralEntity":{"ref":3}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":29,"element":{"ref":30},"startPos":299,"endPos":365,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":30,"sourceAnchor":{"ref":29},"comments":[],"incomingImports":[],"name":"() => void","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":31,"element":{"ref":32},"startPos":299,"endPos":365,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Function","id":32,"sourceAnchor":{"ref":31},"comments":[],"incomingImports":[],"name":"a","decorators":[],"cyclomaticComplexity":1,"numberOfStatements":1,"numberOfLinesOfCode":2,"types":[{"ref":34}],"functions":[{"ref":38}],"localVariables":[],"signature":"export function a(c: MyClass)","parameters":[{"ref":36}],"numberOfParameters":1,"incomingInvocations":[],"declaredType":{"ref":30}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":33,"element":{"ref":34},"startPos":317,"endPos":327,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":34,"sourceAnchor":{"ref":33},"comments":[],"incomingImports":[],"name":"MyClass","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":32},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":35,"element":{"ref":36},"startPos":317,"endPos":327,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Parameter","id":36,"sourceAnchor":{"ref":35},"comments":[],"incomingImports":[],"name":"c","decorators":[],"incomingAccesses":[{"ref":86}],"declaredType":{"ref":34},"parentBehaviouralEntity":{"ref":32}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":37,"element":{"ref":38},"startPos":341,"endPos":361,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.ArrowFunction","id":38,"sourceAnchor":{"ref":37},"comments":[],"incomingImports":[],"name":"(NO_NAME)","decorators":[],"numberOfStatements":0,"numberOfLinesOfCode":0,"types":[],"functions":[],"localVariables":[],"signature":"() => void","parameters":[],"numberOfParameters":0,"incomingInvocations":[],"declaredType":{"ref":6}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":39,"element":{"ref":40},"startPos":91,"endPos":144,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":40,"sourceAnchor":{"ref":39},"comments":[],"incomingImports":[],"name":"typeof A","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":41,"element":{"ref":42},"startPos":91,"endPos":144,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.ArrowFunction","id":42,"sourceAnchor":{"ref":41},"comments":[],"incomingImports":[],"name":"createClassA1","decorators":[],"numberOfStatements":1,"numberOfLinesOfCode":4,"types":[],"functions":[],"localVariables":[],"signature":"() => typeof A","parameters":[],"numberOfParameters":0,"incomingInvocations":[],"declaredType":{"ref":40}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":43,"element":{"ref":44},"startPos":169,"endPos":222,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":44,"sourceAnchor":{"ref":43},"comments":[],"incomingImports":[],"name":"typeof A","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":45,"element":{"ref":46},"startPos":169,"endPos":222,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.ArrowFunction","id":46,"sourceAnchor":{"ref":45},"comments":[],"incomingImports":[],"name":"createClassA2","decorators":[],"numberOfStatements":1,"numberOfLinesOfCode":4,"types":[],"functions":[],"localVariables":[],"signature":"() => typeof A","parameters":[],"numberOfParameters":0,"incomingInvocations":[],"declaredType":{"ref":44}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":47,"element":{"ref":48},"startPos":441,"endPos":463,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.ArrowFunction","id":48,"sourceAnchor":{"ref":47},"comments":[],"incomingImports":[],"name":"(NO_NAME)","decorators":[],"numberOfStatements":0,"numberOfLinesOfCode":0,"types":[],"functions":[],"localVariables":[],"signature":"(_req, res, ctx) => void","parameters":[{"ref":51},{"ref":53},{"ref":55}],"numberOfParameters":3,"incomingInvocations":[],"declaredType":{"ref":6}},{"FM3":"FamixTypeScript.PrimitiveType","id":49,"isStub":true,"comments":[],"incomingImports":[],"name":"any","decorators":[],"types":[],"functions":[],"localVariables":[],"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":50,"element":{"ref":51},"startPos":442,"endPos":446,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Parameter","id":51,"sourceAnchor":{"ref":50},"comments":[],"incomingImports":[],"name":"_req","decorators":[],"incomingAccesses":[],"declaredType":{"ref":49},"parentBehaviouralEntity":{"ref":48}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":52,"element":{"ref":53},"startPos":448,"endPos":451,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Parameter","id":53,"sourceAnchor":{"ref":52},"comments":[],"incomingImports":[],"name":"res","decorators":[],"incomingAccesses":[],"declaredType":{"ref":49},"parentBehaviouralEntity":{"ref":48}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":54,"element":{"ref":55},"startPos":453,"endPos":456,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Parameter","id":55,"sourceAnchor":{"ref":54},"comments":[],"incomingImports":[],"name":"ctx","decorators":[],"incomingAccesses":[],"declaredType":{"ref":49},"parentBehaviouralEntity":{"ref":48}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":56,"element":{"ref":57},"startPos":512,"endPos":534,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.ArrowFunction","id":57,"sourceAnchor":{"ref":56},"comments":[],"incomingImports":[],"name":"(NO_NAME)","decorators":[],"numberOfStatements":0,"numberOfLinesOfCode":0,"types":[],"functions":[],"localVariables":[],"signature":"(_req, res, ctx) => void","parameters":[{"ref":59},{"ref":61},{"ref":63}],"numberOfParameters":3,"incomingInvocations":[],"declaredType":{"ref":6}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":58,"element":{"ref":59},"startPos":513,"endPos":517,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Parameter","id":59,"sourceAnchor":{"ref":58},"comments":[],"incomingImports":[],"name":"_req","decorators":[],"incomingAccesses":[],"declaredType":{"ref":49},"parentBehaviouralEntity":{"ref":57}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":60,"element":{"ref":61},"startPos":519,"endPos":522,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Parameter","id":61,"sourceAnchor":{"ref":60},"comments":[],"incomingImports":[],"name":"res","decorators":[],"incomingAccesses":[],"declaredType":{"ref":49},"parentBehaviouralEntity":{"ref":57}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":62,"element":{"ref":63},"startPos":524,"endPos":527,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Parameter","id":63,"sourceAnchor":{"ref":62},"comments":[],"incomingImports":[],"name":"ctx","decorators":[],"incomingAccesses":[],"declaredType":{"ref":49},"parentBehaviouralEntity":{"ref":57}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":64,"element":{"ref":65},"startPos":561,"endPos":596,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":65,"sourceAnchor":{"ref":64},"comments":[],"incomingImports":[],"name":"Promise<void>","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":66,"element":{"ref":67},"startPos":561,"endPos":596,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.ArrowFunction","id":67,"sourceAnchor":{"ref":66},"comments":[],"incomingImports":[],"name":"(NO_NAME)","decorators":[],"numberOfStatements":1,"numberOfLinesOfCode":2,"types":[],"functions":[],"localVariables":[{"ref":71}],"signature":"() => Promise<void>","parameters":[],"numberOfParameters":0,"incomingInvocations":[],"declaredType":{"ref":65}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":68,"element":{"ref":69},"startPos":584,"endPos":592,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":69,"sourceAnchor":{"ref":68},"comments":[],"incomingImports":[],"name":"1","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":70,"element":{"ref":71},"startPos":584,"endPos":592,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Variable","id":71,"sourceAnchor":{"ref":70},"comments":[],"incomingImports":[],"name":"resp","decorators":[],"incomingAccesses":[],"declaredType":{"ref":69},"parentBehaviouralEntity":{"ref":67}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":72,"element":{"ref":73},"startPos":619,"endPos":654,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":73,"sourceAnchor":{"ref":72},"comments":[],"incomingImports":[],"name":"Promise<void>","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":74,"element":{"ref":75},"startPos":619,"endPos":654,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.ArrowFunction","id":75,"sourceAnchor":{"ref":74},"comments":[],"incomingImports":[],"name":"(NO_NAME)","decorators":[],"numberOfStatements":1,"numberOfLinesOfCode":2,"types":[],"functions":[],"localVariables":[{"ref":79}],"signature":"() => Promise<void>","parameters":[],"numberOfParameters":0,"incomingInvocations":[],"declaredType":{"ref":73}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":76,"element":{"ref":77},"startPos":642,"endPos":650,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Type","id":77,"sourceAnchor":{"ref":76},"comments":[],"incomingImports":[],"name":"2","decorators":[],"types":[],"functions":[],"localVariables":[],"typeContainer":{"ref":3},"incomingReferences":[]},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":78,"element":{"ref":79},"startPos":642,"endPos":650,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.Variable","id":79,"sourceAnchor":{"ref":78},"comments":[],"incomingImports":[],"name":"resp","decorators":[],"incomingAccesses":[],"declaredType":{"ref":77},"parentBehaviouralEntity":{"ref":75}},{"FM3":"FamixTypeScript.IndexedFileAnchor","id":80,"element":{"ref":82},"startPos":10,"endPos":14,"fileName":"sample.ts"},{"FM3":"FamixTypeScript.NamedEntity","id":82,"isStub":true,"sourceAnchor":{"ref":80},"comments":[],"incomingImports":[{"ref":83}],"name":"rest","decorators":[]},{"FM3":"FamixTypeScript.ImportClause","id":83,"importingEntity":{"ref":3},"importedEntity":{"ref":82}},{"FM3":"FamixTypeScript.Access","id":84,"accessor":{"ref":3},"variable":{"ref":12}},{"FM3":"FamixTypeScript.Access","id":85,"accessor":{"ref":3},"variable":{"ref":16}},{"FM3":"FamixTypeScript.Access","id":86,"accessor":{"ref":32},"variable":{"ref":36}},{"FM3":"FamixTypeScript.Invocation","id":87,"candidates":[{"ref":7}],"receiver":{"ref":5},"sender":{"ref":32},"signature":"myMethod()"}]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Project, SyntaxKind } from "ts-morph";
|
|
2
|
+
|
|
3
|
+
const project = new Project({
|
|
4
|
+
useInMemoryFileSystem: true,
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
// Example source files in the project
|
|
8
|
+
project.createSourceFile("file1.ts", `
|
|
9
|
+
type MyType<T> = T;
|
|
10
|
+
type Example1 = MyType<AnotherType>;
|
|
11
|
+
class A<T> {
|
|
12
|
+
prop: T;
|
|
13
|
+
}
|
|
14
|
+
class B extends A<AnotherType> {}
|
|
15
|
+
`);
|
|
16
|
+
|
|
17
|
+
project.createSourceFile("file2.ts", `
|
|
18
|
+
type Example2 = MyType<YetAnotherType>;
|
|
19
|
+
`);
|
|
20
|
+
|
|
21
|
+
// Iterate through all source files in the project
|
|
22
|
+
project.getSourceFiles().forEach((sourceFile) => {
|
|
23
|
+
// Get all type aliases in the source file
|
|
24
|
+
const typeAliases = sourceFile.getTypeAliases();
|
|
25
|
+
|
|
26
|
+
typeAliases.forEach((typeAlias) => {
|
|
27
|
+
console.log(`Type alias: ${typeAlias.getName()}`);
|
|
28
|
+
|
|
29
|
+
// Get the type parameters of the alias
|
|
30
|
+
const typeParameters = typeAlias.getTypeParameters();
|
|
31
|
+
if (typeParameters.length > 0) {
|
|
32
|
+
typeParameters.forEach((typeParam) => {
|
|
33
|
+
console.log(`Type alias: ${typeAlias.getName()}, Type parameter: ${typeParam.getName()}`);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Get the type node of the alias
|
|
38
|
+
const typeNode = typeAlias.getTypeNode();
|
|
39
|
+
if (typeNode && typeNode.getKind() === SyntaxKind.TypeReference) {
|
|
40
|
+
const typeReference = typeNode.asKindOrThrow(SyntaxKind.TypeReference);
|
|
41
|
+
|
|
42
|
+
// Get type arguments
|
|
43
|
+
const typeArguments = typeReference.getTypeArguments();
|
|
44
|
+
|
|
45
|
+
// Process type arguments (example: log them)
|
|
46
|
+
typeArguments.forEach((typeArg) => {
|
|
47
|
+
console.log(`Type alias: ${typeAlias.getName()}, Type argument: ${typeArg.getText()}`);
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
// Log type aliases that are not type references
|
|
51
|
+
console.log(`Type alias: ${typeAlias.getName()}, Type: ${typeNode?.getText()}`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Get all classes in the source file
|
|
56
|
+
const classes = sourceFile.getClasses();
|
|
57
|
+
|
|
58
|
+
classes.forEach((classDeclaration) => {
|
|
59
|
+
console.log(`Class: ${classDeclaration.getName()}`);
|
|
60
|
+
|
|
61
|
+
// Get the type parameters of the class
|
|
62
|
+
const typeParameters = classDeclaration.getTypeParameters();
|
|
63
|
+
if (typeParameters.length > 0) {
|
|
64
|
+
typeParameters.forEach((typeParam) => {
|
|
65
|
+
console.log(`Class: ${classDeclaration.getName()}, Type parameter: ${typeParam.getName()}`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|