@proteinjs/reflection-build 1.0.2 → 1.0.4
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/CHANGELOG.md +16 -0
- package/dist/modules/typescript-parser/.appveyor.yml +22 -0
- package/dist/modules/typescript-parser/DeclarationIndex.d.ts +217 -0
- package/dist/modules/typescript-parser/DeclarationIndex.js +441 -0
- package/dist/modules/typescript-parser/LICENSE +21 -0
- package/dist/modules/typescript-parser/Node.d.ts +23 -0
- package/dist/modules/typescript-parser/Node.js +2 -0
- package/dist/modules/typescript-parser/README.md +51 -0
- package/dist/modules/typescript-parser/SymbolSpecifier.d.ts +22 -0
- package/dist/modules/typescript-parser/SymbolSpecifier.js +28 -0
- package/dist/modules/typescript-parser/TypescriptParser.d.ts +68 -0
- package/dist/modules/typescript-parser/TypescriptParser.js +191 -0
- package/dist/modules/typescript-parser/clonable/Clonable.d.ts +17 -0
- package/dist/modules/typescript-parser/clonable/Clonable.js +2 -0
- package/dist/modules/typescript-parser/code-generators/TypescriptCodeGenerator.d.ts +39 -0
- package/dist/modules/typescript-parser/code-generators/TypescriptCodeGenerator.js +66 -0
- package/dist/modules/typescript-parser/code-generators/TypescriptGenerationOptions.d.ts +69 -0
- package/dist/modules/typescript-parser/code-generators/TypescriptGenerationOptions.js +9 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/accessorDeclaration.d.ts +11 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/accessorDeclaration.js +34 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/externalModuleImport.d.ts +11 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/externalModuleImport.js +15 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/methodDeclaration.d.ts +11 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/methodDeclaration.js +23 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/namedImport.d.ts +11 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/namedImport.js +94 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/namespaceImport.d.ts +11 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/namespaceImport.js +15 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/parameterDeclaration.d.ts +9 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/parameterDeclaration.js +14 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/propertyDeclaration.d.ts +11 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/propertyDeclaration.js +18 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/stringImport.d.ts +11 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/stringImport.js +15 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/symbolSpecifier.d.ts +9 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/symbolSpecifier.js +14 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/variableDeclaration.d.ts +9 -0
- package/dist/modules/typescript-parser/code-generators/typescript-generators/variableDeclaration.js +14 -0
- package/dist/modules/typescript-parser/declarations/AccessorDeclaration.d.ts +40 -0
- package/dist/modules/typescript-parser/declarations/AccessorDeclaration.js +45 -0
- package/dist/modules/typescript-parser/declarations/ClassDeclaration.d.ts +34 -0
- package/dist/modules/typescript-parser/declarations/ClassDeclaration.js +26 -0
- package/dist/modules/typescript-parser/declarations/ConstructorDeclaration.d.ts +18 -0
- package/dist/modules/typescript-parser/declarations/ConstructorDeclaration.js +20 -0
- package/dist/modules/typescript-parser/declarations/Declaration.d.ts +215 -0
- package/dist/modules/typescript-parser/declarations/Declaration.js +2 -0
- package/dist/modules/typescript-parser/declarations/DeclarationInfo.d.ts +13 -0
- package/dist/modules/typescript-parser/declarations/DeclarationInfo.js +17 -0
- package/dist/modules/typescript-parser/declarations/DeclarationVisibility.d.ts +18 -0
- package/dist/modules/typescript-parser/declarations/DeclarationVisibility.js +22 -0
- package/dist/modules/typescript-parser/declarations/DefaultDeclaration.d.ts +21 -0
- package/dist/modules/typescript-parser/declarations/DefaultDeclaration.js +28 -0
- package/dist/modules/typescript-parser/declarations/EnumDeclaration.d.ts +16 -0
- package/dist/modules/typescript-parser/declarations/EnumDeclaration.js +20 -0
- package/dist/modules/typescript-parser/declarations/FunctionDeclaration.d.ts +23 -0
- package/dist/modules/typescript-parser/declarations/FunctionDeclaration.js +25 -0
- package/dist/modules/typescript-parser/declarations/InterfaceDeclaration.d.ts +27 -0
- package/dist/modules/typescript-parser/declarations/InterfaceDeclaration.js +24 -0
- package/dist/modules/typescript-parser/declarations/MethodDeclaration.d.ts +28 -0
- package/dist/modules/typescript-parser/declarations/MethodDeclaration.js +29 -0
- package/dist/modules/typescript-parser/declarations/ModuleDeclaration.d.ts +15 -0
- package/dist/modules/typescript-parser/declarations/ModuleDeclaration.js +19 -0
- package/dist/modules/typescript-parser/declarations/ParameterDeclaration.d.ts +33 -0
- package/dist/modules/typescript-parser/declarations/ParameterDeclaration.js +54 -0
- package/dist/modules/typescript-parser/declarations/PropertyDeclaration.d.ts +20 -0
- package/dist/modules/typescript-parser/declarations/PropertyDeclaration.js +23 -0
- package/dist/modules/typescript-parser/declarations/TypeAliasDeclaration.d.ts +19 -0
- package/dist/modules/typescript-parser/declarations/TypeAliasDeclaration.js +22 -0
- package/dist/modules/typescript-parser/declarations/VariableDeclaration.d.ts +19 -0
- package/dist/modules/typescript-parser/declarations/VariableDeclaration.js +22 -0
- package/dist/modules/typescript-parser/declarations/index.d.ts +16 -0
- package/dist/modules/typescript-parser/declarations/index.js +19 -0
- package/dist/modules/typescript-parser/errors/NotGeneratableYetError.d.ts +11 -0
- package/dist/modules/typescript-parser/errors/NotGeneratableYetError.js +17 -0
- package/dist/modules/typescript-parser/exports/AllExport.d.ts +14 -0
- package/dist/modules/typescript-parser/exports/AllExport.js +18 -0
- package/dist/modules/typescript-parser/exports/AssignedExport.d.ts +26 -0
- package/dist/modules/typescript-parser/exports/AssignedExport.js +38 -0
- package/dist/modules/typescript-parser/exports/Export.d.ts +10 -0
- package/dist/modules/typescript-parser/exports/Export.js +2 -0
- package/dist/modules/typescript-parser/exports/NamedExport.d.ts +16 -0
- package/dist/modules/typescript-parser/exports/NamedExport.js +18 -0
- package/dist/modules/typescript-parser/exports/index.d.ts +4 -0
- package/dist/modules/typescript-parser/exports/index.js +7 -0
- package/dist/modules/typescript-parser/imports/ExternalModuleImport.d.ts +25 -0
- package/dist/modules/typescript-parser/imports/ExternalModuleImport.js +33 -0
- package/dist/modules/typescript-parser/imports/Import.d.ts +43 -0
- package/dist/modules/typescript-parser/imports/Import.js +2 -0
- package/dist/modules/typescript-parser/imports/NamedImport.d.ts +29 -0
- package/dist/modules/typescript-parser/imports/NamedImport.js +38 -0
- package/dist/modules/typescript-parser/imports/NamespaceImport.d.ts +24 -0
- package/dist/modules/typescript-parser/imports/NamespaceImport.js +32 -0
- package/dist/modules/typescript-parser/imports/StringImport.d.ts +23 -0
- package/dist/modules/typescript-parser/imports/StringImport.js +31 -0
- package/dist/modules/typescript-parser/imports/index.d.ts +5 -0
- package/dist/modules/typescript-parser/imports/index.js +8 -0
- package/dist/modules/typescript-parser/index.d.ts +12 -0
- package/dist/modules/typescript-parser/index.js +14 -0
- package/dist/modules/typescript-parser/node-parser/changes/parseType.d.ts +14 -0
- package/dist/modules/typescript-parser/node-parser/changes/parseType.js +35 -0
- package/dist/modules/typescript-parser/node-parser/class-parser.d.ts +30 -0
- package/dist/modules/typescript-parser/node-parser/class-parser.js +143 -0
- package/dist/modules/typescript-parser/node-parser/enum-parser.d.ts +10 -0
- package/dist/modules/typescript-parser/node-parser/enum-parser.js +18 -0
- package/dist/modules/typescript-parser/node-parser/export-parser.d.ts +10 -0
- package/dist/modules/typescript-parser/node-parser/export-parser.js +58 -0
- package/dist/modules/typescript-parser/node-parser/function-parser.d.ts +33 -0
- package/dist/modules/typescript-parser/node-parser/function-parser.js +101 -0
- package/dist/modules/typescript-parser/node-parser/identifier-parser.d.ts +10 -0
- package/dist/modules/typescript-parser/node-parser/identifier-parser.js +81 -0
- package/dist/modules/typescript-parser/node-parser/import-parser.d.ts +10 -0
- package/dist/modules/typescript-parser/node-parser/import-parser.js +54 -0
- package/dist/modules/typescript-parser/node-parser/index.d.ts +0 -0
- package/dist/modules/typescript-parser/node-parser/index.js +11 -0
- package/dist/modules/typescript-parser/node-parser/interface-parser.d.ts +11 -0
- package/dist/modules/typescript-parser/node-parser/interface-parser.js +57 -0
- package/dist/modules/typescript-parser/node-parser/module-parser.d.ts +12 -0
- package/dist/modules/typescript-parser/node-parser/module-parser.js +23 -0
- package/dist/modules/typescript-parser/node-parser/parse-utilities.d.ts +55 -0
- package/dist/modules/typescript-parser/node-parser/parse-utilities.js +96 -0
- package/dist/modules/typescript-parser/node-parser/traverse-ast.d.ts +1 -0
- package/dist/modules/typescript-parser/node-parser/traverse-ast.js +14 -0
- package/dist/modules/typescript-parser/node-parser/type-alias-parser.d.ts +10 -0
- package/dist/modules/typescript-parser/node-parser/type-alias-parser.js +20 -0
- package/dist/modules/typescript-parser/node-parser/variable-parser.d.ts +11 -0
- package/dist/modules/typescript-parser/node-parser/variable-parser.js +30 -0
- package/dist/modules/typescript-parser/package-lock.json +16793 -0
- package/dist/modules/typescript-parser/package.json +55 -0
- package/dist/modules/typescript-parser/resources/File.d.ts +45 -0
- package/dist/modules/typescript-parser/resources/File.js +58 -0
- package/dist/modules/typescript-parser/resources/Module.d.ts +35 -0
- package/dist/modules/typescript-parser/resources/Module.js +50 -0
- package/dist/modules/typescript-parser/resources/Namespace.d.ts +35 -0
- package/dist/modules/typescript-parser/resources/Namespace.js +50 -0
- package/dist/modules/typescript-parser/resources/Resource.d.ts +64 -0
- package/dist/modules/typescript-parser/resources/Resource.js +2 -0
- package/dist/modules/typescript-parser/resources/index.d.ts +4 -0
- package/dist/modules/typescript-parser/resources/index.js +7 -0
- package/dist/modules/typescript-parser/type-guards/TypescriptGuards.d.ts +153 -0
- package/dist/modules/typescript-parser/type-guards/TypescriptGuards.js +213 -0
- package/dist/modules/typescript-parser/type-guards/TypescriptHeroGuards.d.ts +26 -0
- package/dist/modules/typescript-parser/type-guards/TypescriptHeroGuards.js +36 -0
- package/dist/modules/typescript-parser/utilities/PathHelpers.d.ts +22 -0
- package/dist/modules/typescript-parser/utilities/PathHelpers.js +42 -0
- package/dist/modules/typescript-parser/utilities/StringTemplate.d.ts +9 -0
- package/dist/modules/typescript-parser/utilities/StringTemplate.js +21 -0
- package/dist/src/tsconfigTemplate.json +18 -0
- package/package.json +3 -3
- package/tsconfig.json +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "typescript-parser",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Parser for typescript (and javascript) files, that compiles those files and generates a human understandable AST.",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"typings": "index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "npm run clean && tsc -p ./config/tsconfig.build.json",
|
|
10
|
+
"clean": "del-cli ./build ./coverage",
|
|
11
|
+
"develop": "npm run clean && tsc -p .",
|
|
12
|
+
"lint": "tslint -c ./tslint.json -p ./config/tsconfig.build.json 'src/**/*.ts'",
|
|
13
|
+
"test": "npm run lint && npm run clean && jest -c ./jest.json",
|
|
14
|
+
"test:watch": "npm run clean && jest -c ./jest.json --watch --no-coverage",
|
|
15
|
+
"typedoc": "del-cli ./docs && typedoc --ignoreCompilerErrors --out ./docs --mode file --tsconfig ./config/tsconfig.build.json ./src/",
|
|
16
|
+
"semantic-release": "semantic-release"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/TypeScript-Heroes/node-typescript-parser.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"typescript",
|
|
24
|
+
"parser",
|
|
25
|
+
"AST",
|
|
26
|
+
"parsing"
|
|
27
|
+
],
|
|
28
|
+
"author": "Christoph Bühler <christoph.buehler@bluewin.ch>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/TypeScript-Heroes/node-typescript-parser/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/TypeScript-Heroes/node-typescript-parser#readme",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@smartive/tslint-config": "^4.0.0",
|
|
36
|
+
"@types/jest": "^23.3.1",
|
|
37
|
+
"@types/lodash-es": "^4.17.1",
|
|
38
|
+
"@types/mock-fs": "^3.6.30",
|
|
39
|
+
"@types/node": "^10.9.4",
|
|
40
|
+
"del-cli": "^1.1.0",
|
|
41
|
+
"jest": "^23.5.0",
|
|
42
|
+
"mock-fs": "^4.6.0",
|
|
43
|
+
"semantic-release": "^15.9.12",
|
|
44
|
+
"ts-jest": "^23.1.4",
|
|
45
|
+
"tslint": "^5.11.0",
|
|
46
|
+
"tsutils": "^3.0.0",
|
|
47
|
+
"typedoc": "^0.12.0"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"lodash": "^4.17.10",
|
|
51
|
+
"lodash-es": "^4.17.10",
|
|
52
|
+
"tslib": "^1.9.3",
|
|
53
|
+
"typescript": "^3.0.3"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ParsedPath } from 'path';
|
|
3
|
+
import { Declaration } from '../declarations/Declaration';
|
|
4
|
+
import { Export } from '../exports/Export';
|
|
5
|
+
import { Import } from '../imports/Import';
|
|
6
|
+
import { Node } from '../Node';
|
|
7
|
+
import { Resource } from './Resource';
|
|
8
|
+
/**
|
|
9
|
+
* TypeScript resource. Basically a file that is located somewhere.
|
|
10
|
+
*
|
|
11
|
+
* @export
|
|
12
|
+
* @class File
|
|
13
|
+
* @implements {Resource}
|
|
14
|
+
* @implements {Node}
|
|
15
|
+
*/
|
|
16
|
+
export declare class File implements Resource, Node {
|
|
17
|
+
filePath: string;
|
|
18
|
+
private rootPath;
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
imports: Import[];
|
|
22
|
+
exports: Export[];
|
|
23
|
+
declarations: Declaration[];
|
|
24
|
+
resources: Resource[];
|
|
25
|
+
usages: string[];
|
|
26
|
+
get identifier(): string;
|
|
27
|
+
get nonLocalUsages(): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Returns the parsed path of a resource.
|
|
30
|
+
*
|
|
31
|
+
* @readonly
|
|
32
|
+
* @type {ParsedPath}
|
|
33
|
+
* @memberof File
|
|
34
|
+
*/
|
|
35
|
+
get parsedPath(): ParsedPath;
|
|
36
|
+
/**
|
|
37
|
+
* Determines if a file is a workspace file or an external resource.
|
|
38
|
+
*
|
|
39
|
+
* @readonly
|
|
40
|
+
* @type {boolean}
|
|
41
|
+
* @memberof File
|
|
42
|
+
*/
|
|
43
|
+
get isWorkspaceFile(): boolean;
|
|
44
|
+
constructor(filePath: string, rootPath: string, start: number, end: number);
|
|
45
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.File = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const PathHelpers_1 = require("../utilities/PathHelpers");
|
|
6
|
+
const Module_1 = require("./Module");
|
|
7
|
+
const Namespace_1 = require("./Namespace");
|
|
8
|
+
/**
|
|
9
|
+
* TypeScript resource. Basically a file that is located somewhere.
|
|
10
|
+
*
|
|
11
|
+
* @export
|
|
12
|
+
* @class File
|
|
13
|
+
* @implements {Resource}
|
|
14
|
+
* @implements {Node}
|
|
15
|
+
*/
|
|
16
|
+
class File {
|
|
17
|
+
constructor(filePath, rootPath, start, end) {
|
|
18
|
+
this.filePath = filePath;
|
|
19
|
+
this.rootPath = rootPath;
|
|
20
|
+
this.start = start;
|
|
21
|
+
this.end = end;
|
|
22
|
+
this.imports = [];
|
|
23
|
+
this.exports = [];
|
|
24
|
+
this.declarations = [];
|
|
25
|
+
this.resources = [];
|
|
26
|
+
this.usages = [];
|
|
27
|
+
}
|
|
28
|
+
get identifier() {
|
|
29
|
+
return '/' + PathHelpers_1.normalizeFilename(path_1.relative(this.rootPath, this.filePath));
|
|
30
|
+
}
|
|
31
|
+
get nonLocalUsages() {
|
|
32
|
+
return this.usages
|
|
33
|
+
.filter(usage => !this.declarations.some(o => o.name === usage) &&
|
|
34
|
+
!this.resources.some(o => (o instanceof Module_1.Module || o instanceof Namespace_1.Namespace) && o.name === usage))
|
|
35
|
+
.concat(this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), []));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns the parsed path of a resource.
|
|
39
|
+
*
|
|
40
|
+
* @readonly
|
|
41
|
+
* @type {ParsedPath}
|
|
42
|
+
* @memberof File
|
|
43
|
+
*/
|
|
44
|
+
get parsedPath() {
|
|
45
|
+
return path_1.parse(this.filePath);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Determines if a file is a workspace file or an external resource.
|
|
49
|
+
*
|
|
50
|
+
* @readonly
|
|
51
|
+
* @type {boolean}
|
|
52
|
+
* @memberof File
|
|
53
|
+
*/
|
|
54
|
+
get isWorkspaceFile() {
|
|
55
|
+
return ['node_modules', 'typings'].every(o => this.filePath.indexOf(o) === -1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.File = File;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Declaration } from '../declarations/Declaration';
|
|
2
|
+
import { Export } from '../exports/Export';
|
|
3
|
+
import { Import } from '../imports/Import';
|
|
4
|
+
import { Node } from '../Node';
|
|
5
|
+
import { Resource } from './Resource';
|
|
6
|
+
/**
|
|
7
|
+
* TypeScript resource. Declaration of a typescript module (i.e. declare module "foobar").
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
* @class Module
|
|
11
|
+
* @implements {Resource}
|
|
12
|
+
* @implements {Node}
|
|
13
|
+
*/
|
|
14
|
+
export declare class Module implements Resource, Node {
|
|
15
|
+
name: string;
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
imports: Import[];
|
|
19
|
+
exports: Export[];
|
|
20
|
+
declarations: Declaration[];
|
|
21
|
+
resources: Resource[];
|
|
22
|
+
usages: string[];
|
|
23
|
+
get identifier(): string;
|
|
24
|
+
get nonLocalUsages(): string[];
|
|
25
|
+
constructor(name: string, start: number, end: number);
|
|
26
|
+
/**
|
|
27
|
+
* Function that calculates the alias name of a namespace.
|
|
28
|
+
* Removes all underlines and dashes and camelcases the name.
|
|
29
|
+
*
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*
|
|
32
|
+
* @memberof Module
|
|
33
|
+
*/
|
|
34
|
+
getNamespaceAlias(): string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Module = void 0;
|
|
4
|
+
const Namespace_1 = require("./Namespace");
|
|
5
|
+
/**
|
|
6
|
+
* TypeScript resource. Declaration of a typescript module (i.e. declare module "foobar").
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @class Module
|
|
10
|
+
* @implements {Resource}
|
|
11
|
+
* @implements {Node}
|
|
12
|
+
*/
|
|
13
|
+
class Module {
|
|
14
|
+
constructor(name, start, end) {
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.start = start;
|
|
17
|
+
this.end = end;
|
|
18
|
+
this.imports = [];
|
|
19
|
+
this.exports = [];
|
|
20
|
+
this.declarations = [];
|
|
21
|
+
this.resources = [];
|
|
22
|
+
this.usages = [];
|
|
23
|
+
}
|
|
24
|
+
get identifier() {
|
|
25
|
+
return this.name;
|
|
26
|
+
}
|
|
27
|
+
get nonLocalUsages() {
|
|
28
|
+
return this.usages
|
|
29
|
+
.filter(usage => !this.declarations.some(o => o.name === usage) &&
|
|
30
|
+
!this.resources.some(o => (o instanceof Module || o instanceof Namespace_1.Namespace) && o.name === usage))
|
|
31
|
+
.concat(this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), []));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Function that calculates the alias name of a namespace.
|
|
35
|
+
* Removes all underlines and dashes and camelcases the name.
|
|
36
|
+
*
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*
|
|
39
|
+
* @memberof Module
|
|
40
|
+
*/
|
|
41
|
+
getNamespaceAlias() {
|
|
42
|
+
return this.name.split(/[-_]/).reduce((all, cur, idx) => {
|
|
43
|
+
if (idx === 0) {
|
|
44
|
+
return all + cur.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
|
|
47
|
+
}, '');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Module = Module;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Declaration } from '../declarations/Declaration';
|
|
2
|
+
import { Export } from '../exports/Export';
|
|
3
|
+
import { Import } from '../imports/Import';
|
|
4
|
+
import { Node } from '../Node';
|
|
5
|
+
import { Resource } from './Resource';
|
|
6
|
+
/**
|
|
7
|
+
* TypeScript resource. Declaration of a typescript namespace (i.e. declare foobar).
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
* @class Namespace
|
|
11
|
+
* @implements {Resource}
|
|
12
|
+
* @implements {Node}
|
|
13
|
+
*/
|
|
14
|
+
export declare class Namespace implements Resource, Node {
|
|
15
|
+
name: string;
|
|
16
|
+
start: number;
|
|
17
|
+
end: number;
|
|
18
|
+
imports: Import[];
|
|
19
|
+
exports: Export[];
|
|
20
|
+
declarations: Declaration[];
|
|
21
|
+
resources: Resource[];
|
|
22
|
+
usages: string[];
|
|
23
|
+
get identifier(): string;
|
|
24
|
+
get nonLocalUsages(): string[];
|
|
25
|
+
constructor(name: string, start: number, end: number);
|
|
26
|
+
/**
|
|
27
|
+
* Function that calculates the alias name of a namespace.
|
|
28
|
+
* Removes all underlines and dashes and camelcases the name.
|
|
29
|
+
*
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*
|
|
32
|
+
* @memberof Namespace
|
|
33
|
+
*/
|
|
34
|
+
getNamespaceAlias(): string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Namespace = void 0;
|
|
4
|
+
const Module_1 = require("./Module");
|
|
5
|
+
/**
|
|
6
|
+
* TypeScript resource. Declaration of a typescript namespace (i.e. declare foobar).
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @class Namespace
|
|
10
|
+
* @implements {Resource}
|
|
11
|
+
* @implements {Node}
|
|
12
|
+
*/
|
|
13
|
+
class Namespace {
|
|
14
|
+
constructor(name, start, end) {
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.start = start;
|
|
17
|
+
this.end = end;
|
|
18
|
+
this.imports = [];
|
|
19
|
+
this.exports = [];
|
|
20
|
+
this.declarations = [];
|
|
21
|
+
this.resources = [];
|
|
22
|
+
this.usages = [];
|
|
23
|
+
}
|
|
24
|
+
get identifier() {
|
|
25
|
+
return this.name;
|
|
26
|
+
}
|
|
27
|
+
get nonLocalUsages() {
|
|
28
|
+
return this.usages
|
|
29
|
+
.filter(usage => !this.declarations.some(o => o.name === usage) &&
|
|
30
|
+
!this.resources.some(o => (o instanceof Module_1.Module || o instanceof Namespace) && o.name === usage))
|
|
31
|
+
.concat(this.resources.reduce((all, cur) => all.concat(cur.nonLocalUsages), []));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Function that calculates the alias name of a namespace.
|
|
35
|
+
* Removes all underlines and dashes and camelcases the name.
|
|
36
|
+
*
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*
|
|
39
|
+
* @memberof Namespace
|
|
40
|
+
*/
|
|
41
|
+
getNamespaceAlias() {
|
|
42
|
+
return this.name.split(/[-_]/).reduce((all, cur, idx) => {
|
|
43
|
+
if (idx === 0) {
|
|
44
|
+
return all + cur.toLowerCase();
|
|
45
|
+
}
|
|
46
|
+
return all + cur.charAt(0).toUpperCase() + cur.substring(1).toLowerCase();
|
|
47
|
+
}, '');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Namespace = Namespace;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Declaration } from '../declarations/Declaration';
|
|
2
|
+
import { Export } from '../exports/Export';
|
|
3
|
+
import { Import } from '../imports/Import';
|
|
4
|
+
/**
|
|
5
|
+
* Base interface for resources. All resources share the same properties.
|
|
6
|
+
* Resources are files, namespaces or modules.
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @interface Resource
|
|
10
|
+
*/
|
|
11
|
+
export interface Resource {
|
|
12
|
+
/**
|
|
13
|
+
* List of imports contained in this resource.
|
|
14
|
+
*
|
|
15
|
+
* @type {Import[]}
|
|
16
|
+
* @memberof Resource
|
|
17
|
+
*/
|
|
18
|
+
imports: Import[];
|
|
19
|
+
/**
|
|
20
|
+
* List of exports contained in this resource.
|
|
21
|
+
*
|
|
22
|
+
* @type {Export[]}
|
|
23
|
+
* @memberof Resource
|
|
24
|
+
*/
|
|
25
|
+
exports: Export[];
|
|
26
|
+
/**
|
|
27
|
+
* List of declarations that are contained in this resource.
|
|
28
|
+
*
|
|
29
|
+
* @type {Declaration[]}
|
|
30
|
+
* @memberof Resource
|
|
31
|
+
*/
|
|
32
|
+
declarations: Declaration[];
|
|
33
|
+
/**
|
|
34
|
+
* List of subresources (like namespaces in a file) of this resource.
|
|
35
|
+
*
|
|
36
|
+
* @type {Resource[]}
|
|
37
|
+
* @memberof Resource
|
|
38
|
+
*/
|
|
39
|
+
resources: Resource[];
|
|
40
|
+
/**
|
|
41
|
+
* List of used identifiers in this resource.
|
|
42
|
+
* (i.e. actual used string identifiers to calculate missing imports and stuff.)
|
|
43
|
+
*
|
|
44
|
+
* @type {string[]}
|
|
45
|
+
* @memberof Resource
|
|
46
|
+
*/
|
|
47
|
+
usages: string[];
|
|
48
|
+
/**
|
|
49
|
+
* "Unique" identifier for this resource. Can be the filepath for files or
|
|
50
|
+
* node identifiers for node modules.
|
|
51
|
+
*
|
|
52
|
+
* @type {string}
|
|
53
|
+
* @memberof Resource
|
|
54
|
+
*/
|
|
55
|
+
readonly identifier: string;
|
|
56
|
+
/**
|
|
57
|
+
* Returns an array of usages (a usage is a used symbol name in the resource)
|
|
58
|
+
* that are not covered by its own declarations.
|
|
59
|
+
*
|
|
60
|
+
* @type {string[]}
|
|
61
|
+
* @memberof Resource
|
|
62
|
+
*/
|
|
63
|
+
readonly nonLocalUsages: string[];
|
|
64
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./File"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./Module"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./Namespace"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./Resource"), exports);
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { ArrayBindingPattern, ConstructorDeclaration, ExportDeclaration, ExternalModuleReference, FunctionDeclaration, GetAccessorDeclaration, Identifier, ImportDeclaration, ImportEqualsDeclaration, MethodDeclaration, MethodSignature, NamedExports, NamedImports, NamespaceImport, Node, ObjectBindingPattern, PropertyDeclaration, PropertySignature, SetAccessorDeclaration, StringLiteral } from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Determines if the given node is an ImportDeclaration.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @param {Node} [node]
|
|
7
|
+
* @returns {node is ImportDeclaration}
|
|
8
|
+
*/
|
|
9
|
+
export declare function isImportDeclaration(node?: Node): node is ImportDeclaration;
|
|
10
|
+
/**
|
|
11
|
+
* Determines if the given node is an ImportEqualsDeclaration.
|
|
12
|
+
*
|
|
13
|
+
* @export
|
|
14
|
+
* @param {Node} [node]
|
|
15
|
+
* @returns {node is ImportEqualsDeclaration}
|
|
16
|
+
*/
|
|
17
|
+
export declare function isImportEqualsDeclaration(node?: Node): node is ImportEqualsDeclaration;
|
|
18
|
+
/**
|
|
19
|
+
* Determines if the given node is a NamespaceImport.
|
|
20
|
+
*
|
|
21
|
+
* @export
|
|
22
|
+
* @param {Node} [node]
|
|
23
|
+
* @returns {node is NamespaceImport}
|
|
24
|
+
*/
|
|
25
|
+
export declare function isNamespaceImport(node?: Node): node is NamespaceImport;
|
|
26
|
+
/**
|
|
27
|
+
* Determines if the given node are NamedImports.
|
|
28
|
+
*
|
|
29
|
+
* @export
|
|
30
|
+
* @param {Node} [node]
|
|
31
|
+
* @returns {node is NamedImports}
|
|
32
|
+
*/
|
|
33
|
+
export declare function isNamedImports(node?: Node): node is NamedImports;
|
|
34
|
+
/**
|
|
35
|
+
* Determines if the given node are NamedExports.
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @param {Node} [node]
|
|
39
|
+
* @returns {node is NamedExports}
|
|
40
|
+
*/
|
|
41
|
+
export declare function isNamedExports(node?: Node): node is NamedExports;
|
|
42
|
+
/**
|
|
43
|
+
* Determines if the given node is a StringLiteral.
|
|
44
|
+
*
|
|
45
|
+
* @export
|
|
46
|
+
* @param {Node} [node]
|
|
47
|
+
* @returns {node is StringLiteral}
|
|
48
|
+
*/
|
|
49
|
+
export declare function isStringLiteral(node?: Node): node is StringLiteral;
|
|
50
|
+
/**
|
|
51
|
+
* Determines if the given node is an Identifier.
|
|
52
|
+
*
|
|
53
|
+
* @export
|
|
54
|
+
* @param {Node} [node]
|
|
55
|
+
* @returns {node is Identifier}
|
|
56
|
+
*/
|
|
57
|
+
export declare function isIdentifier(node?: Node): node is Identifier;
|
|
58
|
+
/**
|
|
59
|
+
* Determines if the given node is an ExternalModuleReference.
|
|
60
|
+
*
|
|
61
|
+
* @export
|
|
62
|
+
* @param {Node} [node]
|
|
63
|
+
* @returns {node is ExternalModuleReference}
|
|
64
|
+
*/
|
|
65
|
+
export declare function isExternalModuleReference(node?: Node): node is ExternalModuleReference;
|
|
66
|
+
/**
|
|
67
|
+
* Determines if the given node is an ExportDeclaration.
|
|
68
|
+
*
|
|
69
|
+
* @export
|
|
70
|
+
* @param {Node} [node]
|
|
71
|
+
* @returns {node is ExportDeclaration}
|
|
72
|
+
*/
|
|
73
|
+
export declare function isExportDeclaration(node?: Node): node is ExportDeclaration;
|
|
74
|
+
/**
|
|
75
|
+
* Determines if the given node is an ObjectBindingPattern (i.e. let {x, y} = foo).
|
|
76
|
+
*
|
|
77
|
+
* @export
|
|
78
|
+
* @param {Node} [node]
|
|
79
|
+
* @returns {node is ObjectBindingPattern}
|
|
80
|
+
*/
|
|
81
|
+
export declare function isObjectBindingPattern(node?: Node): node is ObjectBindingPattern;
|
|
82
|
+
/**
|
|
83
|
+
* Determines if the given node is an ArrayBindingPattern (i.e. let [x, y] = foo).
|
|
84
|
+
*
|
|
85
|
+
* @export
|
|
86
|
+
* @param {Node} [node]
|
|
87
|
+
* @returns {node is ArrayBindingPattern}
|
|
88
|
+
*/
|
|
89
|
+
export declare function isArrayBindingPattern(node?: Node): node is ArrayBindingPattern;
|
|
90
|
+
/**
|
|
91
|
+
* Determines if the given node is a FunctionDeclaration.
|
|
92
|
+
*
|
|
93
|
+
* @export
|
|
94
|
+
* @param {Node} [node]
|
|
95
|
+
* @returns {node is FunctionDeclaration}
|
|
96
|
+
*/
|
|
97
|
+
export declare function isFunctionDeclaration(node?: Node): node is FunctionDeclaration;
|
|
98
|
+
/**
|
|
99
|
+
* Determines if the given node is a MethodSignature.
|
|
100
|
+
*
|
|
101
|
+
* @export
|
|
102
|
+
* @param {Node} [node]
|
|
103
|
+
* @returns {node is MethodSignature}
|
|
104
|
+
*/
|
|
105
|
+
export declare function isMethodSignature(node?: Node): node is MethodSignature;
|
|
106
|
+
/**
|
|
107
|
+
* Determines if the given node is a PropertySignature.
|
|
108
|
+
*
|
|
109
|
+
* @export
|
|
110
|
+
* @param {Node} [node]
|
|
111
|
+
* @returns {node is PropertySignature}
|
|
112
|
+
*/
|
|
113
|
+
export declare function isPropertySignature(node?: Node): node is PropertySignature;
|
|
114
|
+
/**
|
|
115
|
+
* Determines if the given node is a MethodDeclaration.
|
|
116
|
+
*
|
|
117
|
+
* @export
|
|
118
|
+
* @param {Node} [node]
|
|
119
|
+
* @returns {node is MethodDeclaration}
|
|
120
|
+
*/
|
|
121
|
+
export declare function isMethodDeclaration(node?: Node): node is MethodDeclaration;
|
|
122
|
+
/**
|
|
123
|
+
* Determines if the given node is a PropertyDeclaration.
|
|
124
|
+
*
|
|
125
|
+
* @export
|
|
126
|
+
* @param {Node} [node]
|
|
127
|
+
* @returns {node is PropertyDeclaration}
|
|
128
|
+
*/
|
|
129
|
+
export declare function isPropertyDeclaration(node?: Node): node is PropertyDeclaration;
|
|
130
|
+
/**
|
|
131
|
+
* Determines if the given node is a ConstructorDeclaration.
|
|
132
|
+
*
|
|
133
|
+
* @export
|
|
134
|
+
* @param {Node} [node]
|
|
135
|
+
* @returns {node is ConstructorDeclaration}
|
|
136
|
+
*/
|
|
137
|
+
export declare function isConstructorDeclaration(node?: Node): node is ConstructorDeclaration;
|
|
138
|
+
/**
|
|
139
|
+
* Determines if the given node is a isGetAccessorDeclaration.
|
|
140
|
+
*
|
|
141
|
+
* @export
|
|
142
|
+
* @param {Node} [node]
|
|
143
|
+
* @returns {node is isGetAccessorDeclaration}
|
|
144
|
+
*/
|
|
145
|
+
export declare function isGetAccessorDeclaration(node?: Node): node is GetAccessorDeclaration;
|
|
146
|
+
/**
|
|
147
|
+
* Determines if the given node is a SetAccessorDeclaration.
|
|
148
|
+
*
|
|
149
|
+
* @export
|
|
150
|
+
* @param {Node} [node]
|
|
151
|
+
* @returns {node is SetAccessorDeclaration}
|
|
152
|
+
*/
|
|
153
|
+
export declare function isSetAccessorDeclaration(node?: Node): node is SetAccessorDeclaration;
|