(path: any, config: any, options: any, printPath: any)
| 186 | export { Printer }; |
| 187 | |
| 188 | function genericPrint(path: any, config: any, options: any, printPath: any) { |
| 189 | assert.ok(path instanceof FastPath); |
| 190 | |
| 191 | const node = path.getValue(); |
| 192 | const parts = []; |
| 193 | const linesWithoutParens = genericPrintNoParens(path, config, printPath); |
| 194 | |
| 195 | if (!node || linesWithoutParens.isEmpty()) { |
| 196 | return linesWithoutParens; |
| 197 | } |
| 198 | |
| 199 | let shouldAddParens = false; |
| 200 | const decoratorsLines = printDecorators(path, printPath); |
| 201 | |
| 202 | if (decoratorsLines.isEmpty()) { |
| 203 | // Nodes with decorators can't have parentheses, so we can avoid |
| 204 | // computing path.needsParens() except in this case. |
| 205 | if (!options.avoidRootParens) { |
| 206 | shouldAddParens = path.needsParens(); |
| 207 | } |
| 208 | } else { |
| 209 | parts.push(decoratorsLines); |
| 210 | } |
| 211 | |
| 212 | if (shouldAddParens) { |
| 213 | parts.unshift("("); |
| 214 | } |
| 215 | |
| 216 | parts.push(linesWithoutParens); |
| 217 | |
| 218 | if (shouldAddParens) { |
| 219 | parts.push(")"); |
| 220 | } |
| 221 | |
| 222 | return concat(parts); |
| 223 | } |
| 224 | |
| 225 | // Note that the `options` parameter of this function is what other |
| 226 | // functions in this file call the `config` object (that is, the |
no test coverage detected
searching dependent graphs…