blob: 046e36b9d1917e43b6c6bafeb36cad475927c7e7 [file] [log] [blame]
Tim van der Lippe652ccb72021-05-27 17:07:12 +01001"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.parseLiterals = void 0;
4const typescript_1 = require("./strategies/typescript");
5function parseLiterals(source, options = {}) {
6 const strategy = {
7 ...typescript_1.default,
8 ...(options.strategy || {})
9 };
10 const literals = [];
11 const visitedTemplates = [];
12 strategy.walkNodes(strategy.getRootNode(source, options.fileName), node => {
13 if (strategy.isTaggedTemplate(node)) {
14 const template = strategy.getTaggedTemplateTemplate(node);
15 visitedTemplates.push(template);
16 literals.push({
17 tag: strategy.getTagText(node),
18 parts: strategy.getTemplateParts(template)
19 });
20 }
21 else if (strategy.isTemplate(node) && !visitedTemplates.includes(node)) {
22 literals.push({
23 parts: strategy.getTemplateParts(node)
24 });
25 }
26 });
27 return literals;
28}
29exports.parseLiterals = parseLiterals;
30//# sourceMappingURL=parseLiterals.js.map