All files / src/nodes FunctionTypeName.js

100% Statements 11/11
100% Branches 10/10
100% Functions 4/4
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45        55x   55x   55x 40x                 55x 40x       55x 40x       55x 40x                           55x  
const {
  doc: {
    builders: { group, indent, line }
  }
} = require('prettier');
 
const printSeparatedList = require('./print-separated-list');
 
const returnTypes = (node, path, print) =>
  node.returnTypes.length > 0
    ? [
        line,
        'returns (',
        printSeparatedList(path.map(print, 'returnTypes')),
        ')'
      ]
    : '';
 
const visibility = (node) =>
  node.visibility && node.visibility !== 'default'
    ? [line, node.visibility]
    : '';
 
const stateMutability = (node) =>
  node.stateMutability && node.stateMutability !== 'default'
    ? [line, node.stateMutability]
    : '';
 
const FunctionTypeName = {
  print: ({ node, path, print }) => [
    'function(',
    printSeparatedList(path.map(print, 'parameterTypes')),
    ')',
    indent(
      group([
        visibility(node),
        stateMutability(node),
        returnTypes(node, path, print)
      ])
    )
  ]
};
 
module.exports = FunctionTypeName;