@effect/language-service 0.43.0 → 0.43.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/language-service",
3
- "version": "0.43.0",
3
+ "version": "0.43.2",
4
4
  "description": "A Language-Service Plugin to Refactor and Diagnostic effect-ts projects",
5
5
  "main": "index.cjs",
6
6
  "bin": {
package/transform.js CHANGED
@@ -3492,31 +3492,33 @@ var makeKeyBuilder = fn("KeyBuilder")(
3492
3492
  if (!packageInfo) return;
3493
3493
  for (const keyPattern of options.keyPatterns) {
3494
3494
  if (keyPattern.target !== kind) continue;
3495
- if (keyPattern.pattern === "package-identifier") {
3496
- return packageInfo.name + "/" + classNameText;
3497
- }
3498
- const dirPath = getDirectoryPath(ts, sourceFile.fileName);
3499
- if (!dirPath.startsWith(packageInfo.packageDirectory)) return;
3500
- let subDirectory = dirPath.slice(packageInfo.packageDirectory.length);
3501
- if (subDirectory.startsWith("/")) subDirectory = subDirectory.slice(1);
3502
3495
  const lastIndex = sourceFile.fileName.lastIndexOf("/");
3503
- let subModule = lastIndex === -1 ? "" : sourceFile.fileName.slice(lastIndex + 1);
3504
- for (const extension of [".ts", ".tsx", ".js", ".jsx"]) {
3505
- if (subModule.toLowerCase().endsWith(extension)) {
3506
- subModule = subModule.slice(0, -extension.length);
3507
- break;
3508
- }
3509
- }
3510
- if (subModule.toLowerCase().endsWith("/index")) subModule = subModule.slice(0, -6);
3511
- if (subModule.startsWith("/")) subModule = subModule.slice(1);
3496
+ let onlyFileName = lastIndex === -1 ? "" : sourceFile.fileName.slice(lastIndex + 1);
3497
+ const lastExtensionIndex = onlyFileName.lastIndexOf(".");
3498
+ if (lastExtensionIndex !== -1) onlyFileName = onlyFileName.slice(0, lastExtensionIndex);
3499
+ if (onlyFileName.toLowerCase().endsWith("/index")) onlyFileName = onlyFileName.slice(0, -6);
3500
+ if (onlyFileName.startsWith("/")) onlyFileName = onlyFileName.slice(1);
3501
+ let subDirectory = getDirectoryPath(ts, sourceFile.fileName);
3502
+ if (!subDirectory.startsWith(packageInfo.packageDirectory)) continue;
3503
+ subDirectory = subDirectory.slice(packageInfo.packageDirectory.length);
3504
+ if (!subDirectory.endsWith("/")) subDirectory = subDirectory + "/";
3505
+ if (subDirectory.startsWith("/")) subDirectory = subDirectory.slice(1);
3512
3506
  for (const prefix of keyPattern.skipLeadingPath) {
3513
3507
  if (subDirectory.startsWith(prefix)) {
3514
3508
  subDirectory = subDirectory.slice(prefix.length);
3515
3509
  break;
3516
3510
  }
3517
3511
  }
3518
- const parts = [packageInfo.name, subDirectory, subModule].concat(
3519
- subModule.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
3512
+ let parts = [packageInfo.name, subDirectory, onlyFileName].concat(
3513
+ onlyFileName.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
3514
+ );
3515
+ if (keyPattern.pattern === "package-identifier") {
3516
+ parts = [packageInfo.name, onlyFileName].concat(
3517
+ onlyFileName.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
3518
+ );
3519
+ }
3520
+ parts = parts.map((part) => part.startsWith("/") ? part.slice(1) : part).map(
3521
+ (part) => part.endsWith("/") ? part.slice(0, -1) : part
3520
3522
  );
3521
3523
  return parts.filter((_) => String(_).trim().length > 0).join("/");
3522
3524
  }