mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-09 05:08:28 +08:00
R=jacktfranklin@chromium.org Bug: 1213034 Change-Id: I5da8225f60b53870a1c67d6b5d02a464c08f4eb2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2917088 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.parseLiterals = void 0;
|
|
const typescript_1 = require("./strategies/typescript");
|
|
function parseLiterals(source, options = {}) {
|
|
const strategy = {
|
|
...typescript_1.default,
|
|
...(options.strategy || {})
|
|
};
|
|
const literals = [];
|
|
const visitedTemplates = [];
|
|
strategy.walkNodes(strategy.getRootNode(source, options.fileName), node => {
|
|
if (strategy.isTaggedTemplate(node)) {
|
|
const template = strategy.getTaggedTemplateTemplate(node);
|
|
visitedTemplates.push(template);
|
|
literals.push({
|
|
tag: strategy.getTagText(node),
|
|
parts: strategy.getTemplateParts(template)
|
|
});
|
|
}
|
|
else if (strategy.isTemplate(node) && !visitedTemplates.includes(node)) {
|
|
literals.push({
|
|
parts: strategy.getTemplateParts(node)
|
|
});
|
|
}
|
|
});
|
|
return literals;
|
|
}
|
|
exports.parseLiterals = parseLiterals;
|
|
//# sourceMappingURL=parseLiterals.js.map
|