@effect/language-service 0.17.0 → 0.17.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.
Files changed (3) hide show
  1. package/index.js +106 -55
  2. package/index.js.map +1 -1
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -159,13 +159,13 @@ var array = (item) => make((self, that) => {
159
159
  });
160
160
 
161
161
  // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/internal/doNotation.js
162
- var let_ = (map4) => dual(3, (self, name, f) => map4(self, (a) => Object.assign({}, a, {
162
+ var let_ = (map5) => dual(3, (self, name, f) => map5(self, (a) => Object.assign({}, a, {
163
163
  [name]: f(a)
164
164
  })));
165
- var bindTo = (map4) => dual(2, (self, name) => map4(self, (a) => ({
165
+ var bindTo = (map5) => dual(2, (self, name) => map5(self, (a) => ({
166
166
  [name]: a
167
167
  })));
168
- var bind = (map4, flatMap4) => dual(3, (self, name, f) => flatMap4(self, (a) => map4(f(a), (b) => Object.assign({}, a, {
168
+ var bind = (map5, flatMap4) => dual(3, (self, name, f) => flatMap4(self, (a) => map5(f(a), (b) => Object.assign({}, a, {
169
169
  [name]: b
170
170
  }))));
171
171
 
@@ -907,6 +907,7 @@ var getOrElse2 = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNon
907
907
  var orElse2 = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
908
908
  var fromNullable2 = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
909
909
  var getOrUndefined2 = /* @__PURE__ */ getOrElse2(constUndefined);
910
+ var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
910
911
 
911
912
  // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Array.js
912
913
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
@@ -936,7 +937,7 @@ var sort = /* @__PURE__ */ dual(2, (self, O) => {
936
937
  return out;
937
938
  });
938
939
  var empty = () => [];
939
- var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
940
+ var map3 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
940
941
  var flatMap2 = /* @__PURE__ */ dual(2, (self, f) => {
941
942
  if (isEmptyReadonlyArray(self)) {
942
943
  return [];
@@ -1052,7 +1053,7 @@ var flatMap3 = dual(2, (fa, f) => make3((ctx) => {
1052
1053
  if (result._tag !== "Right") return result;
1053
1054
  return f(result.value).run(ctx);
1054
1055
  }));
1055
- var map3 = dual(2, (fa, f) => make3((ctx) => {
1056
+ var map4 = dual(2, (fa, f) => make3((ctx) => {
1056
1057
  const result = fa.run(ctx);
1057
1058
  if (result._tag !== "Right") return result;
1058
1059
  return makeInternalSuccess(f(result.value));
@@ -1505,7 +1506,7 @@ var getSemanticDiagnosticsWithCodeFixes = fn(
1505
1506
  effectDiagnostics.push(
1506
1507
  ...pipe(
1507
1508
  result.value,
1508
- map2((_) => ({
1509
+ map3((_) => ({
1509
1510
  file: sourceFile,
1510
1511
  start: _.node.getStart(sourceFile),
1511
1512
  length: _.node.getEnd() - _.node.getStart(sourceFile),
@@ -1519,8 +1520,8 @@ var getSemanticDiagnosticsWithCodeFixes = fn(
1519
1520
  effectCodeFixes.push(
1520
1521
  ...pipe(
1521
1522
  result.value,
1522
- map2(
1523
- (_) => map2(
1523
+ map3(
1524
+ (_) => map3(
1524
1525
  _.fixes,
1525
1526
  (fix) => ({
1526
1527
  ...fix,
@@ -2016,45 +2017,6 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
2016
2017
  return result;
2017
2018
  });
2018
2019
 
2019
- // src/completions/genFunctionStar.ts
2020
- var genFunctionStar = createCompletion({
2021
- name: "effect/genFunctionStar",
2022
- apply: fn("genFunctionStar")(function* (sourceFile, position) {
2023
- const ts = yield* service(TypeScriptApi);
2024
- const typeChecker = yield* service(TypeCheckerApi);
2025
- const maybeInfos = yield* option(
2026
- parseAccessedExpressionForCompletion(sourceFile, position)
2027
- );
2028
- if (isNone2(maybeInfos)) return [];
2029
- const { accessedObject } = maybeInfos.value;
2030
- const type = typeChecker.getTypeAtLocation(accessedObject);
2031
- const genMemberSymbol = type.getProperty("gen");
2032
- if (!genMemberSymbol) return [];
2033
- const genType = typeChecker.getTypeOfSymbolAtLocation(genMemberSymbol, accessedObject);
2034
- if (genType.getCallSignatures().length === 0) return [];
2035
- const span = ts.createTextSpan(
2036
- accessedObject.end + 1,
2037
- Math.max(0, position - accessedObject.end - 1)
2038
- );
2039
- return [{
2040
- name: `gen(function*(){})`,
2041
- kind: ts.ScriptElementKind.constElement,
2042
- insertText: `gen(function*(){${"${0}"}})`,
2043
- replacementSpan: span,
2044
- isSnippet: true
2045
- }];
2046
- })
2047
- });
2048
-
2049
- // src/completions.ts
2050
- var completions = [
2051
- effectSchemaSelfInClasses,
2052
- effectSelfInClasses,
2053
- contextSelfInClasses,
2054
- genFunctionStar,
2055
- effectDataClasses
2056
- ];
2057
-
2058
2020
  // src/utils/TypeParser.ts
2059
2021
  var TypeParserIssue = class {
2060
2022
  constructor(type, node, message) {
@@ -2354,6 +2316,95 @@ var effectSchemaType = fn("TypeParser.effectSchemaType")(function* (type, atLoca
2354
2316
  return yield* typeParserIssue("Type has no schema variance struct", type, atLocation);
2355
2317
  });
2356
2318
 
2319
+ // src/completions/fnFunctionStar.ts
2320
+ var fnFunctionStar = createCompletion({
2321
+ name: "effect/fnFunctionStar",
2322
+ apply: fn("fnFunctionStar")(function* (sourceFile, position) {
2323
+ const ts = yield* service(TypeScriptApi);
2324
+ const maybeInfos = yield* option(
2325
+ parseAccessedExpressionForCompletion(sourceFile, position)
2326
+ );
2327
+ if (isNone2(maybeInfos)) return [];
2328
+ const { accessedObject } = maybeInfos.value;
2329
+ const isEffectModule = yield* option(importedEffectModule(accessedObject));
2330
+ if (isNone2(isEffectModule)) return [];
2331
+ const span = ts.createTextSpan(
2332
+ accessedObject.end + 1,
2333
+ Math.max(0, position - accessedObject.end - 1)
2334
+ );
2335
+ const maybeFnName = pipe(
2336
+ yield* getAncestorNodesInRange(sourceFile, toTextRange(accessedObject.pos)),
2337
+ filter(ts.isVariableDeclaration),
2338
+ map3((_) => _.name && ts.isIdentifier(_.name) ? _.name.text : ""),
2339
+ filter((_) => _.length > 0),
2340
+ head,
2341
+ map2((name) => [
2342
+ {
2343
+ name: `fn("${name}")`,
2344
+ kind: ts.ScriptElementKind.constElement,
2345
+ insertText: `fn("${name}")(function*(${"${1}"}){${"${0}"}})`,
2346
+ replacementSpan: span,
2347
+ isSnippet: true
2348
+ }
2349
+ ]),
2350
+ getOrElse2(() => [])
2351
+ );
2352
+ return maybeFnName.concat([{
2353
+ name: `fn(function*(){})`,
2354
+ kind: ts.ScriptElementKind.constElement,
2355
+ insertText: `fn(function*(${"${1}"}){${"${0}"}})`,
2356
+ replacementSpan: span,
2357
+ isSnippet: true
2358
+ }, {
2359
+ name: `fnUntraced(function*(){})`,
2360
+ kind: ts.ScriptElementKind.constElement,
2361
+ insertText: `fnUntraced(function*(${"${1}"}){${"${0}"}})`,
2362
+ replacementSpan: span,
2363
+ isSnippet: true
2364
+ }]);
2365
+ })
2366
+ });
2367
+
2368
+ // src/completions/genFunctionStar.ts
2369
+ var genFunctionStar = createCompletion({
2370
+ name: "effect/genFunctionStar",
2371
+ apply: fn("genFunctionStar")(function* (sourceFile, position) {
2372
+ const ts = yield* service(TypeScriptApi);
2373
+ const typeChecker = yield* service(TypeCheckerApi);
2374
+ const maybeInfos = yield* option(
2375
+ parseAccessedExpressionForCompletion(sourceFile, position)
2376
+ );
2377
+ if (isNone2(maybeInfos)) return [];
2378
+ const { accessedObject } = maybeInfos.value;
2379
+ const type = typeChecker.getTypeAtLocation(accessedObject);
2380
+ const genMemberSymbol = type.getProperty("gen");
2381
+ if (!genMemberSymbol) return [];
2382
+ const genType = typeChecker.getTypeOfSymbolAtLocation(genMemberSymbol, accessedObject);
2383
+ if (genType.getCallSignatures().length === 0) return [];
2384
+ const span = ts.createTextSpan(
2385
+ accessedObject.end + 1,
2386
+ Math.max(0, position - accessedObject.end - 1)
2387
+ );
2388
+ return [{
2389
+ name: `gen(function*(){})`,
2390
+ kind: ts.ScriptElementKind.constElement,
2391
+ insertText: `gen(function*(){${"${0}"}})`,
2392
+ replacementSpan: span,
2393
+ isSnippet: true
2394
+ }];
2395
+ })
2396
+ });
2397
+
2398
+ // src/completions.ts
2399
+ var completions = [
2400
+ effectSchemaSelfInClasses,
2401
+ effectSelfInClasses,
2402
+ contextSelfInClasses,
2403
+ genFunctionStar,
2404
+ fnFunctionStar,
2405
+ effectDataClasses
2406
+ ];
2407
+
2357
2408
  // src/diagnostics/floatingEffect.ts
2358
2409
  var floatingEffect = createDiagnostic({
2359
2410
  name: "effect/floatingEffect",
@@ -2788,7 +2839,7 @@ var asyncAwaitToGen = createRefactor({
2788
2839
  (node2) => pipe(
2789
2840
  importedEffectModule(node2),
2790
2841
  option,
2791
- map3(isSome2)
2842
+ map4(isSome2)
2792
2843
  )
2793
2844
  )
2794
2845
  ),
@@ -2860,7 +2911,7 @@ var asyncAwaitToGenTryPromise = createRefactor({
2860
2911
  (node2) => pipe(
2861
2912
  importedEffectModule(node2),
2862
2913
  option,
2863
- map3(isSome2)
2914
+ map4(isSome2)
2864
2915
  )
2865
2916
  )
2866
2917
  ),
@@ -2971,7 +3022,7 @@ var effectGenToFn = createRefactor({
2971
3022
  });
2972
3023
  const maybeNode = yield* pipe(
2973
3024
  yield* getAncestorNodesInRange(sourceFile, textRange),
2974
- map2(parseEffectGenNode),
3025
+ map3(parseEffectGenNode),
2975
3026
  firstSuccessOf,
2976
3027
  option
2977
3028
  );
@@ -3106,7 +3157,7 @@ var _findSchemaVariableDeclaration = fn(
3106
3157
  );
3107
3158
  return yield* pipe(
3108
3159
  yield* getAncestorNodesInRange(sourceFile, textRange),
3109
- map2(findSchema),
3160
+ map3(findSchema),
3110
3161
  firstSuccessOf,
3111
3162
  option
3112
3163
  );
@@ -3399,7 +3450,7 @@ var pipeableToDatafirst = createRefactor({
3399
3450
  filter(
3400
3451
  (node2) => node2.arguments.length > 0
3401
3452
  ),
3402
- map2((node2) => {
3453
+ map3((node2) => {
3403
3454
  let newNode2 = node2.arguments[0];
3404
3455
  let didSomething = false;
3405
3456
  for (let i = 1; i < node2.arguments.length; i++) {
@@ -3426,7 +3477,7 @@ var pipeableToDatafirst = createRefactor({
3426
3477
  return didSomething ? some2([node2, newNode2]) : none2();
3427
3478
  }),
3428
3479
  filter(isSome2),
3429
- map2((_) => _.value),
3480
+ map3((_) => _.value),
3430
3481
  head
3431
3482
  );
3432
3483
  if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
@@ -4140,7 +4191,7 @@ var wrapWithEffectGen = createRefactor({
4140
4191
  );
4141
4192
  const maybeNode = yield* pipe(
4142
4193
  yield* getAncestorNodesInRange(sourceFile, textRange),
4143
- map2(findEffectToWrap),
4194
+ map3(findEffectToWrap),
4144
4195
  firstSuccessOf,
4145
4196
  option
4146
4197
  );
@@ -4174,7 +4225,7 @@ var getEffectModuleIdentifierName = fn("getEffectModuleIdentifierName")(
4174
4225
  (node) => pipe(
4175
4226
  importedEffectModule(node),
4176
4227
  option,
4177
- map3(isSome2)
4228
+ map4(isSome2)
4178
4229
  )
4179
4230
  )
4180
4231
  ),