@effect/language-service 0.38.1 → 0.38.2

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.
@@ -1053,7 +1053,7 @@ var match = (fa, opts) => {
1053
1053
  var orElse2 = (f) => (fa) => {
1054
1054
  const nano = Object.create(MatchProto);
1055
1055
  nano[args] = fa;
1056
- nano[contE] = f;
1056
+ nano[contE] = (_) => _ instanceof NanoDefectException ? fail(_) : f(_);
1057
1057
  return nano;
1058
1058
  };
1059
1059
  var firstSuccessOf = (arr) => arr.slice(1).reduce((arr2, fa) => orElse2(() => fa)(arr2), arr[0]);
@@ -1724,18 +1724,21 @@ var getApplicableRefactors = fn("LSP.getApplicableRefactors")(function* (refacto
1724
1724
  const textRange = typeof positionOrRange === "number" ? { pos: positionOrRange, end: positionOrRange } : positionOrRange;
1725
1725
  const effectRefactors = [];
1726
1726
  for (const refactor of refactors) {
1727
- const result = yield* option(refactor.apply(sourceFile, textRange));
1728
- if (isSome2(result)) {
1729
- effectRefactors.push({
1730
- name: refactorNameToFullyQualifiedName(refactor.name),
1731
- description: refactor.description,
1732
- actions: [{
1727
+ yield* pipe(
1728
+ refactor.apply(sourceFile, textRange),
1729
+ map4(
1730
+ (result) => effectRefactors.push({
1733
1731
  name: refactorNameToFullyQualifiedName(refactor.name),
1734
- description: result.value.description,
1735
- kind: result.value.kind
1736
- }]
1737
- });
1738
- }
1732
+ description: refactor.description,
1733
+ actions: [{
1734
+ name: refactorNameToFullyQualifiedName(refactor.name),
1735
+ description: result.description,
1736
+ kind: result.kind
1737
+ }]
1738
+ })
1739
+ ),
1740
+ ignore
1741
+ );
1739
1742
  }
1740
1743
  return effectRefactors;
1741
1744
  });
@@ -3140,6 +3143,55 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils) {
3140
3143
  "TypeParser.extendsContextTag",
3141
3144
  (atLocation) => atLocation
3142
3145
  );
3146
+ const extendsEffectTag = cachedBy(
3147
+ fn("TypeParser.extendsEffectTag")(function* (atLocation) {
3148
+ if (!atLocation.name) {
3149
+ return yield* typeParserIssue("Class has no name", void 0, atLocation);
3150
+ }
3151
+ const heritageClauses = atLocation.heritageClauses;
3152
+ if (!heritageClauses) {
3153
+ return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
3154
+ }
3155
+ for (const heritageClause of heritageClauses) {
3156
+ for (const typeX of heritageClause.types) {
3157
+ if (ts.isExpressionWithTypeArguments(typeX)) {
3158
+ const wholeCall = typeX.expression;
3159
+ if (ts.isCallExpression(wholeCall)) {
3160
+ const effectTagCall = wholeCall.expression;
3161
+ if (ts.isCallExpression(effectTagCall) && wholeCall.typeArguments && wholeCall.typeArguments.length > 0) {
3162
+ const effectTagIdentifier = effectTagCall.expression;
3163
+ const selfTypeNode = wholeCall.typeArguments[0];
3164
+ if (ts.isPropertyAccessExpression(effectTagIdentifier) && ts.isIdentifier(effectTagIdentifier.name) && ts.idText(effectTagIdentifier.name) === "Tag") {
3165
+ const parsedEffectModule = yield* pipe(
3166
+ importedEffectModule(effectTagIdentifier.expression),
3167
+ option
3168
+ );
3169
+ if (isSome2(parsedEffectModule)) {
3170
+ const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
3171
+ if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
3172
+ const type = typeChecker.getTypeOfSymbol(classSym);
3173
+ const tagType = yield* contextTag(type, atLocation);
3174
+ return {
3175
+ className: atLocation.name,
3176
+ selfTypeNode,
3177
+ keyStringLiteral: ts.isStringLiteral(effectTagCall.arguments[0]) ? effectTagCall.arguments[0] : void 0,
3178
+ args: effectTagCall.arguments,
3179
+ Identifier: tagType.Identifier,
3180
+ Service: tagType.Service,
3181
+ Tag: parsedEffectModule.value
3182
+ };
3183
+ }
3184
+ }
3185
+ }
3186
+ }
3187
+ }
3188
+ }
3189
+ }
3190
+ return yield* typeParserIssue("Class does not extend Effect.Tag", void 0, atLocation);
3191
+ }),
3192
+ "TypeParser.extendsEffectTag",
3193
+ (atLocation) => atLocation
3194
+ );
3143
3195
  const extendsEffectService = cachedBy(
3144
3196
  fn("TypeParser.extendsEffectService")(function* (atLocation) {
3145
3197
  if (!atLocation.name) {
@@ -3222,6 +3274,7 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils) {
3222
3274
  pipeCall,
3223
3275
  scopeType,
3224
3276
  promiseLike,
3277
+ extendsEffectTag,
3225
3278
  extendsEffectService,
3226
3279
  extendsContextTag,
3227
3280
  extendsSchemaClass,
@@ -4464,6 +4517,7 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
4464
4517
  if (!ts.isClassDeclaration(node)) return yield* fail("not a class declaration");
4465
4518
  const { Service, accessors: accessors2, className } = yield* pipe(
4466
4519
  typeParser.extendsEffectService(node),
4520
+ orElse2(() => map4(typeParser.extendsEffectTag(node), (_) => ({ accessors: true, ..._ }))),
4467
4521
  orElse2(() => fail("not a class extending Effect.Service call"))
4468
4522
  );
4469
4523
  if (accessors2 !== true) return yield* fail("accessors are not enabled in the Effect.Service call");