dist/ruby/nodes/heredocs.js in prettier-2.0.0 vs dist/ruby/nodes/heredocs.js in prettier-2.1.0
- old
+ new
@@ -6,25 +6,25 @@
exports.printHeredoc = void 0;
const prettier_1 = __importDefault(require("../../prettier"));
const utils_1 = require("../../utils");
const { group, lineSuffix, join } = prettier_1.default;
const printHeredoc = (path, opts, print) => {
- const { body, ending } = path.getValue();
- const parts = body.map((part, index) => {
- if (part.type !== "@tstring_content") {
- // In this case, the part of the string is an embedded expression
- return path.call(print, "body", index);
+ const node = path.getValue();
+ // Print out each part of the heredoc to its own doc node.
+ const parts = path.map((partPath) => {
+ const part = partPath.getValue();
+ if (part.type !== "tstring_content") {
+ return print(partPath);
}
- // In this case, the part of the string is just regular string content
- return join(utils_1.literallineWithoutBreakParent, part.body.split(/\r?\n/));
- });
+ return join(utils_1.literallineWithoutBreakParent, part.value.split(/\r?\n/));
+ }, "parts");
// We use a literalline break because matching indentation is required
// for the heredoc contents and ending. If the line suffix contains a
// break-parent, all ancestral groups are broken, and heredocs automatically
// break lines in groups they appear in. We prefer them to appear in-line if
// possible, so we use a literalline without the break-parent.
return group([
path.call(print, "beging"),
- lineSuffix(group([utils_1.literallineWithoutBreakParent, ...parts, ending]))
+ lineSuffix(group([utils_1.literallineWithoutBreakParent, ...parts, node.ending]))
]);
};
exports.printHeredoc = printHeredoc;