@effect/language-service 0.19.0 → 0.20.1

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.
package/README.md CHANGED
@@ -60,6 +60,9 @@ And you're done! You'll now be able to use a set of refactor and diagnostics tha
60
60
  - Remove unnecessary `Effect.gen` definitions that contains a single `yield` statement.
61
61
  - Wrap an `Effect` expression with `Effect.gen`
62
62
 
63
+ ### Miscellaneous
64
+ - "Go to definition" for RpcClient will resolve to the Rpc definition
65
+
63
66
  ## Options
64
67
 
65
68
  Few options can be provided alongside the initialization of the Language Service Plugin.
package/index.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all3) => {
5
5
  __defProp(target, name, { get: all3[name], enumerable: true });
6
6
  };
7
7
 
8
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Function.js
8
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Function.js
9
9
  var isFunction = (input) => typeof input === "function";
10
10
  var dual = function(arity, body) {
11
11
  if (typeof arity === "function") {
@@ -102,7 +102,7 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
102
102
  }
103
103
  }
104
104
 
105
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Either.js
105
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Either.js
106
106
  var Either_exports = {};
107
107
  __export(Either_exports, {
108
108
  Do: () => Do,
@@ -146,7 +146,7 @@ __export(Either_exports, {
146
146
  zipWith: () => zipWith
147
147
  });
148
148
 
149
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Equivalence.js
149
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Equivalence.js
150
150
  var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
151
151
  var array = (item) => make((self, that) => {
152
152
  if (self.length !== that.length) {
@@ -161,7 +161,7 @@ var array = (item) => make((self, that) => {
161
161
  return true;
162
162
  });
163
163
 
164
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/doNotation.js
164
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/doNotation.js
165
165
  var let_ = (map5) => dual(3, (self, name, f) => map5(self, (a) => Object.assign({}, a, {
166
166
  [name]: f(a)
167
167
  })));
@@ -172,11 +172,11 @@ var bind = (map5, flatMap4) => dual(3, (self, name, f) => flatMap4(self, (a) =>
172
172
  [name]: b
173
173
  }))));
174
174
 
175
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/version.js
176
- var moduleVersion = "3.16.3";
175
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/version.js
176
+ var moduleVersion = "3.16.5";
177
177
  var getCurrentVersion = () => moduleVersion;
178
178
 
179
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/GlobalValue.js
179
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/GlobalValue.js
180
180
  var globalStoreId = `effect/GlobalValue/globalStoreId/${/* @__PURE__ */ getCurrentVersion()}`;
181
181
  var globalStore;
182
182
  var globalValue = (id, compute) => {
@@ -190,7 +190,7 @@ var globalValue = (id, compute) => {
190
190
  return globalStore.get(id);
191
191
  };
192
192
 
193
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Predicate.js
193
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Predicate.js
194
194
  var isString = (input) => typeof input === "string";
195
195
  var isNumber = (input) => typeof input === "number";
196
196
  var isBoolean = (input) => typeof input === "boolean";
@@ -199,10 +199,10 @@ var isRecordOrArray = (input) => typeof input === "object" && input !== null;
199
199
  var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
200
200
  var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
201
201
 
202
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/errors.js
202
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/errors.js
203
203
  var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
204
204
 
205
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Utils.js
205
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Utils.js
206
206
  var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
207
207
  var isGenKind = (u) => isObject(u) && GenKindTypeId in u;
208
208
  var GenKindImpl = class {
@@ -338,7 +338,7 @@ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forc
338
338
  var genConstructor = function* () {
339
339
  }.constructor;
340
340
 
341
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Hash.js
341
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Hash.js
342
342
  var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
343
343
  var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
344
344
  var hash = (self) => {
@@ -437,7 +437,7 @@ var cached = function() {
437
437
  return hash2;
438
438
  };
439
439
 
440
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Equal.js
440
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Equal.js
441
441
  var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
442
442
  function equals() {
443
443
  if (arguments.length === 1) {
@@ -490,7 +490,7 @@ function compareBoth(self, that) {
490
490
  }
491
491
  var isEqual = (u) => hasProperty(u, symbol2);
492
492
 
493
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Inspectable.js
493
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Inspectable.js
494
494
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
495
495
  var toJSON = (x) => {
496
496
  try {
@@ -542,7 +542,7 @@ var redact = (u) => {
542
542
  return u;
543
543
  };
544
544
 
545
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Pipeable.js
545
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Pipeable.js
546
546
  var pipeArguments = (self, args) => {
547
547
  switch (args.length) {
548
548
  case 0:
@@ -575,10 +575,10 @@ var pipeArguments = (self, args) => {
575
575
  }
576
576
  };
577
577
 
578
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/opCodes/effect.js
578
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/opCodes/effect.js
579
579
  var OP_COMMIT = "Commit";
580
580
 
581
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/effectable.js
581
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/effectable.js
582
582
  var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
583
583
  var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
584
584
  var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
@@ -665,7 +665,7 @@ var StructuralCommitPrototype = {
665
665
  ...StructuralPrototype
666
666
  };
667
667
 
668
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/option.js
668
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/option.js
669
669
  var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
670
670
  var CommonProto = {
671
671
  ...EffectPrototype,
@@ -723,7 +723,7 @@ var some = (value) => {
723
723
  return a;
724
724
  };
725
725
 
726
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/either.js
726
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/either.js
727
727
  var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
728
728
  var CommonProto2 = {
729
729
  ...EffectPrototype,
@@ -788,7 +788,7 @@ var getLeft = (self) => isRight(self) ? none : some(self.left);
788
788
  var getRight = (self) => isLeft(self) ? none : some(self.right);
789
789
  var fromOption = /* @__PURE__ */ dual(2, (self, onNone) => isNone(self) ? left(onNone()) : right(self.value));
790
790
 
791
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Either.js
791
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Either.js
792
792
  var TypeId3 = TypeId2;
793
793
  var right2 = right;
794
794
  var void_ = /* @__PURE__ */ right2(void 0);
@@ -898,13 +898,13 @@ var transposeOption = (self) => {
898
898
  };
899
899
  var transposeMapOption = /* @__PURE__ */ dual(2, (self, f) => isNone(self) ? right2(none) : map(f(self.value), some));
900
900
 
901
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/internal/array.js
901
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/internal/array.js
902
902
  var isNonEmptyArray = (self) => self.length > 0;
903
903
 
904
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Order.js
904
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Order.js
905
905
  var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
906
906
 
907
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Option.js
907
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Option.js
908
908
  var none2 = () => none;
909
909
  var some2 = some;
910
910
  var isNone2 = isNone;
@@ -919,7 +919,7 @@ var fromNullable2 = (nullableValue) => nullableValue == null ? none2() : some2(n
919
919
  var getOrUndefined2 = /* @__PURE__ */ getOrElse2(constUndefined);
920
920
  var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
921
921
 
922
- // node_modules/.pnpm/effect@3.16.3/node_modules/effect/dist/esm/Array.js
922
+ // node_modules/.pnpm/effect@3.16.5/node_modules/effect/dist/esm/Array.js
923
923
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
924
924
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
925
925
  var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
@@ -1137,6 +1137,27 @@ var all2 = (...args) => gen2(function* () {
1137
1137
  var TypeScriptApi = Tag("TypeScriptApi");
1138
1138
  var TypeScriptProgram = Tag("TypeScriptProgram");
1139
1139
  var ChangeTracker = Tag("ChangeTracker");
1140
+ function parsePackageContentNameAndVersionFromScope(v) {
1141
+ if (!isObject(v)) return;
1142
+ if (!hasProperty(v, "packageJsonScope")) return;
1143
+ if (!v.packageJsonScope) return;
1144
+ const packageJsonScope = v.packageJsonScope;
1145
+ if (!hasProperty(packageJsonScope, "contents")) return;
1146
+ if (!hasProperty(packageJsonScope.contents, "packageJsonContent")) return;
1147
+ const packageJsonContent = packageJsonScope.contents.packageJsonContent;
1148
+ if (!hasProperty(packageJsonContent, "name")) return;
1149
+ if (!hasProperty(packageJsonContent, "version")) return;
1150
+ const { name, version } = packageJsonContent;
1151
+ if (!isString(name)) return;
1152
+ if (!isString(version)) return;
1153
+ const hasEffectInPeerDependencies = hasProperty(packageJsonContent, "peerDependencies") && isObject(packageJsonContent.peerDependencies) && hasProperty(packageJsonContent.peerDependencies, "effect");
1154
+ return {
1155
+ name: name.toLowerCase(),
1156
+ version: version.toLowerCase(),
1157
+ hasEffectInPeerDependencies,
1158
+ contents: packageJsonContent
1159
+ };
1160
+ }
1140
1161
 
1141
1162
  // src/core/AST.ts
1142
1163
  function collectSelfAndAncestorNodesInRange(node, textRange) {
@@ -1485,6 +1506,19 @@ var createReturnYieldStarStatement = fn("AST.createReturnYieldStarStatement")(
1485
1506
  );
1486
1507
  }
1487
1508
  );
1509
+ var parsePipeCall = fn("AST.parsePipeCall")(
1510
+ function* (node) {
1511
+ const ts = yield* service(TypeScriptApi);
1512
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name.text === "pipe") {
1513
+ return { node, subject: node.expression.expression, args: node.arguments };
1514
+ }
1515
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "pipe" && node.arguments.length > 0) {
1516
+ const [subject, ...args] = node.arguments;
1517
+ return { node, subject, args };
1518
+ }
1519
+ return yield* fail(new NodeNotFoundError());
1520
+ }
1521
+ );
1488
1522
 
1489
1523
  // src/core/LSP.ts
1490
1524
  var RefactorNotApplicableError = class {
@@ -2616,11 +2650,45 @@ var genFunctionStar = createCompletion({
2616
2650
  })
2617
2651
  });
2618
2652
 
2653
+ // src/completions/rpcMakeClasses.ts
2654
+ var rpcMakeClasses = createCompletion({
2655
+ name: "rpcMakeClasses",
2656
+ apply: fn("rpcMakeClasses")(function* (sourceFile, position) {
2657
+ const ts = yield* service(TypeScriptApi);
2658
+ const maybeInfos = yield* option(
2659
+ parseDataForExtendsClassCompletion(sourceFile, position)
2660
+ );
2661
+ if (isNone2(maybeInfos)) return [];
2662
+ const { accessedObject, className, replacementSpan } = maybeInfos.value;
2663
+ const rpcName = yield* option(
2664
+ findImportedModuleIdentifierByPackageAndNameOrBarrel(
2665
+ sourceFile,
2666
+ "@effect/rpc",
2667
+ "Rpc"
2668
+ )
2669
+ );
2670
+ const rpcIdentifier = match2(rpcName, {
2671
+ onNone: () => "Rpc",
2672
+ onSome: (_) => _.text
2673
+ });
2674
+ if (rpcIdentifier !== accessedObject.text) return [];
2675
+ const name = className.text;
2676
+ return [{
2677
+ name: `make("${name}")`,
2678
+ kind: ts.ScriptElementKind.constElement,
2679
+ insertText: `${rpcIdentifier}.make("${name}", {${"${0}"}}) {}`,
2680
+ replacementSpan,
2681
+ isSnippet: true
2682
+ }];
2683
+ })
2684
+ });
2685
+
2619
2686
  // src/completions.ts
2620
2687
  var completions = [
2621
2688
  effectSchemaSelfInClasses,
2622
2689
  effectSelfInClasses,
2623
2690
  contextSelfInClasses,
2691
+ rpcMakeClasses,
2624
2692
  genFunctionStar,
2625
2693
  fnFunctionStar,
2626
2694
  effectDataClasses
@@ -2640,27 +2708,6 @@ function parse(config) {
2640
2708
  // src/diagnostics/duplicatePackage.ts
2641
2709
  var checkedPackagesCache = /* @__PURE__ */ new Map();
2642
2710
  var programResolvedCacheSize = /* @__PURE__ */ new Map();
2643
- function parsePackageContentNameAndVersion(v) {
2644
- if (!isObject(v)) return;
2645
- if (!hasProperty(v, "packageJsonScope")) return;
2646
- if (!v.packageJsonScope) return;
2647
- const packageJsonScope = v.packageJsonScope;
2648
- if (!hasProperty(packageJsonScope, "contents")) return;
2649
- if (!hasProperty(packageJsonScope.contents, "packageJsonContent")) return;
2650
- const packageJsonContent = packageJsonScope.contents.packageJsonContent;
2651
- if (!hasProperty(packageJsonContent, "name")) return;
2652
- if (!hasProperty(packageJsonContent, "version")) return;
2653
- const { name, version } = packageJsonContent;
2654
- if (!isString(name)) return;
2655
- if (!isString(version)) return;
2656
- const hasEffectInPeerDependencies = hasProperty(packageJsonContent, "peerDependencies") && isObject(packageJsonContent.peerDependencies) && hasProperty(packageJsonContent.peerDependencies, "effect");
2657
- return {
2658
- name: name.toLowerCase(),
2659
- version: version.toLowerCase(),
2660
- hasEffectInPeerDependencies,
2661
- contents: packageJsonContent
2662
- };
2663
- }
2664
2711
  var duplicatePackage = createDiagnostic({
2665
2712
  name: "duplicatePackage",
2666
2713
  code: 6,
@@ -2677,7 +2724,7 @@ var duplicatePackage = createDiagnostic({
2677
2724
  const seenPackages = /* @__PURE__ */ new Set();
2678
2725
  resolvedPackages = {};
2679
2726
  program.getSourceFiles().map((_) => {
2680
- const packageInfo = parsePackageContentNameAndVersion(_);
2727
+ const packageInfo = parsePackageContentNameAndVersionFromScope(_);
2681
2728
  if (!packageInfo) return;
2682
2729
  const packageNameAndVersion = packageInfo.name + "@" + packageInfo.version;
2683
2730
  if (seenPackages.has(packageNameAndVersion)) return;
@@ -2858,6 +2905,75 @@ var missingEffectError = createDiagnostic({
2858
2905
  })
2859
2906
  });
2860
2907
 
2908
+ // src/diagnostics/missingReturnYieldStar.ts
2909
+ var missingReturnYieldStar = createDiagnostic({
2910
+ name: "missingReturnYieldStar",
2911
+ code: 7,
2912
+ apply: fn("missingReturnYieldStar.apply")(function* (sourceFile) {
2913
+ const ts = yield* service(TypeScriptApi);
2914
+ const typeChecker = yield* service(TypeCheckerApi);
2915
+ const effectDiagnostics = [];
2916
+ const brokenYields = /* @__PURE__ */ new Set();
2917
+ const nodeToVisit = [];
2918
+ const appendNodeToVisit = (node) => {
2919
+ nodeToVisit.push(node);
2920
+ return void 0;
2921
+ };
2922
+ ts.forEachChild(sourceFile, appendNodeToVisit);
2923
+ while (nodeToVisit.length > 0) {
2924
+ const node = nodeToVisit.shift();
2925
+ ts.forEachChild(node, appendNodeToVisit);
2926
+ if (ts.isYieldExpression(node) && node.expression && node.asteriskToken) {
2927
+ const type = typeChecker.getTypeAtLocation(node.expression);
2928
+ const maybeEffect = yield* option(effectType(type, node.expression));
2929
+ if (isSome2(maybeEffect) && maybeEffect.value.A.flags & ts.TypeFlags.Never) {
2930
+ const generatorFunctionOrReturnStatement = ts.findAncestor(
2931
+ node,
2932
+ (_) => ts.isFunctionExpression(_) || ts.isFunctionDeclaration(_) || ts.isMethodDeclaration(_) || ts.isReturnStatement(_)
2933
+ );
2934
+ if (generatorFunctionOrReturnStatement && !ts.isReturnStatement(generatorFunctionOrReturnStatement)) {
2935
+ if (generatorFunctionOrReturnStatement && generatorFunctionOrReturnStatement.parent) {
2936
+ const effectGenNode = generatorFunctionOrReturnStatement.parent;
2937
+ const effectGenLike = yield* pipe(
2938
+ effectGen(effectGenNode),
2939
+ orElse3(() => effectFnUntracedGen(effectGenNode)),
2940
+ orElse3(() => effectFnGen(effectGenNode)),
2941
+ option
2942
+ );
2943
+ if (isSome2(effectGenLike)) {
2944
+ brokenYields.add(node);
2945
+ }
2946
+ }
2947
+ }
2948
+ }
2949
+ }
2950
+ }
2951
+ brokenYields.forEach((node) => {
2952
+ const fix = node.expression ? [{
2953
+ fixName: "missingReturnYieldStar_fix",
2954
+ description: "Add return statement",
2955
+ apply: gen2(function* () {
2956
+ const changeTracker = yield* service(ChangeTracker);
2957
+ changeTracker.replaceNode(
2958
+ sourceFile,
2959
+ node,
2960
+ ts.factory.createReturnStatement(
2961
+ node
2962
+ )
2963
+ );
2964
+ })
2965
+ }] : [];
2966
+ effectDiagnostics.push({
2967
+ node,
2968
+ category: ts.DiagnosticCategory.Error,
2969
+ messageText: `Yielded Effect never completes, so it is best to use a 'return yield*' instead.`,
2970
+ fixes: fix
2971
+ });
2972
+ });
2973
+ return effectDiagnostics;
2974
+ })
2975
+ });
2976
+
2861
2977
  // src/diagnostics/missingStarInYieldEffectGen.ts
2862
2978
  var missingStarInYieldEffectGen = createDiagnostic({
2863
2979
  name: "missingStarInYieldEffectGen",
@@ -2983,9 +3099,115 @@ var diagnostics = [
2983
3099
  missingEffectError,
2984
3100
  floatingEffect,
2985
3101
  missingStarInYieldEffectGen,
2986
- unnecessaryEffectGen2
3102
+ unnecessaryEffectGen2,
3103
+ missingReturnYieldStar
2987
3104
  ];
2988
3105
 
3106
+ // src/goto/effectRpcDefinition.ts
3107
+ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
3108
+ return gen2(function* () {
3109
+ const program = yield* service(TypeScriptProgram);
3110
+ const ts = yield* service(TypeScriptApi);
3111
+ const typeChecker = yield* service(TypeCheckerApi);
3112
+ const textRange = toTextRange(position);
3113
+ function isSymbolFromEffectRpcModule(symbol3) {
3114
+ if (symbol3.valueDeclaration) {
3115
+ const sourceFile2 = symbol3.valueDeclaration.getSourceFile();
3116
+ const packageInfo = parsePackageContentNameAndVersionFromScope(sourceFile2);
3117
+ if (packageInfo && packageInfo.name === "@effect/rpc") {
3118
+ const fileSymbol = typeChecker.getSymbolAtLocation(sourceFile2);
3119
+ return fileSymbol && fileSymbol.exports && fileSymbol.exports.has("isRpc") && fileSymbol.exports.has("make") && fileSymbol.exports.has("fromTaggedRequest");
3120
+ }
3121
+ }
3122
+ return false;
3123
+ }
3124
+ function isSymbolFromEffectRpcClientModule(symbol3) {
3125
+ if (symbol3.valueDeclaration) {
3126
+ const sourceFile2 = symbol3.valueDeclaration.getSourceFile();
3127
+ const packageInfo = parsePackageContentNameAndVersionFromScope(sourceFile2);
3128
+ if (packageInfo && packageInfo.name === "@effect/rpc") {
3129
+ const fileSymbol = typeChecker.getSymbolAtLocation(sourceFile2);
3130
+ return fileSymbol && fileSymbol.exports && fileSymbol.exports.has("RpcClient") && fileSymbol.exports.has("make");
3131
+ }
3132
+ }
3133
+ return false;
3134
+ }
3135
+ let rpcName = null;
3136
+ let callNode = null;
3137
+ for (const node of yield* getAncestorNodesInRange(sourceFile, textRange)) {
3138
+ if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isNodeInRange(textRange)(node.name)) {
3139
+ const type = typeChecker.getTypeAtLocation(node);
3140
+ for (const callSig of type.getCallSignatures()) {
3141
+ if (callSig.parameters.length >= 2 && isSymbolFromEffectRpcClientModule(callSig.parameters[1])) {
3142
+ rpcName = node.name.text;
3143
+ callNode = node.name;
3144
+ }
3145
+ }
3146
+ }
3147
+ }
3148
+ if (rpcName === null || callNode === null) return applicableGotoDefinition;
3149
+ const result = [];
3150
+ const nodeToVisit = [];
3151
+ const appendNodeToVisit = (node) => {
3152
+ nodeToVisit.push(node);
3153
+ return void 0;
3154
+ };
3155
+ const filesToTest = [];
3156
+ for (const programFile of program.getSourceFiles()) {
3157
+ if (programFile.isDeclarationFile) continue;
3158
+ if (programFile.text.indexOf("make") === -1 && programFile.text.indexOf("fromTaggedRequest") === -1) continue;
3159
+ if (programFile.text.indexOf(rpcName) > -1) {
3160
+ filesToTest.unshift(programFile);
3161
+ } else {
3162
+ filesToTest.push(programFile);
3163
+ }
3164
+ }
3165
+ for (const fileToTest of filesToTest) {
3166
+ if (result.length > 0) break;
3167
+ ts.forEachChild(fileToTest, appendNodeToVisit);
3168
+ while (result.length === 0 && nodeToVisit.length > 0) {
3169
+ const node = nodeToVisit.shift();
3170
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && (node.expression.name.text === "make" || node.expression.name.text === "fromTaggedRequest")) {
3171
+ const symbol3 = typeChecker.getSymbolAtLocation(node.expression.name);
3172
+ if (symbol3 && isSymbolFromEffectRpcModule(symbol3)) {
3173
+ const type = typeChecker.getTypeAtLocation(node);
3174
+ const _tag = type.getProperty("_tag");
3175
+ if (_tag) {
3176
+ const tagValue = typeChecker.getTypeOfSymbolAtLocation(_tag, node);
3177
+ if ("value" in tagValue && tagValue.value === rpcName) result.push([node, symbol3]);
3178
+ }
3179
+ }
3180
+ }
3181
+ ts.forEachChild(node, appendNodeToVisit);
3182
+ }
3183
+ }
3184
+ if (result.length === 0) return applicableGotoDefinition;
3185
+ const effectRpcResult = result.map(([node]) => ({
3186
+ fileName: node.getSourceFile().fileName,
3187
+ textSpan: ts.createTextSpan(node.getStart(), node.getEnd() - node.getStart()),
3188
+ kind: ts.ScriptElementKind.constElement,
3189
+ name: rpcName,
3190
+ containerKind: ts.ScriptElementKind.constElement,
3191
+ containerName: rpcName
3192
+ }));
3193
+ if (applicableGotoDefinition) {
3194
+ return {
3195
+ ...applicableGotoDefinition,
3196
+ definitions: (applicableGotoDefinition.definitions || []).concat(effectRpcResult)
3197
+ };
3198
+ }
3199
+ return {
3200
+ textSpan: ts.createTextSpan(callNode.getStart(), callNode.getEnd() - callNode.getStart()),
3201
+ definitions: effectRpcResult
3202
+ };
3203
+ });
3204
+ }
3205
+
3206
+ // src/goto.ts
3207
+ function goto(applicableGotoDefinition, sourceFile, position) {
3208
+ return effectRpcDefinition(applicableGotoDefinition, sourceFile, position);
3209
+ }
3210
+
2989
3211
  // src/quickinfo/dedupeJsDocs.ts
2990
3212
  var SymbolDisplayPartEq = make((fa, fb) => fa.kind === fb.kind && fa.text === fb.text);
2991
3213
  var JSDocTagInfoEq = make(
@@ -3093,20 +3315,14 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
3093
3315
  return gen2(function* () {
3094
3316
  const ts = yield* service(TypeScriptApi);
3095
3317
  const typeChecker = yield* service(TypeCheckerApi);
3096
- if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && node.expression.name.text === "pipe") {
3097
- let graphNode = yield* processLayerGraphNode(ctx, node.expression.expression, void 0);
3098
- for (const entry of node.arguments) {
3318
+ const maybePipe = yield* option(parsePipeCall(node));
3319
+ if (isSome2(maybePipe)) {
3320
+ let graphNode = yield* processLayerGraphNode(ctx, maybePipe.value.subject, void 0);
3321
+ for (const entry of maybePipe.value.args) {
3099
3322
  graphNode = yield* processLayerGraphNode(ctx, entry, graphNode);
3100
3323
  }
3101
3324
  return graphNode;
3102
3325
  }
3103
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "pipe" && node.arguments.length > 0) {
3104
- let graphNode = yield* processLayerGraphNode(ctx, node.arguments[0], void 0);
3105
- for (let i = 1; i < node.arguments.length; i++) {
3106
- graphNode = yield* processLayerGraphNode(ctx, node.arguments[i], graphNode);
3107
- }
3108
- return graphNode;
3109
- }
3110
3326
  if (ts.isCallExpression(node)) {
3111
3327
  const type = typeChecker.getTypeAtLocation(node);
3112
3328
  const maybeLayer = yield* option(layerType(type, node));
@@ -3635,14 +3851,14 @@ var effectGenToFn = createRefactor({
3635
3851
  nodeToReplace2 = parent;
3636
3852
  continue;
3637
3853
  }
3638
- if (ts.isPropertyAccessExpression(parent) && parent.expression === nodeToReplace2 && parent.name.text === "pipe" && ts.isCallExpression(parent.parent)) {
3639
- pipeArgs2 = ts.factory.createNodeArray(pipeArgs2.concat(parent.parent.arguments));
3640
- nodeToReplace2 = parent.parent;
3641
- continue;
3642
- }
3643
- if (ts.isCallExpression(parent) && ts.isIdentifier(parent.expression) && parent.expression.text === "pipe" && parent.arguments.length > 0 && parent.arguments[0] === nodeToReplace2) {
3644
- pipeArgs2 = ts.factory.createNodeArray(pipeArgs2.concat(parent.arguments.slice(1)));
3645
- nodeToReplace2 = parent;
3854
+ const maybePipe = yield* pipe(
3855
+ parsePipeCall(parent),
3856
+ orElse3((e) => parent.parent ? parsePipeCall(parent.parent) : fail(e)),
3857
+ option
3858
+ );
3859
+ if (isSome2(maybePipe) && maybePipe.value.subject === nodeToReplace2) {
3860
+ pipeArgs2 = ts.factory.createNodeArray(pipeArgs2.concat(maybePipe.value.args));
3861
+ nodeToReplace2 = maybePipe.value.node;
3646
3862
  continue;
3647
3863
  }
3648
3864
  break;
@@ -4501,12 +4717,21 @@ var processNode = (node, isVirtualTypeNode) => gen2(function* () {
4501
4717
  [ts.factory.createObjectLiteralExpression(properties, true)].concat(records)
4502
4718
  );
4503
4719
  }
4720
+ if (ts.isParenthesizedTypeNode(node)) {
4721
+ return yield* processNode(node.type, isVirtualTypeNode);
4722
+ }
4504
4723
  if (ts.isTypeQueryNode(node)) {
4505
4724
  const typeChecker = yield* service(TypeCheckerApi);
4506
4725
  const type = typeChecker.getTypeAtLocation(node.exprName);
4507
4726
  const typeNode = typeChecker.typeToTypeNode(type, void 0, ts.NodeBuilderFlags.NoTruncation);
4508
4727
  if (typeNode) return yield* processNode(typeNode, true);
4509
4728
  }
4729
+ if (!isVirtualTypeNode && ts.isIndexedAccessTypeNode(node) && ts.isParenthesizedTypeNode(node.objectType) && ts.isTypeQueryNode(node.objectType.type) && ts.isTypeOperatorNode(node.indexType) && node.indexType.operator === ts.SyntaxKind.KeyOfKeyword && ts.isTypeQueryNode(node.indexType.type) && node.indexType.type.exprName.getText().trim() === node.objectType.type.exprName.getText().trim()) {
4730
+ const typeChecker = yield* service(TypeCheckerApi);
4731
+ const type = typeChecker.getTypeAtLocation(node);
4732
+ const typeNode = typeChecker.typeToTypeNode(type, void 0, ts.NodeBuilderFlags.NoTruncation);
4733
+ if (typeNode) return yield* processNode(typeNode, true);
4734
+ }
4510
4735
  if (ts.isTypeReferenceNode(node)) {
4511
4736
  const parsedName = entityNameToDataTypeName(node.typeName);
4512
4737
  if (isSome2(parsedName)) {
@@ -5131,6 +5356,21 @@ var init = (modules) => {
5131
5356
  }
5132
5357
  return applicableCompletions;
5133
5358
  };
5359
+ proxy.getDefinitionAndBoundSpan = (fileName, position, ...args) => {
5360
+ const applicableDefinition = languageService.getDefinitionAndBoundSpan(fileName, position, ...args);
5361
+ const program = languageService.getProgram();
5362
+ if (program) {
5363
+ const sourceFile = program.getSourceFile(fileName);
5364
+ if (sourceFile) {
5365
+ return pipe(
5366
+ goto(applicableDefinition, sourceFile, position),
5367
+ runNano(program),
5368
+ Either_exports.getOrElse(() => applicableDefinition)
5369
+ );
5370
+ }
5371
+ }
5372
+ return applicableDefinition;
5373
+ };
5134
5374
  return proxy;
5135
5375
  }
5136
5376
  return { create };