UNPKG

prettier-plugin-awk

Version:

[![tests](https://github.com/Beaglefoot/prettier-plugin-awk/actions/workflows/tests.yml/badge.svg)](https://github.com/Beaglefoot/prettier-plugin-awk/actions/workflows/tests.yml) [![npm](https://img.shields.io/npm/v/prettier-plugin-awk)](https://www.npmjs

42 lines 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatIfStatement = void 0; const prettier_1 = require("prettier"); const { hardline, group, indent, line, softline, ifBreak } = prettier_1.doc.builders; const formatIfStatement = (path, _options, print) => { const node = path.getValue(); const result = []; result.push(group([ 'if (', indent([ ifBreak('\\'), softline, path.call(print, 'firstNamedChild'), ifBreak('\\'), ]), softline, ')', ])); switch (node.children[4].type) { case ';': result.push(';'); break; case 'block': result.push(' ', path.call(print, 'children', 4)); break; case 'comment': result.push(' ', path.call(print, 'children', 4), node.children[5].type === 'block' ? [hardline, path.call(print, 'children', 5)] : indent([hardline, path.call(print, 'children', 5)])); break; default: result.push(group([indent([line, path.call(print, 'children', 4)])])); } const elseClause = node.lastNamedChild.type === 'else_clause' ? node.lastNamedChild : null; if (elseClause) { result.push(hardline, 'else ', path.call(print, 'lastChild', 'lastChild')); } return result; }; exports.formatIfStatement = formatIfStatement; //# sourceMappingURL=if_statement.js.map