Ignore:
Timestamp:
12/12/24 17:06:06 (5 weeks ago)
Author:
stefan toskovski <stefantoska84@…>
Branches:
main
Parents:
d565449
Message:

Pred finalna verzija

File:
1 edited

Legend:

Unmodified
Added
Removed
  • imaps-frontend/node_modules/@babel/generator/lib/generators/methods.js

    rd565449 r0c6b92a  
    1212exports._params = _params;
    1313exports._predicate = _predicate;
     14exports._shouldPrintArrowParamsParens = _shouldPrintArrowParamsParens;
    1415var _t = require("@babel/types");
    1516var _index = require("../node/index.js");
     
    1819} = _t;
    1920function _params(node, idNode, parentNode) {
    20   this.print(node.typeParameters, node);
     21  this.print(node.typeParameters);
    2122  const nameInfo = _getFuncIdName.call(this, idNode, parentNode);
    2223  if (nameInfo) {
     
    2425  }
    2526  this.tokenChar(40);
    26   this._parameters(node.params, node);
    27   this.tokenChar(41);
     27  this._parameters(node.params, ")");
    2828  const noLineTerminator = node.type === "ArrowFunctionExpression";
    29   this.print(node.returnType, node, noLineTerminator);
     29  this.print(node.returnType, noLineTerminator);
    3030  this._noLineTerminator = noLineTerminator;
    3131}
    32 function _parameters(parameters, parent) {
    33   const exit = this.enterForStatementInit(false);
     32function _parameters(parameters, endToken) {
     33  const exit = this.enterDelimited();
     34  const trailingComma = this.shouldPrintTrailingComma(endToken);
    3435  const paramLength = parameters.length;
    3536  for (let i = 0; i < paramLength; i++) {
    36     this._param(parameters[i], parent);
    37     if (i < parameters.length - 1) {
    38       this.tokenChar(44);
     37    this._param(parameters[i]);
     38    if (trailingComma || i < paramLength - 1) {
     39      this.token(",", null, i);
    3940      this.space();
    4041    }
    4142  }
     43  this.token(endToken);
    4244  exit();
    4345}
    44 function _param(parameter, parent) {
    45   this.printJoin(parameter.decorators, parameter);
    46   this.print(parameter, parent);
     46function _param(parameter) {
     47  this.printJoin(parameter.decorators);
     48  this.print(parameter);
    4749  if (parameter.optional) {
    4850    this.tokenChar(63);
    4951  }
    50   this.print(parameter.typeAnnotation, parameter);
     52  this.print(parameter.typeAnnotation);
    5153}
    5254function _methodHead(node) {
     
    6870  if (node.computed) {
    6971    this.tokenChar(91);
    70     this.print(key, node);
     72    this.print(key);
    7173    this.tokenChar(93);
    7274  } else {
    73     this.print(key, node);
     75    this.print(key);
    7476  }
    7577  if (node.optional) {
     
    8486    }
    8587    this.space();
    86     this.print(node.predicate, node, noLineTerminatorAfter);
     88    this.print(node.predicate, noLineTerminatorAfter);
    8789  }
    8890}
     
    9092  if (node.async) {
    9193    this.word("async");
    92     this._endsWithInnerRaw = false;
     94    if (!this.format.preserveFormat) {
     95      this._endsWithInnerRaw = false;
     96    }
    9397    this.space();
    9498  }
    9599  this.word("function");
    96100  if (node.generator) {
    97     this._endsWithInnerRaw = false;
     101    if (!this.format.preserveFormat) {
     102      this._endsWithInnerRaw = false;
     103    }
    98104    this.tokenChar(42);
    99105  }
    100106  this.space();
    101107  if (node.id) {
    102     this.print(node.id, node);
     108    this.print(node.id);
    103109  }
    104110  this._params(node, node.id, parent);
     
    110116  this._functionHead(node, parent);
    111117  this.space();
    112   this.print(node.body, node);
     118  this.print(node.body);
    113119}
    114120function ArrowFunctionExpression(node, parent) {
     
    117123    this.space();
    118124  }
    119   let firstParam;
    120   if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) {
    121     this.print(firstParam, node, true);
     125  if (this._shouldPrintArrowParamsParens(node)) {
     126    this._params(node, undefined, parent);
    122127  } else {
    123     this._params(node, undefined, parent);
     128    this.print(node.params[0], true);
    124129  }
    125130  this._predicate(node, true);
     
    129134  this.space();
    130135  this.tokenContext |= _index.TokenContext.arrowBody;
    131   this.print(node.body, node);
     136  this.print(node.body);
    132137}
    133 function hasTypesOrComments(node, param) {
    134   var _param$leadingComment, _param$trailingCommen;
    135   return !!(node.typeParameters || node.returnType || node.predicate || param.typeAnnotation || param.optional || (_param$leadingComment = param.leadingComments) != null && _param$leadingComment.length || (_param$trailingCommen = param.trailingComments) != null && _param$trailingCommen.length);
     138function _shouldPrintArrowParamsParens(node) {
     139  var _firstParam$leadingCo, _firstParam$trailingC;
     140  if (node.params.length !== 1) return true;
     141  if (node.typeParameters || node.returnType || node.predicate) {
     142    return true;
     143  }
     144  const firstParam = node.params[0];
     145  if (!isIdentifier(firstParam) || firstParam.typeAnnotation || firstParam.optional || (_firstParam$leadingCo = firstParam.leadingComments) != null && _firstParam$leadingCo.length || (_firstParam$trailingC = firstParam.trailingComments) != null && _firstParam$trailingC.length) {
     146    return true;
     147  }
     148  if (this.tokenMap) {
     149    if (node.loc == null) return true;
     150    if (this.tokenMap.findMatching(node, "(") !== null) return true;
     151    const arrowToken = this.tokenMap.findMatching(node, "=>");
     152    if ((arrowToken == null ? void 0 : arrowToken.loc) == null) return true;
     153    return arrowToken.loc.start.line !== node.loc.start.line;
     154  }
     155  if (this.format.retainLines) return true;
     156  return false;
    136157}
    137158function _getFuncIdName(idNode, parent) {
Note: See TracChangeset for help on using the changeset viewer.