@effect/language-service 0.16.5 → 0.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +22 -12
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -2887,21 +2887,31 @@ var effectGenToFn = createRefactor({
2887
2887
  const parseEffectGenNode = fn("asyncAwaitToGen.apply")(function* (node) {
2888
2888
  const effectGen2 = yield* effectGen(node);
2889
2889
  let pipeArgs2 = ts.factory.createNodeArray([]);
2890
- let nodeToReplace2 = node.parent;
2891
- if (ts.isPropertyAccessExpression(node.parent) && node.parent.name.text === "pipe" && ts.isCallExpression(node.parent.parent)) {
2892
- pipeArgs2 = node.parent.parent.arguments;
2893
- nodeToReplace2 = node.parent.parent.parent;
2894
- }
2895
- while (nodeToReplace2) {
2896
- if (ts.isArrowFunction(nodeToReplace2) || ts.isFunctionDeclaration(nodeToReplace2) || ts.isMethodDeclaration(nodeToReplace2)) {
2897
- return { ...effectGen2, pipeArgs: pipeArgs2, nodeToReplace: nodeToReplace2 };
2890
+ let nodeToReplace2 = node;
2891
+ while (nodeToReplace2.parent) {
2892
+ const parent = nodeToReplace2.parent;
2893
+ if (ts.isConciseBody(nodeToReplace2) && ts.isArrowFunction(parent) && parent.body === nodeToReplace2) {
2894
+ return { ...effectGen2, pipeArgs: pipeArgs2, nodeToReplace: parent };
2895
+ }
2896
+ if ((ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent)) && parent.body === nodeToReplace2) {
2897
+ return { ...effectGen2, pipeArgs: pipeArgs2, nodeToReplace: parent };
2898
+ }
2899
+ if (ts.isBlock(parent) && parent.statements.length === 1 && parent.statements[0] === nodeToReplace2) {
2900
+ nodeToReplace2 = parent;
2901
+ continue;
2902
+ }
2903
+ if (ts.isReturnStatement(parent) && parent.expression === nodeToReplace2) {
2904
+ nodeToReplace2 = parent;
2905
+ continue;
2898
2906
  }
2899
- if (ts.isConciseBody(nodeToReplace2) || ts.isReturnStatement(nodeToReplace2)) {
2900
- nodeToReplace2 = nodeToReplace2.parent;
2907
+ if (ts.isPropertyAccessExpression(parent) && parent.expression === nodeToReplace2 && parent.name.text === "pipe" && ts.isCallExpression(parent.parent)) {
2908
+ pipeArgs2 = ts.factory.createNodeArray(pipeArgs2.concat(parent.parent.arguments));
2909
+ nodeToReplace2 = parent.parent;
2901
2910
  continue;
2902
2911
  }
2903
- if (ts.isBlock(nodeToReplace2) && nodeToReplace2.statements.length === 1) {
2904
- nodeToReplace2 = nodeToReplace2.parent;
2912
+ if (ts.isCallExpression(parent) && ts.isIdentifier(parent.expression) && parent.expression.text === "pipe" && parent.arguments.length > 0 && parent.arguments[0] === nodeToReplace2) {
2913
+ pipeArgs2 = ts.factory.createNodeArray(pipeArgs2.concat(parent.arguments.slice(1)));
2914
+ nodeToReplace2 = parent;
2905
2915
  continue;
2906
2916
  }
2907
2917
  break;