浏览代码

Merge pull request #746 from javascript-obfuscator/string-array-wrapper-default-parameter

Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/745
Timofey Kachalov 4 年之前
父节点
当前提交
6edbdb2181

+ 4 - 0
CHANGELOG.md

@@ -1,5 +1,9 @@
 Change Log
 
+v2.2.1
+---
+* Fixed https://github.com/javascript-obfuscator/javascript-obfuscator/issues/745
+
 v2.2.0
 ---
 * **New option (enabled by default):** `stringArrayWrappersCount` sets the count of wrappers for the `string array` inside each root or function scope

文件差异内容过多而无法显示
+ 0 - 0
dist/index.browser.js


文件差异内容过多而无法显示
+ 0 - 0
dist/index.cli.js


文件差异内容过多而无法显示
+ 0 - 0
dist/index.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "javascript-obfuscator",
-  "version": "2.2.0",
+  "version": "2.2.1",
   "description": "JavaScript obfuscator",
   "keywords": [
     "obfuscator",

+ 2 - 2
src/interfaces/storages/string-array-transformers/IStringArrayScopeCallsWrapperDataStorage.ts

@@ -1,10 +1,10 @@
-import { TNodeWithLexicalScope } from '../../../types/node/TNodeWithLexicalScope';
+import { TNodeWithLexicalScopeStatements } from '../../../types/node/TNodeWithLexicalScopeStatements';
 import { TStringArrayScopeCallsWrapperDataByEncoding } from '../../../types/node-transformers/string-array-transformers/TStringArrayScopeCallsWrapperDataByEncoding';
 
 import { IMapStorage } from '../IMapStorage';
 
 // eslint-disable-next-line @typescript-eslint/no-empty-interface
 export interface IStringArrayScopeCallsWrapperDataStorage extends IMapStorage<
-    TNodeWithLexicalScope,
+    TNodeWithLexicalScopeStatements,
     TStringArrayScopeCallsWrapperDataByEncoding
 > {}

+ 8 - 9
src/interfaces/storages/string-array-transformers/IVisitedLexicalScopeNodesStackStorage.ts

@@ -1,21 +1,20 @@
-import { TNodeWithLexicalScopeAndStatements } from '../../../types/node/TNodeWithLexicalScopeAndStatements';
+import { TNodeWithLexicalScopeStatements } from '../../../types/node/TNodeWithLexicalScopeStatements';
 
 import { IArrayStorage } from '../IArrayStorage';
 
-// eslint-disable-next-line @typescript-eslint/no-empty-interface
-export interface IVisitedLexicalScopeNodesStackStorage extends IArrayStorage<TNodeWithLexicalScopeAndStatements> {
+export interface IVisitedLexicalScopeNodesStackStorage extends IArrayStorage<TNodeWithLexicalScopeStatements> {
     /**
-     * @returns {TNodeWithLexicalScopeAndStatements | undefined}
+     * @returns {TNodeWithLexicalScopeStatements | undefined}
      */
-    getLastElement (): TNodeWithLexicalScopeAndStatements | undefined;
+    getLastElement (): TNodeWithLexicalScopeStatements | undefined;
 
     /**
-     * @returns {TNodeWithLexicalScopeAndStatements | undefined}
+     * @returns {TNodeWithLexicalScopeStatements | undefined}
      */
-    pop (): TNodeWithLexicalScopeAndStatements | undefined;
+    pop (): TNodeWithLexicalScopeStatements | undefined;
 
     /**
-     * @param {TNodeWithLexicalScopeAndStatements} lexicalScopeNode
+     * @param {TNodeWithLexicalScopeStatements} lexicalScopeBodyNode
      */
-    push (lexicalScopeNode: TNodeWithLexicalScopeAndStatements): void;
+    push (lexicalScopeBodyNode: TNodeWithLexicalScopeStatements): void;
 }

+ 20 - 23
src/node-transformers/string-array-transformers/StringArrayScopeCallsWrapperTransformer.ts

@@ -4,8 +4,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import * as ESTree from 'estree';
 
 import { TInitialData } from '../../types/TInitialData';
-import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
-import { TNodeWithLexicalScopeAndStatements } from '../../types/node/TNodeWithLexicalScopeAndStatements';
+import { TNodeWithLexicalScopeStatements } from '../../types/node/TNodeWithLexicalScopeStatements';
 import { TStringArrayEncoding } from '../../types/options/TStringArrayEncoding';
 import { TStringArrayScopeCallsWrapperDataByEncoding } from '../../types/node-transformers/string-array-transformers/TStringArrayScopeCallsWrapperDataByEncoding';
 import { TStringArrayTransformerCustomNodeFactory } from '../../types/container/custom-nodes/TStringArrayTransformerCustomNodeFactory';
@@ -86,13 +85,13 @@ export class StringArrayScopeCallsWrapperTransformer extends AbstractNodeTransfo
         switch (nodeTransformationStage) {
             case NodeTransformationStage.StringArray:
                 return {
-                    enter: (node: ESTree.Node): void => {
-                        if (NodeGuards.isNodeWithLexicalScopeAndStatements(node)) {
+                    enter: (node: ESTree.Node, parentNode: ESTree.Node | null): void => {
+                        if (parentNode && NodeGuards.isNodeWithLexicalScopeStatements(node, parentNode)) {
                             this.onLexicalScopeNodeEnter(node);
                         }
                     },
-                    leave: (node: ESTree.Node): ESTree.Node | undefined => {
-                        if (NodeGuards.isNodeWithLexicalScopeAndStatements(node)) {
+                    leave: (node: ESTree.Node, parentNode: ESTree.Node | null): ESTree.Node | undefined => {
+                        if (parentNode && NodeGuards.isNodeWithLexicalScopeStatements(node, parentNode)) {
                             this.onLexicalScopeNodeLeave();
 
                             return this.transformNode(node);
@@ -106,20 +105,17 @@ export class StringArrayScopeCallsWrapperTransformer extends AbstractNodeTransfo
     }
 
     /**
-     * @param {TNodeWithLexicalScopeAndStatements} lexicalScopeNode
-     * @returns {TNodeWithLexicalScopeAndStatements}
+     * @param {TNodeWithLexicalScopeStatements} lexicalScopeBodyNode
+     * @returns {TNodeWithLexicalScopeStatements}
      */
-    public transformNode (lexicalScopeNode: TNodeWithLexicalScopeAndStatements): TNodeWithLexicalScopeAndStatements {
-        const lexicalScopeBodyNode: ESTree.Program | ESTree.BlockStatement =
-            NodeGuards.isProgramNode(lexicalScopeNode)
-                ? lexicalScopeNode
-                : lexicalScopeNode.body;
-
+    public transformNode (
+        lexicalScopeBodyNode: TNodeWithLexicalScopeStatements
+    ): TNodeWithLexicalScopeStatements {
         const stringArrayScopeCallsWrapperDataByEncoding: TStringArrayScopeCallsWrapperDataByEncoding | null =
-            this.stringArrayScopeCallsWrapperDataStorage.get(lexicalScopeNode) ?? null;
+            this.stringArrayScopeCallsWrapperDataStorage.get(lexicalScopeBodyNode) ?? null;
 
         if (!stringArrayScopeCallsWrapperDataByEncoding) {
-            return lexicalScopeNode;
+            return lexicalScopeBodyNode;
         }
 
         const stringArrayScopeCallsWrapperDataList: (IStringArrayScopeCallsWrapperData | undefined)[] =
@@ -159,7 +155,7 @@ export class StringArrayScopeCallsWrapperTransformer extends AbstractNodeTransfo
             }
         }
 
-        return lexicalScopeNode;
+        return lexicalScopeBodyNode;
     }
 
     /**
@@ -181,14 +177,15 @@ export class StringArrayScopeCallsWrapperTransformer extends AbstractNodeTransfo
             return rootStringArrayCallsWrapperName;
         }
 
-        const parentLexicalScope: TNodeWithLexicalScope | undefined = this.visitedLexicalScopeNodesStackStorage.getLastElement();
+        const parentLexicalScopeBodyNode: TNodeWithLexicalScopeStatements | undefined =
+            this.visitedLexicalScopeNodesStackStorage.getLastElement();
 
-        if (!parentLexicalScope) {
+        if (!parentLexicalScopeBodyNode) {
             return rootStringArrayCallsWrapperName;
         }
 
         const parentLexicalScopeDataByEncoding = this.stringArrayScopeCallsWrapperDataStorage
-            .get(parentLexicalScope) ?? null;
+            .get(parentLexicalScopeBodyNode) ?? null;
         const parentLexicalScopeNames: string[] | null = parentLexicalScopeDataByEncoding?.[encoding]?.names ?? null;
 
         return parentLexicalScopeNames?.length
@@ -199,10 +196,10 @@ export class StringArrayScopeCallsWrapperTransformer extends AbstractNodeTransfo
     }
 
     /**
-     * @param {TNodeWithLexicalScopeAndStatements} lexicalScopeNode
+     * @param {TNodeWithLexicalScopeStatements} lexicalScopeBodyNode
      */
-    private onLexicalScopeNodeEnter (lexicalScopeNode: TNodeWithLexicalScopeAndStatements): void {
-        this.visitedLexicalScopeNodesStackStorage.push(lexicalScopeNode);
+    private onLexicalScopeNodeEnter (lexicalScopeBodyNode: TNodeWithLexicalScopeStatements): void {
+        this.visitedLexicalScopeNodesStackStorage.push(lexicalScopeBodyNode);
     }
 
     private onLexicalScopeNodeLeave (): void {

+ 7 - 6
src/node-transformers/string-array-transformers/StringArrayTransformer.ts

@@ -4,7 +4,7 @@ import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 import * as ESTree from 'estree';
 
 import { TInitialData } from '../../types/TInitialData';
-import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
+import { TNodeWithLexicalScopeStatements } from '../../types/node/TNodeWithLexicalScopeStatements';
 import { TStatement } from '../../types/node/TStatement';
 import { TStringArrayEncoding } from '../../types/options/TStringArrayEncoding';
 import { TStringArrayScopeCallsWrapperDataByEncoding } from '../../types/node-transformers/string-array-transformers/TStringArrayScopeCallsWrapperDataByEncoding';
@@ -251,14 +251,15 @@ export class StringArrayTransformer extends AbstractNodeTransformer {
      * @returns {string}
      */
     private getUpperStringArrayCallsWrapperName (encoding: TStringArrayEncoding): string {
-        const currentLexicalScopeNode: TNodeWithLexicalScope | undefined = this.visitedLexicalScopeNodesStackStorage.getLastElement();
+        const currentLexicalScopeBodyNode: TNodeWithLexicalScopeStatements | undefined =
+            this.visitedLexicalScopeNodesStackStorage.getLastElement();
 
-        if (!currentLexicalScopeNode) {
-            throw new Error('Cannot find current lexical scope node');
+        if (!currentLexicalScopeBodyNode) {
+            throw new Error('Cannot find current lexical scope body node');
         }
 
         const stringArrayScopeCallsWrapperDataByEncoding: TStringArrayScopeCallsWrapperDataByEncoding =
-            this.stringArrayScopeCallsWrapperDataStorage.get(currentLexicalScopeNode) ?? {};
+            this.stringArrayScopeCallsWrapperDataStorage.get(currentLexicalScopeBodyNode) ?? {};
         const stringArrayScopeCallsWrapperNames: string[] = stringArrayScopeCallsWrapperDataByEncoding[encoding]?.names ?? [];
         const isFilledScopeCallsWrapperNamesList: boolean = stringArrayScopeCallsWrapperNames.length === this.options.stringArrayWrappersCount;
 
@@ -272,7 +273,7 @@ export class StringArrayTransformer extends AbstractNodeTransformer {
             };
 
             this.stringArrayScopeCallsWrapperDataStorage.set(
-                currentLexicalScopeNode,
+                currentLexicalScopeBodyNode,
                 stringArrayScopeCallsWrapperDataByEncoding
             );
         }

+ 2 - 27
src/node/NodeGuards.ts

@@ -1,7 +1,7 @@
 import * as ESTree from 'estree';
 
 import { TNodeWithLexicalScope } from '../types/node/TNodeWithLexicalScope';
-import { TNodeWithLexicalScopeAndStatements } from '../types/node/TNodeWithLexicalScopeAndStatements';
+import { TNodeWithLexicalScopeStatements } from '../types/node/TNodeWithLexicalScopeStatements';
 import { TNodeWithStatements } from '../types/node/TNodeWithStatements';
 
 import { NodeType } from '../enums/node/NodeType';
@@ -271,31 +271,6 @@ export class NodeGuards {
         return NodeGuards.isNodeWithLexicalScope(node) || NodeGuards.isBlockStatementNode(node);
     }
 
-    /**
-     * @param {Node} node
-     * @returns {node is TNodeWithLexicalScopeAndStatements}
-     */
-    public static isNodeWithLexicalScopeAndStatements (node: ESTree.Node): node is TNodeWithLexicalScopeAndStatements {
-        if (!NodeGuards.isNodeWithLexicalScope(node)) {
-            return false;
-        }
-
-        const lexicalScopeBodyNode: ESTree.Program | ESTree.BlockStatement | ESTree.Expression =
-            NodeGuards.isProgramNode(node)
-                ? node
-                : node.body;
-
-        // invalid lexical scope node
-        if (
-            !lexicalScopeBodyNode.parentNode
-            || !NodeGuards.isNodeWithLexicalScopeStatements(lexicalScopeBodyNode, lexicalScopeBodyNode.parentNode)
-        ) {
-            return false;
-        }
-
-        return true;
-    }
-
     /**
      * @param {Node} node
      * @param {Node} parentNode
@@ -304,7 +279,7 @@ export class NodeGuards {
     public static isNodeWithLexicalScopeStatements (
         node: ESTree.Node,
         parentNode: ESTree.Node
-    ): node is TNodeWithStatements {
+    ): node is TNodeWithLexicalScopeStatements {
         return NodeGuards.isProgramNode(node)
             || (NodeGuards.isBlockStatementNode(node) && NodeGuards.nodesWithLexicalStatements.includes(parentNode.type));
     }

+ 2 - 2
src/storages/string-array-transformers/StringArrayScopeCallsWrapperDataStorage.ts

@@ -1,7 +1,7 @@
 import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
-import { TNodeWithLexicalScope } from '../../types/node/TNodeWithLexicalScope';
+import { TNodeWithLexicalScopeStatements } from '../../types/node/TNodeWithLexicalScopeStatements';
 import { TStringArrayScopeCallsWrapperDataByEncoding } from '../../types/node-transformers/string-array-transformers/TStringArrayScopeCallsWrapperDataByEncoding';
 
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -12,7 +12,7 @@ import { MapStorage } from '../MapStorage';
 
 @injectable()
 export class StringArrayScopeCallsWrapperDataStorage extends MapStorage <
-    TNodeWithLexicalScope,
+    TNodeWithLexicalScopeStatements,
     TStringArrayScopeCallsWrapperDataByEncoding
 > implements IStringArrayScopeCallsWrapperDataStorage {
     /**

+ 9 - 9
src/storages/string-array-transformers/VisitedLexicalScopeNodesStackStorage.ts

@@ -1,7 +1,7 @@
 import { inject, injectable } from 'inversify';
 import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
 
-import { TNodeWithLexicalScopeAndStatements } from '../../types/node/TNodeWithLexicalScopeAndStatements';
+import { TNodeWithLexicalScopeStatements } from '../../types/node/TNodeWithLexicalScopeStatements';
 
 import { IArrayUtils } from '../../interfaces/utils/IArrayUtils';
 import { IOptions } from '../../interfaces/options/IOptions';
@@ -11,7 +11,7 @@ import { IVisitedLexicalScopeNodesStackStorage } from '../../interfaces/storages
 import { ArrayStorage } from '../ArrayStorage';
 
 @injectable()
-export class VisitedLexicalScopeNodesStackStorage extends ArrayStorage <TNodeWithLexicalScopeAndStatements> implements IVisitedLexicalScopeNodesStackStorage {
+export class VisitedLexicalScopeNodesStackStorage extends ArrayStorage <TNodeWithLexicalScopeStatements> implements IVisitedLexicalScopeNodesStackStorage {
     /**
      * @type {IArrayUtils}
      */
@@ -33,23 +33,23 @@ export class VisitedLexicalScopeNodesStackStorage extends ArrayStorage <TNodeWit
     }
 
     /**
-     * @returns {TNodeWithLexicalScopeAndStatements | undefined}
+     * @returns {TNodeWithLexicalScopeStatements | undefined}
      */
-    public getLastElement (): TNodeWithLexicalScopeAndStatements | undefined {
+    public getLastElement (): TNodeWithLexicalScopeStatements | undefined {
         return this.arrayUtils.getLastElement(this.getStorage());
     }
 
     /**
-     * @param {TNodeWithLexicalScopeAndStatements} lexicalScopeNode
+     * @param {TNodeWithLexicalScopeStatements} nodeWithLexicalScopeStatements
      */
-    public push (lexicalScopeNode: TNodeWithLexicalScopeAndStatements): void {
-        this.storage.push(lexicalScopeNode);
+    public push (nodeWithLexicalScopeStatements: TNodeWithLexicalScopeStatements): void {
+        this.storage.push(nodeWithLexicalScopeStatements);
     }
 
     /**
-     * @returns {TNodeWithLexicalScopeAndStatements | undefined}
+     * @returns {TNodeWithLexicalScopeStatements| undefined}
      */
-    public pop (): TNodeWithLexicalScopeAndStatements | undefined {
+    public pop (): TNodeWithLexicalScopeStatements | undefined {
         return this.storage.pop();
     }
 }

+ 0 - 8
src/types/node/TNodeWithLexicalScopeAndStatements.ts

@@ -1,8 +0,0 @@
-import * as ESTree from 'estree';
-
-import { TNodeWithLexicalScope } from './TNodeWithLexicalScope';
-
-export type TNodeWithLexicalScopeAndStatements = TNodeWithLexicalScope
-    & {
-        body: ESTree.Program | ESTree.BlockStatement;
-    };

+ 3 - 0
src/types/node/TNodeWithLexicalScopeStatements.ts

@@ -0,0 +1,3 @@
+import * as ESTree from 'estree';
+
+export type TNodeWithLexicalScopeStatements = ESTree.Program | ESTree.BlockStatement;

+ 4 - 3
test/dev/dev.ts

@@ -12,13 +12,14 @@ import { IdentifierNamesGenerator } from '../../src/enums/generators/identifier-
             const bar = 'bar';
             const baz = 'baz';
             
-            function test () {
-                const bark = 'bark'
+            function test (arg = 'bark') {
                 const hawk = 'hawk';
                 const eagle = 'eagle';
+                
+                console.log(arg, hawk, eagle);
             }
             
-            console.log(foo, bar, baz);
+            test();
         `,
         {
             ...NO_ADDITIONAL_NODES_PRESET,

+ 32 - 0
test/functional-tests/node-transformers/string-array-transformers/string-array-scope-calls-wrapper-transformer/StringArrayScopeCallsWrapperTransformer.spec.ts

@@ -209,6 +209,38 @@ describe('StringArrayScopeCallsWrapperTransformer', function () {
                     assert.match(obfuscatedCode, stringArrayCallRegExp);
                 });
             });
+
+            describe('Variant #4: correct wrapper for the function default parameter', () => {
+                const stringArrayCallRegExp: RegExp = new RegExp(
+                    'const e *= *b;' +
+                    'const foo *= *e\\(\'0x0\'\\);' +
+                    'function test *\\(c *= *e\\(\'0x1\'\\)\\) *{' +
+                        'const f *= *b;' +
+                        'const d *= *f\\(\'0x2\'\\);' +
+                    '}'
+                );
+
+                let obfuscatedCode: string;
+
+                before(() => {
+                    const code: string = readFileAsString(__dirname + '/fixtures/wrapper-for-the-function-default-parameter.js');
+
+                    obfuscatedCode = JavaScriptObfuscator.obfuscate(
+                        code,
+                        {
+                            ...NO_ADDITIONAL_NODES_PRESET,
+                            identifierNamesGenerator: IdentifierNamesGenerator.MangledIdentifierNamesGenerator,
+                            stringArray: true,
+                            stringArrayThreshold: 1,
+                            stringArrayWrappersCount: 1
+                        }
+                    ).getObfuscatedCode();
+                });
+
+                it('should add scope calls wrappers', () => {
+                    assert.match(obfuscatedCode, stringArrayCallRegExp);
+                });
+            });
         });
 
         describe('Variant #3: prohibited scopes', () => {

+ 5 - 0
test/functional-tests/node-transformers/string-array-transformers/string-array-scope-calls-wrapper-transformer/fixtures/wrapper-for-the-function-default-parameter.js

@@ -0,0 +1,5 @@
+const foo = 'foo'
+
+function test (bar = 'bar') {
+    const baz = 'baz'
+}

+ 0 - 95
test/unit-tests/node/node-guards/NodeGuards.spec.ts

@@ -257,99 +257,4 @@ describe('NodeGuards', () => {
             });
         });
     });
-
-    describe('isNodeWithLexicalScopeAndStatements', () => {
-        describe('truthful checks', () => {
-            const expectedResult: boolean = true;
-
-            describe('Variant #1: program node', () => {
-                const node: ESTree.Program = NodeFactory.programNode();
-
-                let result: boolean;
-
-                before(() => {
-                    NodeUtils.parentizeAst(node);
-                    result = NodeGuards.isNodeWithLexicalScopeAndStatements(node);
-                });
-
-                it('should check if node with a lexical scope and statements', () => {
-                    assert.equal(result, expectedResult);
-                });
-            });
-
-            describe('Variant #2: function declaration node', () => {
-                const functionDeclarationNode: ESTree.FunctionDeclaration = NodeFactory.functionDeclarationNode(
-                    'foo',
-                    [],
-                    NodeFactory.blockStatementNode([])
-                );
-                const programNode: ESTree.Program = NodeFactory.programNode([
-                    functionDeclarationNode
-                ]);
-
-                let result: boolean;
-
-                before(() => {
-                    NodeUtils.parentizeAst(programNode);
-                    result = NodeGuards.isNodeWithLexicalScopeAndStatements(functionDeclarationNode);
-                });
-
-                it('should check if node with a lexical scope and statements', () => {
-                    assert.equal(result, expectedResult);
-                });
-            });
-
-            describe('Variant #3: arrow function expression node', () => {
-                const arrowFunctionExpressionNode: ESTree.ArrowFunctionExpression = NodeFactory.arrowFunctionExpressionNode(
-                    [],
-                    false,
-                    NodeFactory.blockStatementNode([])
-                );
-                const programNode: ESTree.Program = NodeFactory.programNode([
-                    NodeFactory.expressionStatementNode(
-                        arrowFunctionExpressionNode
-                    )
-                ]);
-
-                let result: boolean;
-
-                before(() => {
-                    NodeUtils.parentizeAst(programNode);
-                    result = NodeGuards.isNodeWithLexicalScopeAndStatements(arrowFunctionExpressionNode);
-                });
-
-                it('should check if node with a lexical scope and statements', () => {
-                    assert.equal(result, expectedResult);
-                });
-            });
-        });
-
-        describe('false checks', () => {
-            const expectedResult: boolean = false;
-
-            describe('Variant #1: arrow function expression node without statements', () => {
-                const arrowFunctionExpressionNode: ESTree.ArrowFunctionExpression = NodeFactory.arrowFunctionExpressionNode(
-                    [],
-                    true,
-                    NodeFactory.literalNode('foo')
-                );
-                const programNode: ESTree.Program = NodeFactory.programNode([
-                    NodeFactory.expressionStatementNode(
-                        arrowFunctionExpressionNode
-                    )
-                ]);
-
-                let result: boolean;
-
-                before(() => {
-                    NodeUtils.parentizeAst(programNode);
-                    result = NodeGuards.isNodeWithLexicalScopeAndStatements(arrowFunctionExpressionNode);
-                });
-
-                it('should check if node with a lexical scope and statements', () => {
-                    assert.equal(result, expectedResult);
-                });
-            });
-        });
-    });
 });

+ 44 - 44
test/unit-tests/storages/string-array-transformers/visited-lexical-scope-nodes-stack/VisitedLexicalScopeNodesStackStorage.spec.ts

@@ -5,7 +5,7 @@ import { assert } from 'chai';
 import { ServiceIdentifiers } from '../../../../../src/container/ServiceIdentifiers';
 
 import { TInputOptions } from '../../../../../src/types/options/TInputOptions';
-import { TNodeWithLexicalScopeAndStatements } from '../../../../../src/types/node/TNodeWithLexicalScopeAndStatements';
+import { TNodeWithLexicalScopeStatements } from '../../../../../src/types/node/TNodeWithLexicalScopeStatements';
 
 import { IInversifyContainerFacade } from '../../../../../src/interfaces/container/IInversifyContainerFacade';
 import { IVisitedLexicalScopeNodesStackStorage } from '../../../../../src/interfaces/storages/string-array-transformers/IVisitedLexicalScopeNodesStackStorage';
@@ -35,23 +35,23 @@ const getStorageInstance = (options: TInputOptions = {}): IVisitedLexicalScopeNo
 
 describe('VisitedLexicalScopeNodesStackStorage', () => {
     describe('getLastElement', () => {
-        const firstElement: TNodeWithLexicalScopeAndStatements = NodeFactory.functionDeclarationNode(
-            'first',
-            [],
-            NodeFactory.blockStatementNode([])
-        );
-        const secondElement: TNodeWithLexicalScopeAndStatements = NodeFactory.functionDeclarationNode(
-            'second',
-            [],
-            NodeFactory.blockStatementNode([])
-        );
-        const expectedLastElement: TNodeWithLexicalScopeAndStatements = NodeFactory.functionDeclarationNode(
-            'last',
-            [],
-            NodeFactory.blockStatementNode([])
-        );
-
-       let lastElement: TNodeWithLexicalScopeAndStatements | undefined;
+        const firstElement: TNodeWithLexicalScopeStatements = NodeFactory.blockStatementNode([
+            NodeFactory.expressionStatementNode(
+                NodeFactory.literalNode('first')
+            )
+        ]);
+        const secondElement: TNodeWithLexicalScopeStatements = NodeFactory.blockStatementNode([
+            NodeFactory.expressionStatementNode(
+                NodeFactory.literalNode('second')
+            )
+        ]);
+        const expectedLastElement: TNodeWithLexicalScopeStatements =  NodeFactory.blockStatementNode([
+            NodeFactory.expressionStatementNode(
+                NodeFactory.literalNode('last')
+            )
+        ]);
+
+       let lastElement: TNodeWithLexicalScopeStatements | undefined;
 
         before(() => {
             const visitedLexicalScopeNodesStackStorage: IVisitedLexicalScopeNodesStackStorage = getStorageInstance();
@@ -68,22 +68,22 @@ describe('VisitedLexicalScopeNodesStackStorage', () => {
     });
 
     describe('push', () => {
-        const firstElement: TNodeWithLexicalScopeAndStatements = NodeFactory.functionDeclarationNode(
-            'first',
-            [],
-            NodeFactory.blockStatementNode([])
-        );
-        const secondElement: TNodeWithLexicalScopeAndStatements = NodeFactory.functionDeclarationNode(
-            'second',
-            [],
-            NodeFactory.blockStatementNode([])
-        );
-        const expectedStorage: TNodeWithLexicalScopeAndStatements[] = [
+        const firstElement: TNodeWithLexicalScopeStatements = NodeFactory.blockStatementNode([
+            NodeFactory.expressionStatementNode(
+                NodeFactory.literalNode('first')
+            )
+        ]);
+        const secondElement: TNodeWithLexicalScopeStatements = NodeFactory.blockStatementNode([
+            NodeFactory.expressionStatementNode(
+                NodeFactory.literalNode('second')
+            )
+        ]);
+        const expectedStorage: TNodeWithLexicalScopeStatements[] = [
             firstElement,
             secondElement
         ];
 
-        let storage: TNodeWithLexicalScopeAndStatements[];
+        let storage: TNodeWithLexicalScopeStatements[];
 
         before(() => {
             const visitedLexicalScopeNodesStackStorage: IVisitedLexicalScopeNodesStackStorage = getStorageInstance();
@@ -99,23 +99,23 @@ describe('VisitedLexicalScopeNodesStackStorage', () => {
     });
 
     describe('pop', () => {
-        const firstElement: TNodeWithLexicalScopeAndStatements = NodeFactory.functionDeclarationNode(
-            'first',
-            [],
-            NodeFactory.blockStatementNode([])
-        );
-        const secondElement: TNodeWithLexicalScopeAndStatements = NodeFactory.functionDeclarationNode(
-            'second',
-            [],
-            NodeFactory.blockStatementNode([])
-        );
-        const expectedStorage: TNodeWithLexicalScopeAndStatements[] = [
+        const firstElement: TNodeWithLexicalScopeStatements = NodeFactory.blockStatementNode([
+            NodeFactory.expressionStatementNode(
+                NodeFactory.literalNode('first')
+            )
+        ]);
+        const secondElement: TNodeWithLexicalScopeStatements = NodeFactory.blockStatementNode([
+            NodeFactory.expressionStatementNode(
+                NodeFactory.literalNode('second')
+            )
+        ]);
+        const expectedStorage: TNodeWithLexicalScopeStatements[] = [
             firstElement
         ];
-        const expectedPoppedElement: TNodeWithLexicalScopeAndStatements = secondElement;
+        const expectedPoppedElement: TNodeWithLexicalScopeStatements = secondElement;
 
-        let storage: TNodeWithLexicalScopeAndStatements[];
-        let poppedElement: TNodeWithLexicalScopeAndStatements | undefined;
+        let storage: TNodeWithLexicalScopeStatements[];
+        let poppedElement: TNodeWithLexicalScopeStatements | undefined;
 
         before(() => {
             const visitedLexicalScopeNodesStackStorage: IVisitedLexicalScopeNodesStackStorage = getStorageInstance();

部分文件因为文件数量过多而无法显示