<commit_before>import NodePatcher from './NodePatcher';

export default class FunctionApplicationPatcher extends NodePatcher {
  constructor(node, context, editor, fn, args) {
    super(node, context, editor);
    this.fn = fn;
    this.args = args;
    fn.setRequiresExpression();
    args.forEach(arg => arg.setRequiresExpression());
  }

  patch() {
    let { fn, args } = this;
    fn.patch();
    args.forEach(arg => arg.patch());
  }
}<commit_msg>Add basic support for inserting function call parentheses.<commit_after>import NodePatcher from './NodePatcher';

export default class FunctionApplicationPatcher extends NodePatcher {
  constructor(node, context, editor, fn, args) {
    super(node, context, editor);
    this.fn = fn;
    this.args = args;
    fn.setRequiresExpression();
    args.forEach(arg => arg.setRequiresExpression());
  }

  patch() {
    let { fn, args } = this;
    let implicitCall = this.isImplicitCall();
    fn.patch();
    if (implicitCall) {
      this.overwrite(fn.after, args[0].before, '(');
    }
    args.forEach(arg => arg.patch());
    if (implicitCall) {
      this.insertAfter(')');
    }
  }

  isImplicitCall() {
    return !this.fn.hasTokenAfter('CALL_START');
  }
}
{'fraction_non_alphanumeric': 0.14332784184514002, 'fraction_numerical': 0.0008237232289950577, 'mean_word_length': 3.4669117647058822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7578210', 'n_tokens_mistral': 385, 'n_tokens_neox': 377, 'n_words': 86}