@effect/language-service 0.36.0 → 0.37.0

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
@@ -324,10 +324,10 @@ var string = (str) => {
324
324
  }
325
325
  return optimize(h);
326
326
  };
327
- var structureKeys = (o, keys) => {
327
+ var structureKeys = (o, keys2) => {
328
328
  let h = 12289;
329
- for (let i = 0; i < keys.length; i++) {
330
- h ^= pipe(string(keys[i]), combine(hash(o[keys[i]])));
329
+ for (let i = 0; i < keys2.length; i++) {
330
+ h ^= pipe(string(keys2[i]), combine(hash(o[keys2[i]])));
331
331
  }
332
332
  return optimize(h);
333
333
  };
@@ -829,6 +829,7 @@ var NanoFiber = class {
829
829
  _yielded = void 0;
830
830
  _services = {};
831
831
  _cache = {};
832
+ _perf = false;
832
833
  runLoop(nano) {
833
834
  let current = nano;
834
835
  while (true) {
@@ -852,6 +853,34 @@ var NanoFiber = class {
852
853
  return NanoYield;
853
854
  }
854
855
  };
856
+ var timings = {};
857
+ var timingsCount = {};
858
+ var WithSpanProto = {
859
+ ...PrimitiveProto,
860
+ [evaluate](fiber) {
861
+ const [fa, name] = this[args];
862
+ if (!fiber._perf) return fa;
863
+ const start = performance.now();
864
+ timingsCount[name] = (timingsCount[name] || 0) + 1;
865
+ return match(fa, {
866
+ onSuccess: (_) => {
867
+ const end = performance.now();
868
+ timings[name] = (timings[name] || 0) + (end - start);
869
+ return succeed(_);
870
+ },
871
+ onFailure: (_) => {
872
+ const end = performance.now();
873
+ timings[name] = (timings[name] || 0) + (end - start);
874
+ return fail(_);
875
+ }
876
+ });
877
+ }
878
+ };
879
+ var withSpan = (name) => (fa) => {
880
+ const nano = Object.create(WithSpanProto);
881
+ nano[args] = [fa, name];
882
+ return nano;
883
+ };
855
884
  var unsafeRun = (nano) => {
856
885
  const fiber = new NanoFiber();
857
886
  const result = fiber.runLoop(nano);
@@ -913,7 +942,7 @@ var unsafeFromIterator = (iterator, initial) => {
913
942
  return nano;
914
943
  };
915
944
  var gen = (...args2) => suspend(() => unsafeFromIterator(args2[0]()));
916
- var fn = (_) => (body) => (...args2) => suspend(() => unsafeFromIterator(body(...args2)));
945
+ var fn = (_) => (body) => (...args2) => withSpan(_)(suspend(() => unsafeFromIterator(body(...args2))));
917
946
  var MatchProto = {
918
947
  ...PrimitiveProto,
919
948
  [evaluate](fiber) {
@@ -1039,6 +1068,18 @@ var ChangeTracker = Tag("ChangeTracker");
1039
1068
  // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/array.js
1040
1069
  var isNonEmptyArray = (self) => self.length > 0;
1041
1070
 
1071
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Record.js
1072
+ var map4 = /* @__PURE__ */ dual(2, (self, f) => {
1073
+ const out = {
1074
+ ...self
1075
+ };
1076
+ for (const key of keys(self)) {
1077
+ out[key] = f(self[key], key);
1078
+ }
1079
+ return out;
1080
+ });
1081
+ var keys = (self) => Object.keys(self);
1082
+
1042
1083
  // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Array.js
1043
1084
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
1044
1085
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
@@ -1082,7 +1123,7 @@ var intersectionWith = (isEquivalent) => {
1082
1123
  };
1083
1124
  var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
1084
1125
  var empty = () => [];
1085
- var map4 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
1126
+ var map5 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
1086
1127
  var flatMap2 = /* @__PURE__ */ dual(2, (self, f) => {
1087
1128
  if (isEmptyReadonlyArray(self)) {
1088
1129
  return [];
@@ -1179,7 +1220,7 @@ function makeTypeScriptUtils(ts) {
1179
1220
  return pipe(
1180
1221
  referencedPackages.concat(packageJsonScope?.referencedPackages || []),
1181
1222
  dedupe,
1182
- map4((packageName) => packageName.toLowerCase()),
1223
+ map5((packageName) => packageName.toLowerCase()),
1183
1224
  filter(
1184
1225
  (packageName) => pattern.endsWith("*") && packageName.startsWith(pattern.toLowerCase().substring(0, pattern.length - 1))
1185
1226
  )
@@ -1295,7 +1336,7 @@ function makeTypeScriptUtils(ts) {
1295
1336
  fnCall = ts.factory.createCallExpression(
1296
1337
  fnCall,
1297
1338
  void 0,
1298
- [ts.factory.createStringLiteral(fnName.text)]
1339
+ [ts.factory.createStringLiteral(ts.idText(fnName))]
1299
1340
  );
1300
1341
  }
1301
1342
  return tryPreserveDeclarationSemantics(
@@ -1367,7 +1408,7 @@ function makeTypeScriptUtils(ts) {
1367
1408
  if (!namedBindings) continue;
1368
1409
  if (ts.isNamespaceImport(namedBindings)) {
1369
1410
  if (test(namedBindings.name, statement.moduleSpecifier, none2())) {
1370
- return namedBindings.name.text;
1411
+ return ts.idText(namedBindings.name);
1371
1412
  }
1372
1413
  } else if (ts.isNamedImports(namedBindings)) {
1373
1414
  for (const importSpecifier of namedBindings.elements) {
@@ -1375,7 +1416,7 @@ function makeTypeScriptUtils(ts) {
1375
1416
  orElse(() => some2(importSpecifier.name))
1376
1417
  );
1377
1418
  if (test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
1378
- return importSpecifier.name.text;
1419
+ return ts.idText(importSpecifier.name);
1379
1420
  }
1380
1421
  }
1381
1422
  }
@@ -1388,7 +1429,7 @@ function makeTypeScriptUtils(ts) {
1388
1429
  if (isNone2(importProperty) && ts.isStringLiteral(fromModule) && fromModule.text === packageName + "/" + moduleName) {
1389
1430
  return true;
1390
1431
  }
1391
- if (isSome2(importProperty) && ts.isIdentifier(importProperty.value) && importProperty.value.text === moduleName && ts.isStringLiteral(fromModule) && fromModule.text === packageName) {
1432
+ if (isSome2(importProperty) && ts.isIdentifier(importProperty.value) && ts.idText(importProperty.value) === moduleName && ts.isStringLiteral(fromModule) && fromModule.text === packageName) {
1392
1433
  return true;
1393
1434
  }
1394
1435
  return false;
@@ -1615,7 +1656,7 @@ function parseDiagnosticSeverity(config) {
1615
1656
  pipe(
1616
1657
  Object.entries(config),
1617
1658
  filter(([key, value]) => isString(key) && isString(value)),
1618
- map4(([key, value]) => [String(key).toLowerCase(), String(value).toLowerCase()]),
1659
+ map5(([key, value]) => [String(key).toLowerCase(), String(value).toLowerCase()]),
1619
1660
  filter(
1620
1661
  ([_, value]) => value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion"
1621
1662
  )
@@ -1633,8 +1674,10 @@ var defaults = {
1633
1674
  inlays: true,
1634
1675
  allowedDuplicatedPackages: [],
1635
1676
  namespaceImportPackages: [],
1677
+ topLevelNamedReexports: "ignore",
1636
1678
  barrelImportPackages: [],
1637
- topLevelNamedReexports: "ignore"
1679
+ importAliases: {},
1680
+ renames: true
1638
1681
  };
1639
1682
  function parse(config) {
1640
1683
  return {
@@ -1649,7 +1692,9 @@ function parse(config) {
1649
1692
  allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
1650
1693
  namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
1651
1694
  barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
1652
- topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports
1695
+ importAliases: isObject(config) && hasProperty(config, "importAliases") && isRecord(config.importAliases) ? map4(config.importAliases, (value) => String(value)) : defaults.importAliases,
1696
+ topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
1697
+ renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames
1653
1698
  };
1654
1699
  }
1655
1700
 
@@ -1961,6 +2006,9 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
1961
2006
  ignore: updateHashComment
1962
2007
  };
1963
2008
  });
2009
+ var getEffectLspPatchSourceFileMetadata = (sourceFile) => {
2010
+ return sourceFile["@effect-lsp-patch/metadata"];
2011
+ };
1964
2012
 
1965
2013
  // src/completions/contextSelfInClasses.ts
1966
2014
  var contextSelfInClasses = createCompletion({
@@ -1990,188 +2038,6 @@ var contextSelfInClasses = createCompletion({
1990
2038
 
1991
2039
  // src/core/TypeCheckerApi.ts
1992
2040
  var TypeCheckerApi = Tag("TypeChecker");
1993
- var deterministicTypeOrder = gen(function* () {
1994
- const typeChecker = yield* service(TypeCheckerApi);
1995
- return make2((a, b) => {
1996
- const aName = typeChecker.typeToString(a);
1997
- const bName = typeChecker.typeToString(b);
1998
- if (aName < bName) return -1;
1999
- if (aName > bName) return 1;
2000
- return 0;
2001
- });
2002
- });
2003
- var CannotFindAncestorConvertibleDeclarationError = class {
2004
- constructor(node) {
2005
- this.node = node;
2006
- }
2007
- _tag = "@effect/language-service/CannotFindAncestorConvertibleDeclarationError";
2008
- };
2009
- var getAncestorConvertibleDeclaration = fn(
2010
- "TypeCheckerApi.getAncestorConvertibleDeclaration"
2011
- )(function* (node) {
2012
- const ts = yield* service(TypeScriptApi);
2013
- let current = node;
2014
- while (current) {
2015
- if (ts.isFunctionDeclaration(current) || ts.isFunctionExpression(current) || ts.isArrowFunction(current) || ts.isMethodDeclaration(current)) {
2016
- return current;
2017
- }
2018
- current = current.parent;
2019
- }
2020
- return yield* fail(new CannotFindAncestorConvertibleDeclarationError(node));
2021
- });
2022
- var CannotInferReturnTypeFromEmptyBody = class {
2023
- constructor(declaration) {
2024
- this.declaration = declaration;
2025
- }
2026
- _tag = "@effect/language-service/CannotInferReturnTypeFromEmptyBody";
2027
- };
2028
- var CannotInferReturnType = class {
2029
- constructor(declaration) {
2030
- this.declaration = declaration;
2031
- }
2032
- _tag = "@effect/language-service/CannotInferReturnType";
2033
- };
2034
- var getInferredReturnType = fn("TypeCheckerApi.getInferredReturnType")(function* (declaration) {
2035
- const typeChecker = yield* service(TypeCheckerApi);
2036
- const ts = yield* service(TypeScriptApi);
2037
- if (!declaration.body) {
2038
- return yield* fail(
2039
- new CannotInferReturnTypeFromEmptyBody(declaration)
2040
- );
2041
- }
2042
- let returnType;
2043
- if (typeChecker.isImplementationOfOverload(declaration)) {
2044
- const signatures = typeChecker.getSignaturesOfType(
2045
- typeChecker.getTypeAtLocation(declaration),
2046
- ts.SignatureKind.Call
2047
- );
2048
- if (signatures.length > 1) {
2049
- returnType = typeChecker.getUnionType(
2050
- signatures.map((s) => typeChecker.getReturnTypeOfSignature(s)).filter((_) => !!_)
2051
- );
2052
- }
2053
- }
2054
- if (!returnType) {
2055
- const signature = typeChecker.getSignatureFromDeclaration(declaration);
2056
- if (signature) {
2057
- const typePredicate = typeChecker.getTypePredicateOfSignature(signature);
2058
- if (typePredicate && typePredicate.type) {
2059
- return typePredicate.type;
2060
- } else {
2061
- returnType = typeChecker.getReturnTypeOfSignature(signature);
2062
- }
2063
- }
2064
- }
2065
- if (!returnType) {
2066
- return yield* fail(
2067
- new CannotInferReturnType(declaration)
2068
- );
2069
- }
2070
- return returnType;
2071
- });
2072
- var expectedAndRealType = cachedBy(
2073
- fn("TypeCheckerApi.expectedAndRealType")(function* (sourceFile) {
2074
- const typeChecker = yield* service(TypeCheckerApi);
2075
- const ts = yield* service(TypeScriptApi);
2076
- const result = [];
2077
- const nodeToVisit = [sourceFile];
2078
- const appendNodeToVisit = (node) => {
2079
- nodeToVisit.push(node);
2080
- return void 0;
2081
- };
2082
- while (nodeToVisit.length > 0) {
2083
- const node = nodeToVisit.shift();
2084
- if (ts.isVariableDeclaration(node) && node.initializer) {
2085
- const expectedType = typeChecker.getTypeAtLocation(node.name);
2086
- const realType = typeChecker.getTypeAtLocation(node.initializer);
2087
- result.push([node.name, expectedType, node.initializer, realType]);
2088
- appendNodeToVisit(node.initializer);
2089
- continue;
2090
- } else if (ts.isCallExpression(node)) {
2091
- const resolvedSignature = typeChecker.getResolvedSignature(node);
2092
- if (resolvedSignature) {
2093
- resolvedSignature.parameters.map((parameter, index) => {
2094
- const expectedType = typeChecker.getTypeOfSymbolAtLocation(parameter, node);
2095
- const realType = typeChecker.getTypeAtLocation(node.arguments[index]);
2096
- result.push([
2097
- node.arguments[index],
2098
- expectedType,
2099
- node.arguments[index],
2100
- realType
2101
- ]);
2102
- });
2103
- }
2104
- ts.forEachChild(node, appendNodeToVisit);
2105
- continue;
2106
- } else if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
2107
- const parent = node.parent;
2108
- if (ts.isObjectLiteralElement(parent)) {
2109
- if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) {
2110
- const type = typeChecker.getContextualType(parent.parent);
2111
- if (type) {
2112
- const name = ts.isIdentifier(node) ? ts.idText(node) : ts.isStringLiteral(node) ? node.text : void 0;
2113
- if (name) {
2114
- const symbol3 = typeChecker.getPropertyOfType(type, name);
2115
- if (symbol3) {
2116
- const expectedType = typeChecker.getTypeOfSymbolAtLocation(symbol3, node);
2117
- const realType = typeChecker.getTypeAtLocation(node);
2118
- result.push([node, expectedType, node, realType]);
2119
- }
2120
- }
2121
- }
2122
- }
2123
- }
2124
- ts.forEachChild(node, appendNodeToVisit);
2125
- continue;
2126
- } else if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
2127
- const expectedType = typeChecker.getTypeAtLocation(node.left);
2128
- const realType = typeChecker.getTypeAtLocation(node.right);
2129
- result.push([node.left, expectedType, node.right, realType]);
2130
- appendNodeToVisit(node.right);
2131
- continue;
2132
- } else if (ts.isReturnStatement(node) && node.expression) {
2133
- const parentDeclaration = yield* option(getAncestorConvertibleDeclaration(node));
2134
- if (isSome2(parentDeclaration)) {
2135
- const expectedType = yield* option(getInferredReturnType(parentDeclaration.value));
2136
- const realType = typeChecker.getTypeAtLocation(node.expression);
2137
- if (isSome2(expectedType)) {
2138
- result.push([node, expectedType.value, node, realType]);
2139
- }
2140
- }
2141
- ts.forEachChild(node, appendNodeToVisit);
2142
- continue;
2143
- } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length === 0 && ts.isExpression(node.body)) {
2144
- const body = node.body;
2145
- const expectedType = typeChecker.getContextualType(body);
2146
- const realType = typeChecker.getTypeAtLocation(body);
2147
- if (expectedType) {
2148
- result.push([body, expectedType, body, realType]);
2149
- }
2150
- ts.forEachChild(body, appendNodeToVisit);
2151
- continue;
2152
- } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length > 0 && ts.isExpression(node.body)) {
2153
- const body = node.body;
2154
- const expectedType = yield* option(getInferredReturnType(node));
2155
- const realType = typeChecker.getTypeAtLocation(body);
2156
- if (isSome2(expectedType)) {
2157
- result.push([body, expectedType.value, body, realType]);
2158
- }
2159
- ts.forEachChild(body, appendNodeToVisit);
2160
- continue;
2161
- } else if (ts.isSatisfiesExpression(node)) {
2162
- const expectedType = typeChecker.getTypeAtLocation(node.type);
2163
- const realType = typeChecker.getTypeAtLocation(node.expression);
2164
- result.push([node.expression, expectedType, node.expression, realType]);
2165
- appendNodeToVisit(node.expression);
2166
- continue;
2167
- }
2168
- ts.forEachChild(node, appendNodeToVisit);
2169
- }
2170
- return result;
2171
- }),
2172
- "TypeCheckerApi.expectedAndRealType",
2173
- (sourceFile) => sourceFile
2174
- );
2175
2041
  function makeResolveExternalModuleName(typeChecker) {
2176
2042
  if (!(hasProperty(typeChecker, "resolveExternalModuleName") && isFunction(typeChecker.resolveExternalModuleName))) {
2177
2043
  return;
@@ -2284,12 +2150,161 @@ function makeTypeCheckerUtils(ts, typeChecker) {
2284
2150
  };
2285
2151
  }
2286
2152
  );
2153
+ const deterministicTypeOrder = make2((a, b) => {
2154
+ const aName = typeChecker.typeToString(a);
2155
+ const bName = typeChecker.typeToString(b);
2156
+ if (aName < bName) return -1;
2157
+ if (aName > bName) return 1;
2158
+ return 0;
2159
+ });
2160
+ const getAncestorConvertibleDeclaration = (node) => {
2161
+ let current = node;
2162
+ while (current) {
2163
+ if (ts.isFunctionDeclaration(current) || ts.isFunctionExpression(current) || ts.isArrowFunction(current) || ts.isMethodDeclaration(current)) {
2164
+ return current;
2165
+ }
2166
+ current = current.parent;
2167
+ }
2168
+ };
2169
+ const getInferredReturnType = (declaration) => {
2170
+ if (!declaration.body) {
2171
+ return;
2172
+ }
2173
+ let returnType;
2174
+ if (typeChecker.isImplementationOfOverload(declaration)) {
2175
+ const signatures = typeChecker.getSignaturesOfType(
2176
+ typeChecker.getTypeAtLocation(declaration),
2177
+ ts.SignatureKind.Call
2178
+ );
2179
+ if (signatures.length > 1) {
2180
+ returnType = typeChecker.getUnionType(
2181
+ signatures.map((s) => typeChecker.getReturnTypeOfSignature(s)).filter((_) => !!_)
2182
+ );
2183
+ }
2184
+ }
2185
+ if (!returnType) {
2186
+ const signature = typeChecker.getSignatureFromDeclaration(declaration);
2187
+ if (signature) {
2188
+ const typePredicate = typeChecker.getTypePredicateOfSignature(signature);
2189
+ if (typePredicate && typePredicate.type) {
2190
+ return typePredicate.type;
2191
+ } else {
2192
+ returnType = typeChecker.getReturnTypeOfSignature(signature);
2193
+ }
2194
+ }
2195
+ }
2196
+ return returnType;
2197
+ };
2198
+ const expectedAndRealTypeCache = /* @__PURE__ */ new WeakMap();
2199
+ const expectedAndRealType = (sourceFile) => {
2200
+ const cached2 = expectedAndRealTypeCache.get(sourceFile);
2201
+ if (cached2) return cached2;
2202
+ const result = [];
2203
+ const nodeToVisit = [sourceFile];
2204
+ const appendNodeToVisit = (node) => {
2205
+ nodeToVisit.push(node);
2206
+ return void 0;
2207
+ };
2208
+ while (nodeToVisit.length > 0) {
2209
+ const node = nodeToVisit.shift();
2210
+ if (ts.isVariableDeclaration(node) && node.initializer) {
2211
+ const expectedType = typeChecker.getTypeAtLocation(node.name);
2212
+ const realType = typeChecker.getTypeAtLocation(node.initializer);
2213
+ result.push([node.name, expectedType, node.initializer, realType]);
2214
+ appendNodeToVisit(node.initializer);
2215
+ continue;
2216
+ } else if (ts.isCallExpression(node)) {
2217
+ const resolvedSignature = typeChecker.getResolvedSignature(node);
2218
+ if (resolvedSignature) {
2219
+ resolvedSignature.parameters.map((parameter, index) => {
2220
+ const expectedType = typeChecker.getTypeOfSymbolAtLocation(parameter, node);
2221
+ const realType = typeChecker.getTypeAtLocation(node.arguments[index]);
2222
+ result.push([
2223
+ node.arguments[index],
2224
+ expectedType,
2225
+ node.arguments[index],
2226
+ realType
2227
+ ]);
2228
+ });
2229
+ }
2230
+ ts.forEachChild(node, appendNodeToVisit);
2231
+ continue;
2232
+ } else if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
2233
+ const parent = node.parent;
2234
+ if (ts.isObjectLiteralElement(parent)) {
2235
+ if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) {
2236
+ const type = typeChecker.getContextualType(parent.parent);
2237
+ if (type) {
2238
+ const name = ts.isIdentifier(node) ? ts.idText(node) : ts.isStringLiteral(node) ? node.text : void 0;
2239
+ if (name) {
2240
+ const symbol3 = typeChecker.getPropertyOfType(type, name);
2241
+ if (symbol3) {
2242
+ const expectedType = typeChecker.getTypeOfSymbolAtLocation(symbol3, node);
2243
+ const realType = typeChecker.getTypeAtLocation(node);
2244
+ result.push([node, expectedType, node, realType]);
2245
+ }
2246
+ }
2247
+ }
2248
+ }
2249
+ }
2250
+ ts.forEachChild(node, appendNodeToVisit);
2251
+ continue;
2252
+ } else if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
2253
+ const expectedType = typeChecker.getTypeAtLocation(node.left);
2254
+ const realType = typeChecker.getTypeAtLocation(node.right);
2255
+ result.push([node.left, expectedType, node.right, realType]);
2256
+ appendNodeToVisit(node.right);
2257
+ continue;
2258
+ } else if (ts.isReturnStatement(node) && node.expression) {
2259
+ const parentDeclaration = getAncestorConvertibleDeclaration(node);
2260
+ if (parentDeclaration) {
2261
+ const expectedType = getInferredReturnType(parentDeclaration);
2262
+ const realType = typeChecker.getTypeAtLocation(node.expression);
2263
+ if (expectedType) {
2264
+ result.push([node, expectedType, node, realType]);
2265
+ }
2266
+ }
2267
+ ts.forEachChild(node, appendNodeToVisit);
2268
+ continue;
2269
+ } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length === 0 && ts.isExpression(node.body)) {
2270
+ const body = node.body;
2271
+ const expectedType = typeChecker.getContextualType(body);
2272
+ const realType = typeChecker.getTypeAtLocation(body);
2273
+ if (expectedType) {
2274
+ result.push([body, expectedType, body, realType]);
2275
+ }
2276
+ ts.forEachChild(body, appendNodeToVisit);
2277
+ continue;
2278
+ } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length > 0 && ts.isExpression(node.body)) {
2279
+ const body = node.body;
2280
+ const expectedType = getInferredReturnType(node);
2281
+ const realType = typeChecker.getTypeAtLocation(body);
2282
+ if (expectedType) {
2283
+ result.push([body, expectedType, body, realType]);
2284
+ }
2285
+ ts.forEachChild(body, appendNodeToVisit);
2286
+ continue;
2287
+ } else if (ts.isSatisfiesExpression(node)) {
2288
+ const expectedType = typeChecker.getTypeAtLocation(node.type);
2289
+ const realType = typeChecker.getTypeAtLocation(node.expression);
2290
+ result.push([node.expression, expectedType, node.expression, realType]);
2291
+ appendNodeToVisit(node.expression);
2292
+ continue;
2293
+ }
2294
+ ts.forEachChild(node, appendNodeToVisit);
2295
+ }
2296
+ expectedAndRealTypeCache.set(sourceFile, result);
2297
+ return result;
2298
+ };
2287
2299
  return {
2288
2300
  isUnion,
2289
2301
  getTypeParameterAtPosition,
2290
2302
  getMissingTypeEntriesInTargetType,
2291
2303
  unrollUnionMembers,
2292
- appendToUniqueTypesMap
2304
+ appendToUniqueTypesMap,
2305
+ deterministicTypeOrder,
2306
+ getInferredReturnType,
2307
+ expectedAndRealType
2293
2308
  };
2294
2309
  }
2295
2310
 
@@ -2564,6 +2579,21 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
2564
2579
  "TypeParser.importedEffectModule",
2565
2580
  (node) => node
2566
2581
  );
2582
+ const importedDataModule = cachedBy(
2583
+ fn("TypeParser.importedDataModule")(function* (node) {
2584
+ const type = typeChecker.getTypeAtLocation(node);
2585
+ const propertySymbol = typeChecker.getPropertyOfType(type, "TaggedError");
2586
+ if (!propertySymbol) {
2587
+ return yield* typeParserIssue("Type has no 'TaggedError' property", type, node);
2588
+ }
2589
+ if (!ts.isExpression(node)) {
2590
+ return yield* typeParserIssue("Node is not an expression", type, node);
2591
+ }
2592
+ return node;
2593
+ }),
2594
+ "TypeParser.importedDataModule",
2595
+ (node) => node
2596
+ );
2567
2597
  const effectGen = cachedBy(
2568
2598
  function(node) {
2569
2599
  if (!ts.isCallExpression(node)) {
@@ -2583,7 +2613,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
2583
2613
  return typeParserIssue("Node is not a property access expression", void 0, node);
2584
2614
  }
2585
2615
  const propertyAccess = node.expression;
2586
- if (propertyAccess.name.text !== "gen") {
2616
+ if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "gen")) {
2587
2617
  return typeParserIssue("Call expression name is not 'gen'", void 0, node);
2588
2618
  }
2589
2619
  return pipe(
@@ -2627,7 +2657,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
2627
2657
  );
2628
2658
  }
2629
2659
  const propertyAccess = node.expression;
2630
- if (propertyAccess.name.text !== "fnUntraced") {
2660
+ if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "fnUntraced")) {
2631
2661
  return typeParserIssue(
2632
2662
  "Call expression name is not 'fnUntraced'",
2633
2663
  void 0,
@@ -2680,7 +2710,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
2680
2710
  );
2681
2711
  }
2682
2712
  const propertyAccess = expressionToTest;
2683
- if (propertyAccess.name.text !== "fn") {
2713
+ if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "fn")) {
2684
2714
  return typeParserIssue(
2685
2715
  "Call expression name is not 'fn'",
2686
2716
  void 0,
@@ -2834,7 +2864,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
2834
2864
  kind: "pipeable"
2835
2865
  });
2836
2866
  }
2837
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "pipe" && node.arguments.length > 0) {
2867
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ts.idText(node.expression) === "pipe" && node.arguments.length > 0) {
2838
2868
  const [subject, ...args2] = node.arguments;
2839
2869
  return succeed({ node, subject, args: args2, kind: "pipe" });
2840
2870
  }
@@ -2959,7 +2989,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
2959
2989
  for (const typeX of heritageClause.types) {
2960
2990
  if (ts.isExpressionWithTypeArguments(typeX)) {
2961
2991
  const expression = typeX.expression;
2962
- if (ts.isCallExpression(expression)) {
2992
+ if (ts.isCallExpression(expression) && expression.arguments.length > 0) {
2963
2993
  const schemaTaggedClassTCall = expression.expression;
2964
2994
  if (ts.isCallExpression(schemaTaggedClassTCall) && schemaTaggedClassTCall.typeArguments && schemaTaggedClassTCall.typeArguments.length > 0) {
2965
2995
  const selfTypeNode = schemaTaggedClassTCall.typeArguments[0];
@@ -2973,6 +3003,8 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
2973
3003
  return {
2974
3004
  className: atLocation.name,
2975
3005
  selfTypeNode,
3006
+ keyStringLiteral: schemaTaggedClassTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedClassTCall.arguments[0]) ? schemaTaggedClassTCall.arguments[0] : void 0,
3007
+ tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
2976
3008
  Schema: parsedSchemaModule.value
2977
3009
  };
2978
3010
  }
@@ -3014,6 +3046,8 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3014
3046
  return {
3015
3047
  className: atLocation.name,
3016
3048
  selfTypeNode,
3049
+ keyStringLiteral: schemaTaggedErrorTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedErrorTCall.arguments[0]) ? schemaTaggedErrorTCall.arguments[0] : void 0,
3050
+ tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
3017
3051
  Schema: parsedSchemaModule.value
3018
3052
  };
3019
3053
  }
@@ -3028,6 +3062,82 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3028
3062
  "TypeParser.extendsSchemaTaggedError",
3029
3063
  (atLocation) => atLocation
3030
3064
  );
3065
+ const extendsDataTaggedError = cachedBy(
3066
+ fn("TypeParser.extendsDataTaggedError")(function* (atLocation) {
3067
+ if (!atLocation.name) {
3068
+ return yield* typeParserIssue("Class has no name", void 0, atLocation);
3069
+ }
3070
+ const heritageClauses = atLocation.heritageClauses;
3071
+ if (!heritageClauses) {
3072
+ return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
3073
+ }
3074
+ for (const heritageClause of heritageClauses) {
3075
+ for (const typeX of heritageClause.types) {
3076
+ if (ts.isExpressionWithTypeArguments(typeX)) {
3077
+ const expression = typeX.expression;
3078
+ if (ts.isCallExpression(expression)) {
3079
+ const dataTaggedErrorCall = expression;
3080
+ const dataIdentifier = dataTaggedErrorCall.expression;
3081
+ if (ts.isPropertyAccessExpression(dataIdentifier) && ts.isIdentifier(dataIdentifier.name) && ts.idText(dataIdentifier.name) === "TaggedError") {
3082
+ const parsedDataModule = yield* pipe(
3083
+ importedDataModule(dataIdentifier.expression),
3084
+ option
3085
+ );
3086
+ if (isSome2(parsedDataModule)) {
3087
+ return {
3088
+ className: atLocation.name,
3089
+ keyStringLiteral: dataTaggedErrorCall.arguments.length > 0 && ts.isStringLiteral(dataTaggedErrorCall.arguments[0]) ? dataTaggedErrorCall.arguments[0] : void 0,
3090
+ Data: parsedDataModule.value
3091
+ };
3092
+ }
3093
+ }
3094
+ }
3095
+ }
3096
+ }
3097
+ }
3098
+ return yield* typeParserIssue("Class does not extend Data.TaggedError", void 0, atLocation);
3099
+ }),
3100
+ "TypeParser.extendsDataTaggedError",
3101
+ (atLocation) => atLocation
3102
+ );
3103
+ const extendsDataTaggedClass = cachedBy(
3104
+ fn("TypeParser.extendsDataTaggedClass")(function* (atLocation) {
3105
+ if (!atLocation.name) {
3106
+ return yield* typeParserIssue("Class has no name", void 0, atLocation);
3107
+ }
3108
+ const heritageClauses = atLocation.heritageClauses;
3109
+ if (!heritageClauses) {
3110
+ return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
3111
+ }
3112
+ for (const heritageClause of heritageClauses) {
3113
+ for (const typeX of heritageClause.types) {
3114
+ if (ts.isExpressionWithTypeArguments(typeX)) {
3115
+ const expression = typeX.expression;
3116
+ if (ts.isCallExpression(expression)) {
3117
+ const dataTaggedClassCall = expression;
3118
+ const dataIdentifier = dataTaggedClassCall.expression;
3119
+ if (ts.isPropertyAccessExpression(dataIdentifier) && ts.isIdentifier(dataIdentifier.name) && ts.idText(dataIdentifier.name) === "TaggedClass") {
3120
+ const parsedDataModule = yield* pipe(
3121
+ importedDataModule(dataIdentifier.expression),
3122
+ option
3123
+ );
3124
+ if (isSome2(parsedDataModule)) {
3125
+ return {
3126
+ className: atLocation.name,
3127
+ keyStringLiteral: dataTaggedClassCall.arguments.length > 0 && ts.isStringLiteral(dataTaggedClassCall.arguments[0]) ? dataTaggedClassCall.arguments[0] : void 0,
3128
+ Data: parsedDataModule.value
3129
+ };
3130
+ }
3131
+ }
3132
+ }
3133
+ }
3134
+ }
3135
+ }
3136
+ return yield* typeParserIssue("Class does not extend Data.TaggedClass", void 0, atLocation);
3137
+ }),
3138
+ "TypeParser.extendsDataTaggedClass",
3139
+ (atLocation) => atLocation
3140
+ );
3031
3141
  const extendsSchemaTaggedRequest = cachedBy(
3032
3142
  fn("TypeParser.extendsSchemaTaggedRequest")(function* (atLocation) {
3033
3143
  if (!atLocation.name) {
@@ -3055,6 +3165,8 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3055
3165
  return {
3056
3166
  className: atLocation.name,
3057
3167
  selfTypeNode,
3168
+ tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
3169
+ keyStringLiteral: schemaTaggedRequestTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedRequestTCall.arguments[0]) ? schemaTaggedRequestTCall.arguments[0] : void 0,
3058
3170
  Schema: parsedSchemaModule.value
3059
3171
  };
3060
3172
  }
@@ -3074,9 +3186,6 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3074
3186
  if (!atLocation.name) {
3075
3187
  return yield* typeParserIssue("Class has no name", void 0, atLocation);
3076
3188
  }
3077
- const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
3078
- if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
3079
- const type = typeChecker.getTypeOfSymbol(classSym);
3080
3189
  const heritageClauses = atLocation.heritageClauses;
3081
3190
  if (!heritageClauses) {
3082
3191
  return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
@@ -3096,10 +3205,14 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3096
3205
  option
3097
3206
  );
3098
3207
  if (isSome2(parsedContextModule)) {
3208
+ const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
3209
+ if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
3210
+ const type = typeChecker.getTypeOfSymbol(classSym);
3099
3211
  const tagType = yield* contextTag(type, atLocation);
3100
3212
  return {
3101
3213
  className: atLocation.name,
3102
3214
  selfTypeNode,
3215
+ keyStringLiteral: ts.isStringLiteral(contextTagCall.arguments[0]) ? contextTagCall.arguments[0] : void 0,
3103
3216
  args: contextTagCall.arguments,
3104
3217
  Identifier: tagType.Identifier,
3105
3218
  Tag: parsedContextModule.value
@@ -3121,9 +3234,6 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3121
3234
  if (!atLocation.name) {
3122
3235
  return yield* typeParserIssue("Class has no name", void 0, atLocation);
3123
3236
  }
3124
- const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
3125
- if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
3126
- const type = typeChecker.getTypeOfSymbol(classSym);
3127
3237
  const heritageClauses = atLocation.heritageClauses;
3128
3238
  if (!heritageClauses) {
3129
3239
  return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
@@ -3138,6 +3248,9 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3138
3248
  const effectServiceIdentifier = effectServiceCall.expression;
3139
3249
  const selfTypeNode = effectServiceCall.typeArguments[0];
3140
3250
  if (ts.isPropertyAccessExpression(effectServiceIdentifier) && ts.isIdentifier(effectServiceIdentifier.name) && ts.idText(effectServiceIdentifier.name) === "Service") {
3251
+ const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
3252
+ if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
3253
+ const type = typeChecker.getTypeOfSymbol(classSym);
3141
3254
  const parsedContextTag = yield* pipe(
3142
3255
  importedEffectModule(effectServiceIdentifier.expression),
3143
3256
  flatMap(() => contextTag(type, atLocation)),
@@ -3164,6 +3277,7 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3164
3277
  className: atLocation.name,
3165
3278
  selfTypeNode,
3166
3279
  args: wholeCall.arguments,
3280
+ keyStringLiteral: ts.isStringLiteral(wholeCall.arguments[0]) ? wholeCall.arguments[0] : void 0,
3167
3281
  options: wholeCall.arguments[1],
3168
3282
  accessors: accessors2,
3169
3283
  dependencies
@@ -3202,6 +3316,8 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
3202
3316
  extendsSchemaClass,
3203
3317
  extendsSchemaTaggedClass,
3204
3318
  extendsSchemaTaggedError,
3319
+ extendsDataTaggedError,
3320
+ extendsDataTaggedClass,
3205
3321
  extendsSchemaTaggedRequest
3206
3322
  };
3207
3323
  }
@@ -3227,7 +3343,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
3227
3343
  ),
3228
3344
  void 0,
3229
3345
  [
3230
- ts.factory.createIdentifier(className2.text),
3346
+ ts.factory.createIdentifier(ts.idText(className2)),
3231
3347
  ts.factory.createArrowFunction(
3232
3348
  void 0,
3233
3349
  void 0,
@@ -3277,9 +3393,9 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
3277
3393
  const generateReturnType = (type, atLocation2, className2) => pipe(
3278
3394
  typeParser.effectType(type, atLocation2),
3279
3395
  flatMap((returnedEffect) => {
3280
- const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(className2.text) : ts.factory.createUnionTypeNode(
3396
+ const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(ts.idText(className2)) : ts.factory.createUnionTypeNode(
3281
3397
  [
3282
- ts.factory.createTypeReferenceNode(className2.text),
3398
+ ts.factory.createTypeReferenceNode(ts.idText(className2)),
3283
3399
  typeChecker.typeToTypeNode(returnedEffect.R, atLocation2, ts.NodeBuilderFlags.NoTruncation)
3284
3400
  ]
3285
3401
  );
@@ -3327,7 +3443,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
3327
3443
  ts.factory.createIdentifier("UnknownException")
3328
3444
  )
3329
3445
  ),
3330
- ts.factory.createTypeReferenceNode(className2.text)
3446
+ ts.factory.createTypeReferenceNode(ts.idText(className2))
3331
3447
  ]
3332
3448
  ));
3333
3449
  })
@@ -3344,7 +3460,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
3344
3460
  [
3345
3461
  successType,
3346
3462
  ts.factory.createTypeReferenceNode("never"),
3347
- ts.factory.createTypeReferenceNode(className2.text)
3463
+ ts.factory.createTypeReferenceNode(ts.idText(className2))
3348
3464
  ]
3349
3465
  );
3350
3466
  return succeed(typeNode);
@@ -3421,7 +3537,7 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
3421
3537
  }
3422
3538
  const hash2 = involvedMembers.map(({ property, propertyType }) => {
3423
3539
  return ts.symbolName(property) + ": " + typeChecker.typeToString(propertyType);
3424
- }).concat([className.text]).join("\n");
3540
+ }).concat([ts.idText(className)]).join("\n");
3425
3541
  return { Service, className, atLocation: node, hash: cyrb53(hash2), involvedMembers };
3426
3542
  });
3427
3543
  var writeTagClassAccessors = createRefactor({
@@ -3528,8 +3644,8 @@ var effectDataClasses = createCompletion({
3528
3644
  "effect",
3529
3645
  "Data"
3530
3646
  ) || "Data";
3531
- if (effectDataIdentifier !== accessedObject.text) return [];
3532
- const name = className.text;
3647
+ if (effectDataIdentifier !== ts.idText(accessedObject)) return [];
3648
+ const name = ts.idText(className);
3533
3649
  return [{
3534
3650
  name: `TaggedError("${name}")`,
3535
3651
  kind: ts.ScriptElementKind.constElement,
@@ -3715,7 +3831,7 @@ var effectInVoidSuccess = createDiagnostic({
3715
3831
  }
3716
3832
  return yield* fail(typeParserIssue("expectedEffect success is not void"));
3717
3833
  });
3718
- const entries = yield* expectedAndRealType(sourceFile);
3834
+ const entries = typeCheckerUtils.expectedAndRealType(sourceFile);
3719
3835
  for (const [node, expectedType, valueNode, realType] of entries) {
3720
3836
  if (expectedType !== realType) {
3721
3837
  yield* pipe(
@@ -3984,7 +4100,6 @@ var leakingRequirements = createDiagnostic({
3984
4100
  const typeChecker = yield* service(TypeCheckerApi);
3985
4101
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
3986
4102
  const typeParser = yield* service(TypeParser);
3987
- const typeOrder = yield* deterministicTypeOrder;
3988
4103
  const parseLeakedRequirements = cachedBy(
3989
4104
  fn("leakingServices.checkServiceLeaking")(
3990
4105
  function* (service2, atLocation) {
@@ -4087,7 +4202,9 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
4087
4202
  flatMap(
4088
4203
  ({ Service }) => pipe(
4089
4204
  parseLeakedRequirements(Service, node),
4090
- map3((requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeOrder)))
4205
+ map3(
4206
+ (requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeCheckerUtils.deterministicTypeOrder))
4207
+ )
4091
4208
  )
4092
4209
  ),
4093
4210
  orElse2(() => sync(() => ts.forEachChild(node, appendNodeToVisit))),
@@ -4106,7 +4223,6 @@ var missingEffectContext = createDiagnostic({
4106
4223
  apply: fn("missingEffectContext.apply")(function* (sourceFile, report) {
4107
4224
  const typeChecker = yield* service(TypeCheckerApi);
4108
4225
  const typeParser = yield* service(TypeParser);
4109
- const typeOrder = yield* deterministicTypeOrder;
4110
4226
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
4111
4227
  const checkForMissingContextTypes = (node, expectedType, valueNode, realType) => pipe(
4112
4228
  all(
@@ -4120,8 +4236,8 @@ var missingEffectContext = createDiagnostic({
4120
4236
  )
4121
4237
  )
4122
4238
  );
4123
- const sortTypes = sort(typeOrder);
4124
- const entries = yield* expectedAndRealType(sourceFile);
4239
+ const sortTypes = sort(typeCheckerUtils.deterministicTypeOrder);
4240
+ const entries = getEffectLspPatchSourceFileMetadata(sourceFile)?.relationErrors || typeCheckerUtils.expectedAndRealType(sourceFile);
4125
4241
  for (const [node, expectedType, valueNode, realType] of entries) {
4126
4242
  if (expectedType !== realType) {
4127
4243
  yield* pipe(
@@ -4158,7 +4274,6 @@ var missingEffectError = createDiagnostic({
4158
4274
  const typeChecker = yield* service(TypeCheckerApi);
4159
4275
  const typeCheckerUtils = yield* service(TypeCheckerUtils);
4160
4276
  const typeParser = yield* service(TypeParser);
4161
- const typeOrder = yield* deterministicTypeOrder;
4162
4277
  const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
4163
4278
  sourceFile,
4164
4279
  "effect",
@@ -4187,8 +4302,8 @@ var missingEffectError = createDiagnostic({
4187
4302
  )
4188
4303
  )
4189
4304
  );
4190
- const sortTypes = sort(typeOrder);
4191
- const entries = yield* expectedAndRealType(sourceFile);
4305
+ const sortTypes = sort(typeCheckerUtils.deterministicTypeOrder);
4306
+ const entries = getEffectLspPatchSourceFileMetadata(sourceFile)?.relationErrors || typeCheckerUtils.expectedAndRealType(sourceFile);
4192
4307
  for (const [node, expectedType, valueNode, realType] of entries) {
4193
4308
  if (expectedType !== realType) {
4194
4309
  yield* pipe(
@@ -4225,17 +4340,17 @@ var missingEffectError = createDiagnostic({
4225
4340
  if (ts.isExpression(valueNode)) {
4226
4341
  const propertyAssignments = pipe(
4227
4342
  result.missingErrorTypes,
4228
- map4((_) => typeChecker.getPropertyOfType(_, "_tag")),
4343
+ map5((_) => typeChecker.getPropertyOfType(_, "_tag")),
4229
4344
  filter((_) => !!_),
4230
- map4((_) => typeChecker.getTypeOfSymbolAtLocation(_, valueNode)),
4345
+ map5((_) => typeChecker.getTypeOfSymbolAtLocation(_, valueNode)),
4231
4346
  filter((_) => !!(_.flags & ts.TypeFlags.Literal)),
4232
- map4((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
4347
+ map5((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
4233
4348
  filter((_) => !!_ && ts.isLiteralTypeNode(_)),
4234
- map4((_) => _.literal),
4349
+ map5((_) => _.literal),
4235
4350
  filter((_) => ts.isLiteralExpression(_)),
4236
- map4((_) => _.text),
4351
+ map5((_) => _.text),
4237
4352
  sort(string2),
4238
- map4(
4353
+ map5(
4239
4354
  (_) => ts.factory.createPropertyAssignment(
4240
4355
  ts.factory.createIdentifier(_),
4241
4356
  ts.factory.createArrowFunction(
@@ -5280,8 +5395,8 @@ var effectSchemaSelfInClasses = createCompletion({
5280
5395
  "effect",
5281
5396
  "Schema"
5282
5397
  ) || "Schema";
5283
- if (schemaIdentifier !== accessedObject.text) return [];
5284
- const name = className.text;
5398
+ if (schemaIdentifier !== ts.idText(accessedObject)) return [];
5399
+ const name = ts.idText(className);
5285
5400
  return [{
5286
5401
  name: `Class<${name}>`,
5287
5402
  kind: ts.ScriptElementKind.constElement,
@@ -5324,8 +5439,8 @@ var effectSelfInClasses = createCompletion({
5324
5439
  "effect",
5325
5440
  "Effect"
5326
5441
  ) || "Effect";
5327
- if (effectIdentifier !== accessedObject.text) return [];
5328
- const name = className.text;
5442
+ if (effectIdentifier !== ts.idText(accessedObject)) return [];
5443
+ const name = ts.idText(className);
5329
5444
  return [{
5330
5445
  name: `Service<${name}>`,
5331
5446
  kind: ts.ScriptElementKind.constElement,
@@ -5355,7 +5470,7 @@ var fnFunctionStar = createCompletion({
5355
5470
  const maybeFnName = pipe(
5356
5471
  tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
5357
5472
  filter(ts.isVariableDeclaration),
5358
- map4((_) => _.name && ts.isIdentifier(_.name) ? _.name.text : ""),
5473
+ map5((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
5359
5474
  filter((_) => _.length > 0),
5360
5475
  head,
5361
5476
  map2((name) => [
@@ -5428,8 +5543,8 @@ var rpcMakeClasses = createCompletion({
5428
5543
  "@effect/rpc",
5429
5544
  "Rpc"
5430
5545
  ) || "Rpc";
5431
- if (rpcIdentifier !== accessedObject.text) return [];
5432
- const name = className.text;
5546
+ if (rpcIdentifier !== ts.idText(accessedObject)) return [];
5547
+ const name = ts.idText(className);
5433
5548
  return [{
5434
5549
  name: `make("${name}")`,
5435
5550
  kind: ts.ScriptElementKind.constElement,
@@ -5455,7 +5570,7 @@ var schemaBrand = createCompletion({
5455
5570
  "effect",
5456
5571
  "Schema"
5457
5572
  ) || "Schema";
5458
- if (schemaName !== accessedObject.text) return [];
5573
+ if (schemaName !== ts.idText(accessedObject)) return [];
5459
5574
  const span = ts.createTextSpan(
5460
5575
  accessedObject.end + 1,
5461
5576
  Math.max(0, position - accessedObject.end - 1)
@@ -5463,7 +5578,7 @@ var schemaBrand = createCompletion({
5463
5578
  return pipe(
5464
5579
  tsUtils.getAncestorNodesInRange(sourceFile, tsUtils.toTextRange(accessedObject.pos)),
5465
5580
  filter(ts.isVariableDeclaration),
5466
- map4((_) => _.name && ts.isIdentifier(_.name) ? _.name.text : ""),
5581
+ map5((_) => _.name && ts.isIdentifier(_.name) ? ts.idText(_.name) : ""),
5467
5582
  filter((_) => _.length > 0),
5468
5583
  head,
5469
5584
  map2((name) => [
@@ -5519,7 +5634,7 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5519
5634
  namespaceExports.push({
5520
5635
  moduleSpecifier,
5521
5636
  exportClause,
5522
- name: exportClause.name.text
5637
+ name: ts.idText(exportClause.name)
5523
5638
  });
5524
5639
  }
5525
5640
  if (ts.isNamedExports(exportClause)) {
@@ -5530,8 +5645,8 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5530
5645
  namedExports.push({
5531
5646
  moduleSpecifier,
5532
5647
  exportClause,
5533
- name: exportName.text,
5534
- aliasName: exportSpecifier.name.text
5648
+ name: ts.idText(exportName),
5649
+ aliasName: ts.idText(exportSpecifier.name)
5535
5650
  });
5536
5651
  }
5537
5652
  }
@@ -5691,6 +5806,11 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5691
5806
  if (!moduleSpecifier) return fileName;
5692
5807
  return moduleSpecifier;
5693
5808
  };
5809
+ const resolveAliasName = (chosenName) => {
5810
+ const aliasName = languageServicePluginOptions.importAliases[chosenName];
5811
+ if (aliasName) return aliasName;
5812
+ return void 0;
5813
+ };
5694
5814
  const resolve = (exportFileName, exportName) => {
5695
5815
  const excludedExports = mapFilenameToExportExcludes.get(exportFileName);
5696
5816
  if (excludedExports && excludedExports.includes(exportName)) return;
@@ -5702,7 +5822,9 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5702
5822
  _tag: "NamedImport",
5703
5823
  fileName: reexportedFile.fileName,
5704
5824
  moduleName: resolveModuleName(reexportedFile.fileName),
5705
- name: exportName
5825
+ name: exportName,
5826
+ aliasName: resolveAliasName(exportName),
5827
+ introducedPrefix: void 0
5706
5828
  };
5707
5829
  }
5708
5830
  }
@@ -5717,6 +5839,7 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5717
5839
  fileName: namespacedFileName,
5718
5840
  moduleName: resolveModuleName(namespacedFileName),
5719
5841
  name: introducedAlias2,
5842
+ aliasName: resolveAliasName(introducedAlias2),
5720
5843
  introducedPrefix: void 0
5721
5844
  };
5722
5845
  }
@@ -5729,7 +5852,8 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5729
5852
  fileName: exportFileName,
5730
5853
  moduleName: resolveModuleName(exportFileName),
5731
5854
  name: introducedAlias,
5732
- introducedPrefix: introducedAlias
5855
+ aliasName: resolveAliasName(introducedAlias),
5856
+ introducedPrefix: resolveAliasName(introducedAlias) || introducedAlias
5733
5857
  };
5734
5858
  }
5735
5859
  const mapToBarrel = mapFromNamespaceToBarrel.get(exportFileName);
@@ -5739,7 +5863,8 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
5739
5863
  fileName: mapToBarrel.fileName,
5740
5864
  moduleName: resolveModuleName(mapToBarrel.fileName),
5741
5865
  name: mapToBarrel.alias,
5742
- introducedPrefix: mapToBarrel.alias
5866
+ aliasName: resolveAliasName(mapToBarrel.alias),
5867
+ introducedPrefix: resolveAliasName(mapToBarrel.alias) || mapToBarrel.alias
5743
5868
  };
5744
5869
  }
5745
5870
  };
@@ -5782,7 +5907,7 @@ var parseImportOnlyChanges = fn("parseImportOnlyChanges")(function* (sourceFile,
5782
5907
  if (ts.isNamedImports(namedBindings)) {
5783
5908
  for (const importSpecifier of namedBindings.elements) {
5784
5909
  if (!ts.isIdentifier(importSpecifier.name)) return;
5785
- const exportName = importSpecifier.name.text;
5910
+ const exportName = ts.idText(importSpecifier.name);
5786
5911
  imports.push({ moduleName, exportName });
5787
5912
  continue;
5788
5913
  }
@@ -5816,8 +5941,9 @@ var addImport = (ts, sourceFile, changeTracker, preferences, effectAutoImport) =
5816
5941
  let description = "";
5817
5942
  switch (effectAutoImport._tag) {
5818
5943
  case "NamespaceImport": {
5944
+ const aliasName = effectAutoImport.aliasName || effectAutoImport.name;
5819
5945
  const importModule = effectAutoImport.moduleName || effectAutoImport.fileName;
5820
- description = `Import * as ${effectAutoImport.name} from "${importModule}"`;
5946
+ description = `Import * as ${aliasName} from "${importModule}"`;
5821
5947
  ts.insertImports(
5822
5948
  changeTracker,
5823
5949
  sourceFile,
@@ -5826,7 +5952,7 @@ var addImport = (ts, sourceFile, changeTracker, preferences, effectAutoImport) =
5826
5952
  ts.factory.createImportClause(
5827
5953
  false,
5828
5954
  void 0,
5829
- ts.factory.createNamespaceImport(ts.factory.createIdentifier(effectAutoImport.name))
5955
+ ts.factory.createNamespaceImport(ts.factory.createIdentifier(aliasName))
5830
5956
  ),
5831
5957
  ts.factory.createStringLiteral(importModule)
5832
5958
  ),
@@ -5837,7 +5963,11 @@ var addImport = (ts, sourceFile, changeTracker, preferences, effectAutoImport) =
5837
5963
  }
5838
5964
  case "NamedImport": {
5839
5965
  const importModule = effectAutoImport.moduleName || effectAutoImport.fileName;
5840
- description = `Import { ${effectAutoImport.name} } from "${importModule}"`;
5966
+ if (effectAutoImport.aliasName) {
5967
+ description = `Import { ${effectAutoImport.name} as ${effectAutoImport.aliasName} } from "${importModule}"`;
5968
+ } else {
5969
+ description = `Import { ${effectAutoImport.name} } from "${importModule}"`;
5970
+ }
5841
5971
  let foundImportDeclaration = false;
5842
5972
  for (const statement of sourceFile.statements) {
5843
5973
  if (ts.isImportDeclaration(statement)) {
@@ -5846,9 +5976,12 @@ var addImport = (ts, sourceFile, changeTracker, preferences, effectAutoImport) =
5846
5976
  const importClause = statement.importClause;
5847
5977
  if (importClause && importClause.namedBindings && ts.isNamedImports(importClause.namedBindings)) {
5848
5978
  const namedImports = importClause.namedBindings;
5849
- const existingImportSpecifier = namedImports.elements.find(
5850
- (element) => element.name.text === effectAutoImport.name
5851
- );
5979
+ const existingImportSpecifier = namedImports.elements.find((element) => {
5980
+ if (effectAutoImport.aliasName) {
5981
+ return ts.idText(element.name) === effectAutoImport.name && element.propertyName && ts.isIdentifier(element.propertyName) && ts.idText(element.propertyName) === effectAutoImport.aliasName;
5982
+ }
5983
+ return ts.idText(element.name) === effectAutoImport.name;
5984
+ });
5852
5985
  if (existingImportSpecifier) {
5853
5986
  foundImportDeclaration = true;
5854
5987
  break;
@@ -5860,8 +5993,8 @@ var addImport = (ts, sourceFile, changeTracker, preferences, effectAutoImport) =
5860
5993
  namedImports.elements.concat([
5861
5994
  ts.factory.createImportSpecifier(
5862
5995
  false,
5863
- void 0,
5864
- ts.factory.createIdentifier(effectAutoImport.name)
5996
+ effectAutoImport.aliasName ? ts.factory.createIdentifier(effectAutoImport.name) : void 0,
5997
+ ts.factory.createIdentifier(effectAutoImport.aliasName || effectAutoImport.name)
5865
5998
  )
5866
5999
  ])
5867
6000
  )
@@ -5885,8 +6018,8 @@ var addImport = (ts, sourceFile, changeTracker, preferences, effectAutoImport) =
5885
6018
  [
5886
6019
  ts.factory.createImportSpecifier(
5887
6020
  false,
5888
- void 0,
5889
- ts.factory.createIdentifier(effectAutoImport.name)
6021
+ effectAutoImport.aliasName ? ts.factory.createIdentifier(effectAutoImport.name) : void 0,
6022
+ ts.factory.createIdentifier(effectAutoImport.aliasName || effectAutoImport.name)
5890
6023
  )
5891
6024
  ]
5892
6025
  )
@@ -6094,22 +6227,26 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
6094
6227
  const textRange = tsUtils.toTextRange(position);
6095
6228
  function isSymbolFromEffectRpcModule(symbol3) {
6096
6229
  if (symbol3.valueDeclaration) {
6097
- const sourceFile2 = symbol3.valueDeclaration.getSourceFile();
6098
- const packageInfo = tsUtils.parsePackageContentNameAndVersionFromScope(sourceFile2);
6099
- if (packageInfo && packageInfo.name === "@effect/rpc") {
6100
- const fileSymbol = typeChecker.getSymbolAtLocation(sourceFile2);
6101
- return fileSymbol && fileSymbol.exports && fileSymbol.exports.has("isRpc") && fileSymbol.exports.has("make") && fileSymbol.exports.has("fromTaggedRequest");
6230
+ const sourceFile2 = tsUtils.getSourceFileOfNode(symbol3.valueDeclaration);
6231
+ if (sourceFile2) {
6232
+ const packageInfo = tsUtils.parsePackageContentNameAndVersionFromScope(sourceFile2);
6233
+ if (packageInfo && packageInfo.name === "@effect/rpc") {
6234
+ const fileSymbol = typeChecker.getSymbolAtLocation(sourceFile2);
6235
+ return fileSymbol && fileSymbol.exports && fileSymbol.exports.has("isRpc") && fileSymbol.exports.has("make") && fileSymbol.exports.has("fromTaggedRequest");
6236
+ }
6102
6237
  }
6103
6238
  }
6104
6239
  return false;
6105
6240
  }
6106
6241
  function isSymbolFromEffectRpcClientModule(symbol3) {
6107
6242
  if (symbol3.valueDeclaration) {
6108
- const sourceFile2 = symbol3.valueDeclaration.getSourceFile();
6109
- const packageInfo = tsUtils.parsePackageContentNameAndVersionFromScope(sourceFile2);
6110
- if (packageInfo && packageInfo.name === "@effect/rpc") {
6111
- const fileSymbol = typeChecker.getSymbolAtLocation(sourceFile2);
6112
- return fileSymbol && fileSymbol.exports && fileSymbol.exports.has("RpcClient") && fileSymbol.exports.has("make");
6243
+ const sourceFile2 = tsUtils.getSourceFileOfNode(symbol3.valueDeclaration);
6244
+ if (sourceFile2) {
6245
+ const packageInfo = tsUtils.parsePackageContentNameAndVersionFromScope(sourceFile2);
6246
+ if (packageInfo && packageInfo.name === "@effect/rpc") {
6247
+ const fileSymbol = typeChecker.getSymbolAtLocation(sourceFile2);
6248
+ return fileSymbol && fileSymbol.exports && fileSymbol.exports.has("RpcClient") && fileSymbol.exports.has("make");
6249
+ }
6113
6250
  }
6114
6251
  }
6115
6252
  return false;
@@ -6121,7 +6258,7 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
6121
6258
  const type = typeChecker.getTypeAtLocation(node);
6122
6259
  for (const callSig of typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call)) {
6123
6260
  if (callSig.parameters.length >= 2 && isSymbolFromEffectRpcClientModule(callSig.parameters[1])) {
6124
- rpcName = node.name.text;
6261
+ rpcName = ts.idText(node.name);
6125
6262
  callNode = node.name;
6126
6263
  }
6127
6264
  }
@@ -6149,7 +6286,7 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
6149
6286
  ts.forEachChild(fileToTest, appendNodeToVisit);
6150
6287
  while (result.length === 0 && nodeToVisit.length > 0) {
6151
6288
  const node = nodeToVisit.shift();
6152
- if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && (node.expression.name.text === "make" || node.expression.name.text === "fromTaggedRequest")) {
6289
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && (ts.idText(node.expression.name) === "make" || ts.idText(node.expression.name) === "fromTaggedRequest")) {
6153
6290
  const symbol3 = typeChecker.getSymbolAtLocation(node.expression.name);
6154
6291
  if (symbol3 && isSymbolFromEffectRpcModule(symbol3)) {
6155
6292
  const type = typeChecker.getTypeAtLocation(node);
@@ -11273,11 +11410,11 @@ var effectGenToFn = createRefactor({
11273
11410
  parentNodes,
11274
11411
  filter((_) => ts.isVariableDeclaration(_) && _.initializer ? true : false),
11275
11412
  filter((_) => tsUtils.isNodeInRange(textRange)(_.name)),
11276
- map4((_) => _.initializer)
11413
+ map5((_) => _.initializer)
11277
11414
  );
11278
11415
  const maybeNode = yield* pipe(
11279
11416
  nodesFromInitializers.concat(parentNodes),
11280
- map4(parseFunctionLikeReturnEffectGen),
11417
+ map5(parseFunctionLikeReturnEffectGen),
11281
11418
  firstSuccessOf,
11282
11419
  option
11283
11420
  );
@@ -11285,7 +11422,7 @@ var effectGenToFn = createRefactor({
11285
11422
  const { effectModule, fnIdentifier, generatorFunction, nodeToReplace, pipeArgs } = maybeNode.value;
11286
11423
  return {
11287
11424
  kind: "refactor.rewrite.effect.effectGenToFn",
11288
- description: fnIdentifier ? `Convert to Effect.fn("${fnIdentifier.text}")` : "Convert to Effect.fn",
11425
+ description: fnIdentifier ? `Convert to Effect.fn("${ts.idText(fnIdentifier)}")` : "Convert to Effect.fn",
11289
11426
  apply: pipe(
11290
11427
  gen(function* () {
11291
11428
  const changeTracker = yield* service(ChangeTracker);
@@ -11295,7 +11432,7 @@ var effectGenToFn = createRefactor({
11295
11432
  "fn"
11296
11433
  ),
11297
11434
  void 0,
11298
- [ts.factory.createStringLiteral(fnIdentifier.text)]
11435
+ [ts.factory.createStringLiteral(ts.idText(fnIdentifier))]
11299
11436
  ) : ts.factory.createPropertyAccessExpression(
11300
11437
  effectModule,
11301
11438
  "fn"
@@ -11416,7 +11553,7 @@ var _findSchemaVariableDeclaration = fn(
11416
11553
  );
11417
11554
  return yield* pipe(
11418
11555
  tsUtils.getAncestorNodesInRange(sourceFile, textRange),
11419
- map4(findSchema),
11556
+ map5(findSchema),
11420
11557
  firstSuccessOf,
11421
11558
  option
11422
11559
  );
@@ -11518,15 +11655,15 @@ var makeSchemaOpaque = createRefactor({
11518
11655
  "effect",
11519
11656
  "Schema"
11520
11657
  ) || "Schema";
11521
- const newIdentifier = ts.factory.createIdentifier(identifier.text + "_");
11658
+ const newIdentifier = ts.factory.createIdentifier(ts.idText(identifier) + "_");
11522
11659
  const { contextType, encodedType, opaqueType } = yield* _createOpaqueTypes(
11523
11660
  effectSchemaName,
11524
- newIdentifier.text,
11661
+ ts.idText(newIdentifier),
11525
11662
  types.A,
11526
- identifier.text,
11663
+ ts.idText(identifier),
11527
11664
  types.I,
11528
- identifier.text + "Encoded",
11529
- identifier.text + "Context"
11665
+ ts.idText(identifier) + "Encoded",
11666
+ ts.idText(identifier) + "Context"
11530
11667
  );
11531
11668
  changeTracker.replaceNode(
11532
11669
  sourceFile,
@@ -11551,10 +11688,10 @@ var makeSchemaOpaque = createRefactor({
11551
11688
  variableStatement.modifiers,
11552
11689
  ts.factory.createVariableDeclarationList(
11553
11690
  [ts.factory.createVariableDeclaration(
11554
- identifier.text,
11691
+ ts.idText(identifier),
11555
11692
  void 0,
11556
11693
  newSchemaType,
11557
- ts.factory.createIdentifier(newIdentifier.text)
11694
+ ts.factory.createIdentifier(ts.idText(newIdentifier))
11558
11695
  )],
11559
11696
  variableDeclarationList.flags
11560
11697
  )
@@ -11589,19 +11726,19 @@ var makeSchemaOpaqueWithNs = createRefactor({
11589
11726
  "effect",
11590
11727
  "Schema"
11591
11728
  ) || "Schema";
11592
- const newIdentifier = ts.factory.createIdentifier(identifier.text + "_");
11729
+ const newIdentifier = ts.factory.createIdentifier(ts.idText(identifier) + "_");
11593
11730
  const { contextType, encodedType, opaqueType } = yield* _createOpaqueTypes(
11594
11731
  effectSchemaName,
11595
- newIdentifier.text,
11732
+ ts.idText(newIdentifier),
11596
11733
  types.A,
11597
- identifier.text,
11734
+ ts.idText(identifier),
11598
11735
  types.I,
11599
11736
  "Encoded",
11600
11737
  "Context"
11601
11738
  );
11602
11739
  const namespace = ts.factory.createModuleDeclaration(
11603
11740
  [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
11604
- ts.factory.createIdentifier(identifier.text),
11741
+ ts.factory.createIdentifier(ts.idText(identifier)),
11605
11742
  ts.factory.createModuleBlock([
11606
11743
  encodedType,
11607
11744
  contextType
@@ -11615,6 +11752,7 @@ var makeSchemaOpaqueWithNs = createRefactor({
11615
11752
  );
11616
11753
  changeTracker.insertNodeAfter(sourceFile, variableStatement, opaqueType);
11617
11754
  changeTracker.insertNodeAfter(sourceFile, variableStatement, namespace);
11755
+ const namespaceName = ts.isStringLiteral(namespace.name) ? namespace.name.text : ts.idText(namespace.name);
11618
11756
  const newSchemaType = ts.factory.createTypeReferenceNode(
11619
11757
  ts.factory.createQualifiedName(
11620
11758
  ts.factory.createIdentifier(effectSchemaName),
@@ -11624,13 +11762,15 @@ var makeSchemaOpaqueWithNs = createRefactor({
11624
11762
  ts.factory.createTypeReferenceNode(opaqueType.name),
11625
11763
  ts.factory.createTypeReferenceNode(
11626
11764
  ts.factory.createQualifiedName(
11627
- ts.factory.createIdentifier(namespace.name.text),
11628
- encodedType.name
11765
+ ts.factory.createIdentifier(
11766
+ namespaceName
11767
+ ),
11768
+ ts.idText(encodedType.name)
11629
11769
  )
11630
11770
  ),
11631
11771
  ts.factory.createTypeReferenceNode(ts.factory.createQualifiedName(
11632
- ts.factory.createIdentifier(namespace.name.text),
11633
- contextType.name
11772
+ ts.factory.createIdentifier(namespaceName),
11773
+ ts.idText(contextType.name)
11634
11774
  ))
11635
11775
  ]
11636
11776
  );
@@ -11638,10 +11778,10 @@ var makeSchemaOpaqueWithNs = createRefactor({
11638
11778
  variableStatement.modifiers,
11639
11779
  ts.factory.createVariableDeclarationList(
11640
11780
  [ts.factory.createVariableDeclaration(
11641
- identifier.text,
11781
+ ts.idText(identifier),
11642
11782
  void 0,
11643
11783
  newSchemaType,
11644
- ts.factory.createIdentifier(newIdentifier.text)
11784
+ ts.factory.createIdentifier(ts.idText(newIdentifier))
11645
11785
  )],
11646
11786
  variableDeclarationList.flags
11647
11787
  )
@@ -11667,7 +11807,7 @@ var pipeableToDatafirst = createRefactor({
11667
11807
  if (!ts.isCallExpression(node2)) return false;
11668
11808
  const expression = node2.expression;
11669
11809
  if (!ts.isIdentifier(expression)) return false;
11670
- if (expression.text !== "pipe") return false;
11810
+ if (ts.idText(expression) !== "pipe") return false;
11671
11811
  return true;
11672
11812
  }
11673
11813
  function asDataFirstExpression(node2, self) {
@@ -11699,7 +11839,7 @@ var pipeableToDatafirst = createRefactor({
11699
11839
  filter(
11700
11840
  (node2) => node2.arguments.length > 0
11701
11841
  ),
11702
- map4((node2) => {
11842
+ map5((node2) => {
11703
11843
  let newNode2 = node2.arguments[0];
11704
11844
  let didSomething = false;
11705
11845
  for (let i = 1; i < node2.arguments.length; i++) {
@@ -11726,7 +11866,7 @@ var pipeableToDatafirst = createRefactor({
11726
11866
  return didSomething ? some2([node2, newNode2]) : none2();
11727
11867
  }),
11728
11868
  filter(isSome2),
11729
- map4((_) => _.value),
11869
+ map5((_) => _.value),
11730
11870
  head
11731
11871
  );
11732
11872
  if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
@@ -11876,6 +12016,7 @@ var toggleReturnTypeAnnotation = createRefactor({
11876
12016
  const ts = yield* service(TypeScriptApi);
11877
12017
  const tsUtils = yield* service(TypeScriptUtils);
11878
12018
  const typeChecker = yield* service(TypeCheckerApi);
12019
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
11879
12020
  function addReturnTypeAnnotation(sourceFile2, changeTracker, declaration, typeNode) {
11880
12021
  const closeParen = ts.findChildOfKind(declaration, ts.SyntaxKind.CloseParenToken, sourceFile2);
11881
12022
  const needParens = ts.isArrowFunction(declaration) && closeParen === void 0;
@@ -11923,10 +12064,10 @@ var toggleReturnTypeAnnotation = createRefactor({
11923
12064
  )
11924
12065
  };
11925
12066
  }
11926
- const returnType = yield* option(getInferredReturnType(node));
11927
- if (isNone2(returnType)) return yield* fail(new RefactorNotApplicableError());
12067
+ const returnType = typeCheckerUtils.getInferredReturnType(node);
12068
+ if (!returnType) return yield* fail(new RefactorNotApplicableError());
11928
12069
  const returnTypeNode = typeChecker.typeToTypeNode(
11929
- returnType.value,
12070
+ returnType,
11930
12071
  node,
11931
12072
  ts.NodeBuilderFlags.NoTruncation
11932
12073
  );
@@ -12071,12 +12212,12 @@ var makeSchemaGenContext = fn("SchemaGen.makeSchemaGenContext")(function* (sourc
12071
12212
  ),
12072
12213
  entityNameToDataTypeName: (name) => {
12073
12214
  if (ts.isIdentifier(name)) {
12074
- switch (name.text) {
12215
+ switch (ts.idText(name)) {
12075
12216
  case "Date":
12076
12217
  case "Pick":
12077
12218
  case "Omit":
12078
12219
  case "Record":
12079
- return some2(name.text);
12220
+ return some2(ts.idText(name));
12080
12221
  case "ReadonlyArray":
12081
12222
  case "Array":
12082
12223
  return some2("Array");
@@ -12085,7 +12226,7 @@ var makeSchemaGenContext = fn("SchemaGen.makeSchemaGenContext")(function* (sourc
12085
12226
  }
12086
12227
  if (!ts.isIdentifier(name.left)) return none2();
12087
12228
  for (const moduleName in moduleToImportedName) {
12088
- if (name.left.text === moduleToImportedName[moduleName] && name.right.text === moduleName) {
12229
+ if (ts.idText(name.left) === moduleToImportedName[moduleName] && ts.idText(name.right) === moduleName) {
12089
12230
  return some2(moduleName);
12090
12231
  }
12091
12232
  }
@@ -12099,11 +12240,11 @@ var typeEntityNameToNode = fn(
12099
12240
  )(
12100
12241
  function* (entityName) {
12101
12242
  const { ts } = yield* service(SchemaGenContext);
12102
- if (ts.isIdentifier(entityName)) return ts.factory.createIdentifier(entityName.text);
12243
+ if (ts.isIdentifier(entityName)) return ts.factory.createIdentifier(ts.idText(entityName));
12103
12244
  const left3 = yield* typeEntityNameToNode(entityName.left);
12104
12245
  return ts.factory.createPropertyAccessExpression(
12105
12246
  left3,
12106
- ts.factory.createIdentifier(entityName.right.text)
12247
+ ts.factory.createIdentifier(ts.idText(entityName.right))
12107
12248
  );
12108
12249
  }
12109
12250
  );
@@ -12348,13 +12489,13 @@ var processInterfaceDeclaration = fn("SchemaGen.processInterfaceDeclaration")(
12348
12489
  );
12349
12490
  const { properties, records } = yield* processMembers(node.members, false);
12350
12491
  if (preferClass && records.length === 0) {
12351
- return yield* createExportSchemaClassDeclaration(node.name.text, properties);
12492
+ return yield* createExportSchemaClassDeclaration(ts.idText(node.name), properties);
12352
12493
  }
12353
12494
  const schemaStruct = createApiCall(
12354
12495
  "Struct",
12355
12496
  [ts.factory.createObjectLiteralExpression(properties, true)].concat(records)
12356
12497
  );
12357
- return yield* createExportVariableDeclaration(node.name.text, schemaStruct);
12498
+ return yield* createExportVariableDeclaration(ts.idText(node.name), schemaStruct);
12358
12499
  }
12359
12500
  );
12360
12501
  var processTypeAliasDeclaration = fn("SchemaGen.processInterfaceDeclaration")(
@@ -12366,11 +12507,11 @@ var processTypeAliasDeclaration = fn("SchemaGen.processInterfaceDeclaration")(
12366
12507
  if (preferClass && ts.isTypeLiteralNode(node.type)) {
12367
12508
  const { properties, records } = yield* processMembers(node.type.members, false);
12368
12509
  if (records.length === 0) {
12369
- return yield* createExportSchemaClassDeclaration(node.name.text, properties);
12510
+ return yield* createExportSchemaClassDeclaration(ts.idText(node.name), properties);
12370
12511
  }
12371
12512
  }
12372
12513
  const effectSchema = yield* processNode(node.type, false);
12373
- return yield* createExportVariableDeclaration(node.name.text, effectSchema);
12514
+ return yield* createExportVariableDeclaration(ts.idText(node.name), effectSchema);
12374
12515
  }
12375
12516
  );
12376
12517
  var createExportVariableDeclaration = fn("SchemaGen.createExportVariableDeclaration")(
@@ -12475,6 +12616,7 @@ var typeToEffectSchema = createRefactor({
12475
12616
  const ts = yield* service(TypeScriptApi);
12476
12617
  const tsUtils = yield* service(TypeScriptUtils);
12477
12618
  const typeChecker = yield* service(TypeCheckerApi);
12619
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
12478
12620
  const maybeNode = yield* findNodeToProcess(sourceFile, textRange);
12479
12621
  if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
12480
12622
  const node = maybeNode.value;
@@ -12485,7 +12627,8 @@ var typeToEffectSchema = createRefactor({
12485
12627
  applyAtNode(sourceFile, node, false),
12486
12628
  provideService(TypeCheckerApi, typeChecker),
12487
12629
  provideService(TypeScriptUtils, tsUtils),
12488
- provideService(TypeScriptApi, ts)
12630
+ provideService(TypeScriptApi, ts),
12631
+ provideService(TypeCheckerUtils, typeCheckerUtils)
12489
12632
  )
12490
12633
  };
12491
12634
  })
@@ -12499,6 +12642,7 @@ var typeToEffectSchemaClass = createRefactor({
12499
12642
  const ts = yield* service(TypeScriptApi);
12500
12643
  const tsUtils = yield* service(TypeScriptUtils);
12501
12644
  const typeChecker = yield* service(TypeCheckerApi);
12645
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
12502
12646
  const maybeNode = yield* findNodeToProcess(sourceFile, textRange);
12503
12647
  if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
12504
12648
  const node = maybeNode.value;
@@ -12509,7 +12653,8 @@ var typeToEffectSchemaClass = createRefactor({
12509
12653
  applyAtNode(sourceFile, node, true),
12510
12654
  provideService(TypeCheckerApi, typeChecker),
12511
12655
  provideService(TypeScriptUtils, tsUtils),
12512
- provideService(TypeScriptApi, ts)
12656
+ provideService(TypeScriptApi, ts),
12657
+ provideService(TypeCheckerUtils, typeCheckerUtils)
12513
12658
  )
12514
12659
  };
12515
12660
  })
@@ -12536,7 +12681,7 @@ var wrapWithEffectGen = createRefactor({
12536
12681
  );
12537
12682
  const maybeNode = yield* pipe(
12538
12683
  tsUtils.getAncestorNodesInRange(sourceFile, textRange),
12539
- map4(findEffectToWrap),
12684
+ map5(findEffectToWrap),
12540
12685
  firstSuccessOf,
12541
12686
  option
12542
12687
  );
@@ -12608,6 +12753,57 @@ var refactors = [
12608
12753
  writeTagClassAccessors
12609
12754
  ];
12610
12755
 
12756
+ // src/renames/keyStrings.ts
12757
+ var renameKeyStrings = (sourceFile, position, _findInStrings, _findInComments, _preferences, renameLocations) => gen(function* () {
12758
+ const ts = yield* service(TypeScriptApi);
12759
+ const tsUtils = yield* service(TypeScriptUtils);
12760
+ const typeParser = yield* service(TypeParser);
12761
+ const additionalPositions = [];
12762
+ const node = tsUtils.findNodeAtPositionIncludingTrivia(sourceFile, position);
12763
+ if (node && ts.isIdentifier(node)) {
12764
+ const textToReplace = ts.idText(node);
12765
+ const parentClass = node.parent;
12766
+ if (ts.isClassDeclaration(parentClass) && parentClass.name === node) {
12767
+ const baseIdentifier = yield* pipe(
12768
+ map3(typeParser.extendsContextTag(parentClass), (_) => [_.keyStringLiteral]),
12769
+ orElse2(() => map3(typeParser.extendsEffectService(parentClass), (_) => [_.keyStringLiteral])),
12770
+ orElse2(
12771
+ () => map3(typeParser.extendsSchemaTaggedClass(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
12772
+ ),
12773
+ orElse2(
12774
+ () => map3(typeParser.extendsSchemaTaggedError(parentClass), (_) => [_.keyStringLiteral, _.tagStringLiteral])
12775
+ ),
12776
+ orElse2(() => map3(typeParser.extendsDataTaggedError(parentClass), (_) => [_.keyStringLiteral])),
12777
+ orElse2(() => map3(typeParser.extendsDataTaggedClass(parentClass), (_) => [_.keyStringLiteral])),
12778
+ orElse2(
12779
+ () => map3(
12780
+ typeParser.extendsSchemaTaggedRequest(parentClass),
12781
+ (_) => [_.keyStringLiteral, _.tagStringLiteral]
12782
+ )
12783
+ ),
12784
+ option
12785
+ );
12786
+ if (isSome2(baseIdentifier)) {
12787
+ for (const keyStringLiteral of baseIdentifier.value) {
12788
+ if (!keyStringLiteral) continue;
12789
+ const baseText = sourceFile.text.slice(keyStringLiteral.pos, keyStringLiteral.end);
12790
+ const lastIndex = baseText.lastIndexOf(textToReplace);
12791
+ if (lastIndex !== -1) {
12792
+ additionalPositions.push({
12793
+ fileName: sourceFile.fileName,
12794
+ textSpan: {
12795
+ start: keyStringLiteral.pos + lastIndex,
12796
+ length: textToReplace.length
12797
+ }
12798
+ });
12799
+ }
12800
+ }
12801
+ }
12802
+ }
12803
+ }
12804
+ return additionalPositions.length === 0 ? renameLocations : additionalPositions.concat(renameLocations || []);
12805
+ });
12806
+
12611
12807
  // src/index.ts
12612
12808
  var LSP_INJECTED_URI = "@effect/language-service/injected";
12613
12809
  var init = (modules) => {
@@ -12940,6 +13136,37 @@ var init = (modules) => {
12940
13136
  }
12941
13137
  return applicableInlayHints;
12942
13138
  };
13139
+ proxy.findRenameLocations = (fileName, position, findInStrings, findInComments, userPreferences, ...args2) => {
13140
+ const applicableRenameInfo = languageService.findRenameLocations(
13141
+ fileName,
13142
+ position,
13143
+ findInStrings,
13144
+ findInComments,
13145
+ userPreferences,
13146
+ ...args2
13147
+ );
13148
+ if (languageServicePluginOptions.renames) {
13149
+ const program = languageService.getProgram();
13150
+ if (program) {
13151
+ const sourceFile = program.getSourceFile(fileName);
13152
+ if (sourceFile) {
13153
+ return pipe(
13154
+ renameKeyStrings(
13155
+ sourceFile,
13156
+ position,
13157
+ findInStrings,
13158
+ findInComments,
13159
+ userPreferences,
13160
+ applicableRenameInfo
13161
+ ),
13162
+ runNano(program),
13163
+ getOrElse(() => applicableRenameInfo)
13164
+ );
13165
+ }
13166
+ }
13167
+ }
13168
+ return applicableRenameInfo;
13169
+ };
12943
13170
  return proxy;
12944
13171
  }
12945
13172
  return { create, onConfigurationChanged };