UNPKG

cannabis

Version:
61 lines 2.35 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var astq_1 = __importDefault(require("astq")); var ts_simple_ast_extra_1 = require("ts-simple-ast-extra"); var astNode_1 = require("../node/astNode"); var config_1 = require("../query/config"); var attributes_1 = require("./attributes"); var attributeTypes_1 = require("./attributeTypes"); var functions_1 = require("./functions"); var astq; function getTypeScriptAstq() { if (!astq) { astq = new astq_1.default(); astq.adapter({ taste: function (node) { return astNode_1.isASTNode(node) && !!astNode_1.getASTNodeKindName(node); }, getParentNode: function (node) { if (!node) { return null; } var parent = astNode_1.getASTNodeParent(node); if (!parent) { return null; } if (node === parent) { return null; } return parent || null; }, getChildNodes: function (node) { if (node) { var r = astNode_1.getASTNodeChildren(node, config_1.getConfig('getChildren')) || []; if (config_1.getConfig('includeJSDocTagNodes') && ts_simple_ast_extra_1.isNode(node) && ts_simple_ast_extra_1.tsMorph.TypeGuards.isJSDocableNode(node)) { r.push.apply(r, node.getJsDocs()); } return r; } else { return []; } }, getNodeType: function (node) { return node && astNode_1.getASTNodeKindName(node) || 'undefined'; }, getNodeAttrNames: function (node) { return attributeTypes_1.attributeNames; }, getNodeAttrValue: function (node, attr) { return attributes_1.getAttribute(node, attr) || null; } }); functions_1.installFunctions(astq); } return astq; } exports.getTypeScriptAstq = getTypeScriptAstq; //# sourceMappingURL=adapter.js.map