@effect/language-service 0.72.1 → 0.73.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/index.js CHANGED
@@ -4247,7 +4247,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
4247
4247
  const lineOverrides = {};
4248
4248
  const sectionOverrides = {};
4249
4249
  const skippedRules = [];
4250
- const regex = /@effect-diagnostics(-next-line)?((?:\s[a-zA-Z0-9/]+:(?:off|warning|error|message|suggestion|skip-file))+)?/gm;
4250
+ const regex = /@effect-diagnostics(-next-line)?((?:\s(?:[a-zA-Z0-9/]+|\*):(?:off|warning|error|message|suggestion|skip-file))+)?/gm;
4251
4251
  let match3;
4252
4252
  while ((match3 = regex.exec(sourceFile.text)) !== null) {
4253
4253
  const nextLineCaptureGroup = match3[1];
@@ -4296,8 +4296,10 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
4296
4296
  const codeFixes = [];
4297
4297
  const ruleNameLowered = rule.name.toLowerCase();
4298
4298
  const defaultLevel = pluginOptions.diagnosticSeverity[ruleNameLowered] || rule.severity;
4299
- if (skippedRules.indexOf(ruleNameLowered) > -1) return { diagnostics: diagnostics2, codeFixes };
4300
- if (defaultLevel === "off" && (lineOverrides[ruleNameLowered] || sectionOverrides[ruleNameLowered] || []).length === 0) {
4299
+ if (skippedRules.indexOf(ruleNameLowered) > -1 || skippedRules.indexOf("*") > -1) {
4300
+ return { diagnostics: diagnostics2, codeFixes };
4301
+ }
4302
+ if (defaultLevel === "off" && (lineOverrides[ruleNameLowered] || sectionOverrides[ruleNameLowered] || lineOverrides["*"] || sectionOverrides["*"] || []).length === 0) {
4301
4303
  return { diagnostics: diagnostics2, codeFixes };
4302
4304
  }
4303
4305
  const fixByDisableNextLine = (node) => ({
@@ -4346,14 +4348,22 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
4346
4348
  const unusedLineOverrides = new Set(lineOverrides[ruleNameLowered] || []);
4347
4349
  for (const emitted of applicableDiagnostics.slice(0)) {
4348
4350
  let newLevel = defaultLevel;
4349
- const lineOverride = (lineOverrides[ruleNameLowered] || []).find(
4351
+ const specificLineOverride = (lineOverrides[ruleNameLowered] || []).find(
4352
+ (_) => _.pos < emitted.range.pos && _.end >= emitted.range.end
4353
+ );
4354
+ const wildcardLineOverride = (lineOverrides["*"] || []).find(
4350
4355
  (_) => _.pos < emitted.range.pos && _.end >= emitted.range.end
4351
4356
  );
4357
+ const lineOverride = specificLineOverride && wildcardLineOverride ? specificLineOverride.pos >= wildcardLineOverride.pos ? specificLineOverride : wildcardLineOverride : specificLineOverride || wildcardLineOverride;
4352
4358
  if (lineOverride) {
4353
4359
  newLevel = lineOverride.level;
4354
4360
  unusedLineOverrides.delete(lineOverride);
4355
4361
  } else {
4356
- const sectionOverride = (sectionOverrides[ruleNameLowered] || []).find((_) => _.pos < emitted.range.pos);
4362
+ const specificSectionOverride = (sectionOverrides[ruleNameLowered] || []).find(
4363
+ (_) => _.pos < emitted.range.pos
4364
+ );
4365
+ const wildcardSectionOverride = (sectionOverrides["*"] || []).find((_) => _.pos < emitted.range.pos);
4366
+ const sectionOverride = specificSectionOverride && wildcardSectionOverride ? specificSectionOverride.pos >= wildcardSectionOverride.pos ? specificSectionOverride : wildcardSectionOverride : specificSectionOverride || wildcardSectionOverride;
4357
4367
  if (sectionOverride) newLevel = sectionOverride.level;
4358
4368
  }
4359
4369
  if (!(newLevel in levelToDiagnosticCategory)) continue;
@@ -4943,7 +4953,9 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
4943
4953
  const sourceFile = program.getSourceFile(fileName);
4944
4954
  if (!sourceFile) continue;
4945
4955
  const resolvedPackages = getEffectRelatedPackages(sourceFile);
4946
- for (const version of Object.keys(resolvedPackages["effect"])) {
4956
+ const effectPkgs = resolvedPackages["effect"];
4957
+ if (!effectPkgs) continue;
4958
+ for (const version of Object.keys(effectPkgs)) {
4947
4959
  if (String(version).startsWith("4")) return "v4";
4948
4960
  if (String(version).startsWith("3")) return "v3";
4949
4961
  }
@@ -5350,7 +5362,7 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
5350
5362
  fn("TypeParser.isEffectDataSourceFile")(function* (sourceFile) {
5351
5363
  const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
5352
5364
  if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", void 0, sourceFile);
5353
- const taggedEnumSymbol = typeChecker.tryGetMemberInModuleExports("TaggedEnum", moduleSymbol);
5365
+ const taggedEnumSymbol = typeChecker.tryGetMemberInModuleExports("TaggedEnum", moduleSymbol) || typeChecker.tryGetMemberInModuleExports("taggedEnum", moduleSymbol);
5354
5366
  if (!taggedEnumSymbol) return yield* typeParserIssue("TaggedEnum not found", void 0, sourceFile);
5355
5367
  const taggedErrorSymbol = typeChecker.tryGetMemberInModuleExports("TaggedError", moduleSymbol);
5356
5368
  if (!taggedErrorSymbol) return yield* typeParserIssue("TaggedError not found", void 0, sourceFile);
@@ -6784,6 +6796,7 @@ var contextSelfInClasses = createCompletion({
6784
6796
  const ts = yield* service(TypeScriptApi);
6785
6797
  const tsUtils = yield* service(TypeScriptUtils);
6786
6798
  const typeParser = yield* service(TypeParser);
6799
+ if (typeParser.supportedEffect() === "v4") return [];
6787
6800
  const maybeInfos = tsUtils.parseDataForExtendsClassCompletion(sourceFile, position);
6788
6801
  if (!maybeInfos) return [];
6789
6802
  const { accessedObject, className, replacementSpan } = maybeInfos;
@@ -12099,50 +12112,90 @@ var effectSchemaSelfInClasses = createCompletion({
12099
12112
  isSnippet: true
12100
12113
  });
12101
12114
  }
12102
- const hasTaggedErrorCompletion = isFullyQualified || isSome2(
12103
- yield* pipe(
12104
- typeParser.isNodeReferenceToEffectSchemaModuleApi("TaggedError")(accessedObject),
12105
- option
12106
- )
12107
- );
12108
- if (hasTaggedErrorCompletion) {
12109
- completions2.push({
12110
- name: `TaggedError<${name}>`,
12111
- kind: ts.ScriptElementKind.constElement,
12112
- insertText: isFullyQualified ? `${schemaIdentifier}.TaggedError<${name}>()("${errorTagKey}", {${"${0}"}}){}` : `TaggedError<${name}>()("${errorTagKey}", {${"${0}"}}){}`,
12113
- replacementSpan,
12114
- isSnippet: true
12115
- });
12115
+ if (typeParser.supportedEffect() === "v3") {
12116
+ const hasTaggedErrorCompletion = isFullyQualified || isSome2(
12117
+ yield* pipe(
12118
+ typeParser.isNodeReferenceToEffectSchemaModuleApi("TaggedError")(accessedObject),
12119
+ option
12120
+ )
12121
+ );
12122
+ if (hasTaggedErrorCompletion) {
12123
+ completions2.push({
12124
+ name: `TaggedError<${name}>`,
12125
+ kind: ts.ScriptElementKind.constElement,
12126
+ insertText: isFullyQualified ? `${schemaIdentifier}.TaggedError<${name}>()("${errorTagKey}", {${"${0}"}}){}` : `TaggedError<${name}>()("${errorTagKey}", {${"${0}"}}){}`,
12127
+ replacementSpan,
12128
+ isSnippet: true
12129
+ });
12130
+ }
12116
12131
  }
12117
- const hasTaggedClassCompletion = isFullyQualified || isSome2(
12118
- yield* pipe(
12119
- typeParser.isNodeReferenceToEffectSchemaModuleApi("TaggedClass")(accessedObject),
12120
- option
12121
- )
12122
- );
12123
- if (hasTaggedClassCompletion) {
12124
- completions2.push({
12125
- name: `TaggedClass<${name}>`,
12126
- kind: ts.ScriptElementKind.constElement,
12127
- insertText: isFullyQualified ? `${schemaIdentifier}.TaggedClass<${name}>()("${name}", {${"${0}"}}){}` : `TaggedClass<${name}>()("${name}", {${"${0}"}}){}`,
12128
- replacementSpan,
12129
- isSnippet: true
12130
- });
12132
+ if (typeParser.supportedEffect() === "v3") {
12133
+ const hasTaggedClassCompletion = isFullyQualified || isSome2(
12134
+ yield* pipe(
12135
+ typeParser.isNodeReferenceToEffectSchemaModuleApi("TaggedClass")(accessedObject),
12136
+ option
12137
+ )
12138
+ );
12139
+ if (hasTaggedClassCompletion) {
12140
+ completions2.push({
12141
+ name: `TaggedClass<${name}>`,
12142
+ kind: ts.ScriptElementKind.constElement,
12143
+ insertText: isFullyQualified ? `${schemaIdentifier}.TaggedClass<${name}>()("${name}", {${"${0}"}}){}` : `TaggedClass<${name}>()("${name}", {${"${0}"}}){}`,
12144
+ replacementSpan,
12145
+ isSnippet: true
12146
+ });
12147
+ }
12131
12148
  }
12132
- const hasTaggedRequestCompletion = isFullyQualified || isSome2(
12133
- yield* pipe(
12134
- typeParser.isNodeReferenceToEffectSchemaModuleApi("TaggedRequest")(accessedObject),
12135
- option
12136
- )
12137
- );
12138
- if (hasTaggedRequestCompletion) {
12139
- completions2.push({
12140
- name: `TaggedRequest<${name}>`,
12141
- kind: ts.ScriptElementKind.constElement,
12142
- insertText: isFullyQualified ? `${schemaIdentifier}.TaggedRequest<${name}>()("${name}", {${"${0}"}}){}` : `TaggedRequest<${name}>()("${name}", {${"${0}"}}){}`,
12143
- replacementSpan,
12144
- isSnippet: true
12145
- });
12149
+ if (typeParser.supportedEffect() === "v3") {
12150
+ const hasTaggedRequestCompletion = isFullyQualified || isSome2(
12151
+ yield* pipe(
12152
+ typeParser.isNodeReferenceToEffectSchemaModuleApi("TaggedRequest")(accessedObject),
12153
+ option
12154
+ )
12155
+ );
12156
+ if (hasTaggedRequestCompletion) {
12157
+ completions2.push({
12158
+ name: `TaggedRequest<${name}>`,
12159
+ kind: ts.ScriptElementKind.constElement,
12160
+ insertText: isFullyQualified ? `${schemaIdentifier}.TaggedRequest<${name}>()("${name}", {${"${0}"}}){}` : `TaggedRequest<${name}>()("${name}", {${"${0}"}}){}`,
12161
+ replacementSpan,
12162
+ isSnippet: true
12163
+ });
12164
+ }
12165
+ }
12166
+ if (typeParser.supportedEffect() === "v4") {
12167
+ const hasErrorClassCompletion = isFullyQualified || isSome2(
12168
+ yield* pipe(
12169
+ typeParser.isNodeReferenceToEffectSchemaModuleApi("ErrorClass")(accessedObject),
12170
+ option
12171
+ )
12172
+ );
12173
+ if (hasErrorClassCompletion) {
12174
+ completions2.push({
12175
+ name: `ErrorClass<${name}>`,
12176
+ kind: ts.ScriptElementKind.constElement,
12177
+ insertText: isFullyQualified ? `${schemaIdentifier}.ErrorClass<${name}>()({${"${0}"}}){}` : `ErrorClass<${name}>()({${"${0}"}}){}`,
12178
+ replacementSpan,
12179
+ isSnippet: true
12180
+ });
12181
+ }
12182
+ }
12183
+ if (typeParser.supportedEffect() === "v4") {
12184
+ const hasRequestClassCompletion = isFullyQualified || isSome2(
12185
+ yield* pipe(
12186
+ typeParser.isNodeReferenceToEffectSchemaModuleApi("RequestClass")(accessedObject),
12187
+ option
12188
+ )
12189
+ );
12190
+ if (hasRequestClassCompletion) {
12191
+ completions2.push({
12192
+ name: `RequestClass<${name}>`,
12193
+ kind: ts.ScriptElementKind.constElement,
12194
+ insertText: isFullyQualified ? `${schemaIdentifier}.RequestClass<${name}>("${name}")({${"${0}"}}){}` : `RequestClass<${name}>("${name}")({${"${0}"}}){}`,
12195
+ replacementSpan,
12196
+ isSnippet: true
12197
+ });
12198
+ }
12146
12199
  }
12147
12200
  return completions2;
12148
12201
  })
@@ -12167,35 +12220,39 @@ var effectSelfInClasses = createCompletion({
12167
12220
  const name = ts.idText(className);
12168
12221
  const tagKey = (yield* createString(sourceFile, name, "service")) || name;
12169
12222
  const completions2 = [];
12170
- const hasServiceCompletion = isFullyQualified || isSome2(
12171
- yield* pipe(
12172
- typeParser.isNodeReferenceToEffectModuleApi("Service")(accessedObject),
12173
- option
12174
- )
12175
- );
12176
- if (hasServiceCompletion) {
12177
- completions2.push({
12178
- name: `Service<${name}>`,
12179
- kind: ts.ScriptElementKind.constElement,
12180
- insertText: isFullyQualified ? `${effectIdentifier}.Service<${name}>()("${tagKey}", {${"${0}"}}){}` : `Service<${name}>()("${tagKey}", {${"${0}"}}){}`,
12181
- replacementSpan,
12182
- isSnippet: true
12183
- });
12223
+ if (typeParser.supportedEffect() === "v3") {
12224
+ const hasServiceCompletion = isFullyQualified || isSome2(
12225
+ yield* pipe(
12226
+ typeParser.isNodeReferenceToEffectModuleApi("Service")(accessedObject),
12227
+ option
12228
+ )
12229
+ );
12230
+ if (hasServiceCompletion) {
12231
+ completions2.push({
12232
+ name: `Service<${name}>`,
12233
+ kind: ts.ScriptElementKind.constElement,
12234
+ insertText: isFullyQualified ? `${effectIdentifier}.Service<${name}>()("${tagKey}", {${"${0}"}}){}` : `Service<${name}>()("${tagKey}", {${"${0}"}}){}`,
12235
+ replacementSpan,
12236
+ isSnippet: true
12237
+ });
12238
+ }
12184
12239
  }
12185
- const hasTagCompletion = isFullyQualified || isSome2(
12186
- yield* pipe(
12187
- typeParser.isNodeReferenceToEffectModuleApi("Tag")(accessedObject),
12188
- option
12189
- )
12190
- );
12191
- if (hasTagCompletion) {
12192
- completions2.push({
12193
- name: `Tag("${name}")`,
12194
- kind: ts.ScriptElementKind.constElement,
12195
- insertText: isFullyQualified ? `${effectIdentifier}.Tag("${tagKey}")<${name}, {${"${0}"}}>(){}` : `Tag("${tagKey}")<${name}, {${"${0}"}}>(){}`,
12196
- replacementSpan,
12197
- isSnippet: true
12198
- });
12240
+ if (typeParser.supportedEffect() === "v3") {
12241
+ const hasTagCompletion = isFullyQualified || isSome2(
12242
+ yield* pipe(
12243
+ typeParser.isNodeReferenceToEffectModuleApi("Tag")(accessedObject),
12244
+ option
12245
+ )
12246
+ );
12247
+ if (hasTagCompletion) {
12248
+ completions2.push({
12249
+ name: `Tag("${name}")`,
12250
+ kind: ts.ScriptElementKind.constElement,
12251
+ insertText: isFullyQualified ? `${effectIdentifier}.Tag("${tagKey}")<${name}, {${"${0}"}}>(){}` : `Tag("${tagKey}")<${name}, {${"${0}"}}>(){}`,
12252
+ replacementSpan,
12253
+ isSnippet: true
12254
+ });
12255
+ }
12199
12256
  }
12200
12257
  return completions2;
12201
12258
  })
@@ -12208,6 +12265,7 @@ var effectSqlModelSelfInClasses = createCompletion({
12208
12265
  const ts = yield* service(TypeScriptApi);
12209
12266
  const tsUtils = yield* service(TypeScriptUtils);
12210
12267
  const typeParser = yield* service(TypeParser);
12268
+ if (typeParser.supportedEffect() === "v4") return [];
12211
12269
  const maybeInfos = tsUtils.parseDataForExtendsClassCompletion(sourceFile, position);
12212
12270
  if (!maybeInfos) return [];
12213
12271
  const { accessedObject, className, replacementSpan } = maybeInfos;
@@ -12324,6 +12382,8 @@ var rpcMakeClasses = createCompletion({
12324
12382
  apply: fn("rpcMakeClasses")(function* (sourceFile, position) {
12325
12383
  const ts = yield* service(TypeScriptApi);
12326
12384
  const tsUtils = yield* service(TypeScriptUtils);
12385
+ const typeParser = yield* service(TypeParser);
12386
+ if (typeParser.supportedEffect() === "v4") return [];
12327
12387
  const maybeInfos = tsUtils.parseDataForExtendsClassCompletion(sourceFile, position);
12328
12388
  if (!maybeInfos) return [];
12329
12389
  const { accessedObject, className, replacementSpan } = maybeInfos;
@@ -12350,6 +12410,8 @@ var schemaBrand = createCompletion({
12350
12410
  apply: fn("schemaBrand")(function* (sourceFile, position) {
12351
12411
  const ts = yield* service(TypeScriptApi);
12352
12412
  const tsUtils = yield* service(TypeScriptUtils);
12413
+ const typeParser = yield* service(TypeParser);
12414
+ if (typeParser.supportedEffect() === "v4") return [];
12353
12415
  const maybeInfos = tsUtils.parseAccessedExpressionForCompletion(sourceFile, position);
12354
12416
  if (!maybeInfos) return [];
12355
12417
  const { accessedObject } = maybeInfos;