js-ast-parser
Version:
把javascript代码字符串解析为AST对象
31 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Definition = void 0;
const constants_1 = require("../../constants");
class Definition {
constructor(astNode, definitionType, definitionCode, scope) {
this.astNode = astNode;
this.definitionType = definitionType;
this.definitionCode = definitionCode;
this.scope = scope;
this.type = 'Definition';
if (astNode === undefined)
debugger;
switch (astNode.code) {
case constants_1.NodeCode.AssignmentExpression:
this.identifier = astNode.left.identifier;
break;
case constants_1.NodeCode.IdentifierLiteralExpression:
this.identifier = astNode.identifier;
break;
case constants_1.NodeCode.FunctionDeclarationStatement:
this.identifier = astNode.identifier.identifier;
break;
case constants_1.NodeCode.ClassDeclarationStatement:
this.identifier = astNode.className.identifier;
break;
}
}
}
exports.Definition = Definition;
//# sourceMappingURL=Definition.js.map