export function extractType()

in src/parser/WDL/utils/utils.js [256:280]


export function extractType(declarationNode) {
  if (declarationNode === undefined || declarationNode === null) {
    throw new Error('WDL type node could not be empty');
  }

  let res = '';
  if (declarationNode.source_string) {
    res = declarationNode.source_string;
  } else if (declarationNode.attributes) {
    if (declarationNode.name === 'Type') {
      const attr = declarationNode.attributes;
      res = `${attr.name.source_string}[`;
      attr.subtype.list.map(item => extractType(item))
        .forEach((item, idx) => {
          res += idx === 0 ? item : `, ${item}`;
        }, '');

      res += ']';
    } else {
      res = `${extractType(declarationNode.attributes.innerType)}`;
      res += `${declarationNode.name === 'NonEmptyType' ? '+' : '?'}`;
    }
  }
  return res;
}