@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/index.js CHANGED
@@ -1812,31 +1812,33 @@ var makeKeyBuilder = fn("KeyBuilder")(
1812
1812
  if (!packageInfo) return;
1813
1813
  for (const keyPattern of options.keyPatterns) {
1814
1814
  if (keyPattern.target !== kind) continue;
1815
- if (keyPattern.pattern === "package-identifier") {
1816
- return packageInfo.name + "/" + classNameText;
1817
- }
1818
- const dirPath = getDirectoryPath(ts, sourceFile.fileName);
1819
- if (!dirPath.startsWith(packageInfo.packageDirectory)) return;
1820
- let subDirectory = dirPath.slice(packageInfo.packageDirectory.length);
1821
- if (subDirectory.startsWith("/")) subDirectory = subDirectory.slice(1);
1822
1815
  const lastIndex = sourceFile.fileName.lastIndexOf("/");
1823
- let subModule = lastIndex === -1 ? "" : sourceFile.fileName.slice(lastIndex + 1);
1824
- for (const extension of [".ts", ".tsx", ".js", ".jsx"]) {
1825
- if (subModule.toLowerCase().endsWith(extension)) {
1826
- subModule = subModule.slice(0, -extension.length);
1827
- break;
1828
- }
1829
- }
1830
- if (subModule.toLowerCase().endsWith("/index")) subModule = subModule.slice(0, -6);
1831
- if (subModule.startsWith("/")) subModule = subModule.slice(1);
1816
+ let onlyFileName = lastIndex === -1 ? "" : sourceFile.fileName.slice(lastIndex + 1);
1817
+ const lastExtensionIndex = onlyFileName.lastIndexOf(".");
1818
+ if (lastExtensionIndex !== -1) onlyFileName = onlyFileName.slice(0, lastExtensionIndex);
1819
+ if (onlyFileName.toLowerCase().endsWith("/index")) onlyFileName = onlyFileName.slice(0, -6);
1820
+ if (onlyFileName.startsWith("/")) onlyFileName = onlyFileName.slice(1);
1821
+ let subDirectory = getDirectoryPath(ts, sourceFile.fileName);
1822
+ if (!subDirectory.startsWith(packageInfo.packageDirectory)) continue;
1823
+ subDirectory = subDirectory.slice(packageInfo.packageDirectory.length);
1824
+ if (!subDirectory.endsWith("/")) subDirectory = subDirectory + "/";
1825
+ if (subDirectory.startsWith("/")) subDirectory = subDirectory.slice(1);
1832
1826
  for (const prefix of keyPattern.skipLeadingPath) {
1833
1827
  if (subDirectory.startsWith(prefix)) {
1834
1828
  subDirectory = subDirectory.slice(prefix.length);
1835
1829
  break;
1836
1830
  }
1837
1831
  }
1838
- const parts = [packageInfo.name, subDirectory, subModule].concat(
1839
- subModule.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
1832
+ let parts = [packageInfo.name, subDirectory, onlyFileName].concat(
1833
+ onlyFileName.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
1834
+ );
1835
+ if (keyPattern.pattern === "package-identifier") {
1836
+ parts = [packageInfo.name, onlyFileName].concat(
1837
+ onlyFileName.toLowerCase() === classNameText.toLowerCase() ? [] : [classNameText]
1838
+ );
1839
+ }
1840
+ parts = parts.map((part) => part.startsWith("/") ? part.slice(1) : part).map(
1841
+ (part) => part.endsWith("/") ? part.slice(0, -1) : part
1840
1842
  );
1841
1843
  return parts.filter((_) => String(_).trim().length > 0).join("/");
1842
1844
  }