cluaupp 1.5.0 → 1.5.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.
Files changed (323) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +10 -5
  3. package/api/CHANGELOG.md +3 -0
  4. package/api/chat.js +74 -0
  5. package/api/fixtures/roblox/README.md +6 -0
  6. package/api/fixtures/roblox/aux/sample.d.luau +6 -0
  7. package/api/fixtures/roblox/mini/Mini-API-Dump.json +72 -0
  8. package/api/generated/bench-latest.json +39 -0
  9. package/api/generated/capability-profile.json +76 -0
  10. package/api/generated/lsp-index.json +1 -0
  11. package/api/generated/luau/classes.d.luau +11221 -0
  12. package/api/generated/luau/datatypes.d.luau +327 -0
  13. package/api/generated/luau/enums.d.luau +4918 -0
  14. package/api/generated/luau/globals.d.luau +12 -0
  15. package/api/manifests/roblox-target.manifest.json +22 -0
  16. package/api/normalized/roblox-target.profile.json +237461 -0
  17. package/api/overrides/classes.json +8 -0
  18. package/api/overrides/compatibility.json +9 -0
  19. package/api/overrides/datatypes.json +1579 -0
  20. package/api/overrides/enums.json +8 -0
  21. package/api/overrides/globals.json +8 -0
  22. package/api/overrides/type-mappings.json +9 -0
  23. package/api/roblox-api.lock.json +9 -0
  24. package/data/Mini-API-Dump.json +1 -0
  25. package/editors/vscode/README.md +12 -10
  26. package/editors/vscode/extension.js +82 -0
  27. package/editors/vscode/icons/axiom.svg +4 -0
  28. package/editors/vscode/icons/bloom.svg +5 -0
  29. package/editors/vscode/icons/helm.svg +4 -0
  30. package/editors/vscode/icons/hive.svg +5 -0
  31. package/editors/vscode/icons/mint.svg +4 -0
  32. package/editors/vscode/icons/shift.svg +6 -0
  33. package/editors/vscode/language-configuration-schema.json +24 -0
  34. package/editors/vscode/package.json +172 -12
  35. package/editors/vscode/snippets/axiom.json +12 -0
  36. package/editors/vscode/snippets/bloom.json +12 -0
  37. package/editors/vscode/snippets/helm.json +12 -0
  38. package/editors/vscode/snippets/hive.json +12 -0
  39. package/editors/vscode/snippets/mint.json +12 -0
  40. package/editors/vscode/snippets/shift.json +17 -0
  41. package/editors/vscode/syntaxes/axiom.tmLanguage.json +5 -0
  42. package/editors/vscode/syntaxes/bloom.tmLanguage.json +5 -0
  43. package/editors/vscode/syntaxes/helm.tmLanguage.json +5 -0
  44. package/editors/vscode/syntaxes/hive.tmLanguage.json +5 -0
  45. package/editors/vscode/syntaxes/mint.tmLanguage.json +5 -0
  46. package/editors/vscode/syntaxes/schema.tmLanguage.json +89 -0
  47. package/editors/vscode/syntaxes/shift.tmLanguage.json +5 -0
  48. package/examples/game/.cluaupp/compile-cache/ReplicatedStorage__Shared__Constants__Datas__TemplateData.clh.json +1 -0
  49. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Boot__DataBoot.server.clpp.json +1 -0
  50. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Configuration__ServerConfig.clp.json +1 -0
  51. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__Guard.server.clpp.json +1 -0
  52. package/examples/game/.cluaupp/compile-cache/ServerScriptService__Handlers__PlayerHandler.server.clpp.json +1 -0
  53. package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterCharacterScripts__Character__CharacterReady.client.clpp.json +1 -0
  54. package/examples/game/.cluaupp/compile-cache/StarterPlayer__StarterPlayerScripts__Controllers__DataController.client.clpp.json +1 -0
  55. package/examples/game/.cluaupp/compile-cache/index.json +12 -0
  56. package/examples/game/.cluaupp/datamodel-profile.json +94 -0
  57. package/examples/game/.vscode/settings.json +12 -1
  58. package/examples/game/include/clpp/datatypes.clh +337 -373
  59. package/examples/game/include/clpp/generated/datamodel.clh +25 -0
  60. package/examples/game/include/clpp/generated/enums.clh +1 -1
  61. package/examples/game/include/clpp/generated/instances.clh +41135 -41064
  62. package/examples/game/include/clpp/libs/axiom.clh +1 -1
  63. package/examples/game/include/clpp/libs/math.clh +14 -0
  64. package/examples/game/include/clpp/libs/spring.clh +17 -0
  65. package/examples/game/include/clpp/libs/ward.clh +1 -0
  66. package/examples/game/include/clpp/roblox.clh +3 -4
  67. package/examples/game/libs/ArrayIndexer/init.luau +209 -0
  68. package/examples/game/libs/Axiom/init.luau +608 -0
  69. package/examples/game/libs/Bloom/init.luau +433 -0
  70. package/examples/game/libs/Coil/init.luau +215 -0
  71. package/examples/game/libs/Crest/init.luau +426 -0
  72. package/examples/game/libs/Echo/init.luau +417 -0
  73. package/examples/game/libs/Ember/init.luau +365 -0
  74. package/examples/game/libs/Flare/init.luau +717 -0
  75. package/examples/game/libs/Gleam/init.luau +729 -0
  76. package/examples/game/libs/Guide/init.luau +215 -0
  77. package/examples/game/libs/Helm/init.luau +377 -0
  78. package/examples/game/libs/Hive/init.luau +241 -0
  79. package/examples/game/libs/Keep/Client.luau +114 -0
  80. package/examples/game/libs/Keep/Data.luau +883 -0
  81. package/examples/game/libs/Keep/Engine.luau +211 -0
  82. package/examples/game/libs/Keep/Enum.luau +6 -0
  83. package/examples/game/libs/Keep/Enums.luau +10 -0
  84. package/examples/game/libs/Keep/Path.luau +236 -0
  85. package/examples/game/libs/Keep/Replicator.luau +298 -0
  86. package/examples/game/libs/Keep/Server.luau +251 -0
  87. package/examples/game/libs/Keep/Store.luau +652 -0
  88. package/examples/game/libs/Keep/Trade.luau +455 -0
  89. package/examples/game/libs/Keep/init.luau +205 -0
  90. package/examples/game/libs/Lens/init.luau +609 -0
  91. package/examples/game/libs/Mint/init.luau +279 -0
  92. package/examples/game/libs/Net/init.luau +156 -0
  93. package/examples/game/libs/Net/src/codec.luau +224 -0
  94. package/examples/game/libs/Occlude/init.luau +117 -0
  95. package/examples/game/libs/Pin/init.luau +309 -0
  96. package/examples/game/libs/Promise/LICENSE +21 -0
  97. package/examples/game/libs/Promise/_impl/LICENSE +21 -0
  98. package/examples/game/libs/Promise/_impl/init.lua +1991 -0
  99. package/examples/game/libs/Promise/init.lua +1990 -0
  100. package/examples/game/libs/Promise/init.luau +13 -0
  101. package/examples/game/libs/Promise/types.luau +46 -0
  102. package/examples/game/libs/Roster/init.luau +686 -0
  103. package/examples/game/libs/SOURCES.md +31 -0
  104. package/examples/game/libs/Shift/init.luau +238 -0
  105. package/examples/game/libs/Spark/init.luau +487 -0
  106. package/examples/game/libs/Stage/init.luau +178 -0
  107. package/examples/game/libs/Sweep/init.luau +259 -0
  108. package/examples/game/libs/Trace/init.luau +213 -0
  109. package/examples/game/libs/Ward/init.luau +211 -0
  110. package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau +29 -0
  111. package/examples/game/out/ReplicatedStorage/Shared/Constants/Datas/TemplateData.luau.map.json +13 -0
  112. package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau +83 -0
  113. package/examples/game/out/ReplicatedStorage/Shared/Net/Net.luau.map.json +13 -0
  114. package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau +18 -0
  115. package/examples/game/out/ServerScriptService/Boot/DataBoot.server.luau.map.json +13 -0
  116. package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau +14 -0
  117. package/examples/game/out/ServerScriptService/Configuration/ServerConfig.luau.map.json +13 -0
  118. package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau +15 -0
  119. package/examples/game/out/ServerScriptService/Handlers/Guard.server.luau.map.json +13 -0
  120. package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau +50 -0
  121. package/examples/game/out/ServerScriptService/Handlers/PlayerHandler.server.luau.map.json +13 -0
  122. package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau +12 -0
  123. package/examples/game/out/StarterPlayer/StarterCharacterScripts/Character/CharacterReady.client.luau.map.json +13 -0
  124. package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau +16 -0
  125. package/examples/game/out/StarterPlayer/StarterPlayerScripts/Controllers/DataController.client.luau.map.json +13 -0
  126. package/examples/game/src/ReplicatedStorage/Shared/Net/Net.clh +26 -0
  127. package/examples/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
  128. package/examples/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
  129. package/examples/game/stylua.toml +9 -0
  130. package/generated/api/build-profile.js +115 -0
  131. package/generated/api/cache.js +44 -0
  132. package/generated/api/coverage.js +32 -0
  133. package/generated/api/diff.js +125 -0
  134. package/generated/api/generators/clpp-headers.js +353 -0
  135. package/generated/api/generators/docs-reference.js +7 -0
  136. package/generated/api/generators/lsp-index.js +81 -0
  137. package/generated/api/generators/luau-defs.js +94 -0
  138. package/generated/api/ide.js +76 -0
  139. package/generated/api/identifier.js +47 -0
  140. package/generated/api/index.js +324 -0
  141. package/generated/api/loader.js +57 -0
  142. package/generated/api/merge.js +88 -0
  143. package/generated/api/model.js +5 -0
  144. package/generated/api/normalize.js +231 -0
  145. package/generated/api/overrides-validate.js +58 -0
  146. package/generated/api/perf.js +12 -0
  147. package/generated/api/registry.js +136 -0
  148. package/generated/api/release.js +44 -0
  149. package/generated/api/resolver.js +250 -0
  150. package/generated/api/sources/aux-types-diff.js +75 -0
  151. package/generated/api/sources/client-tracker.js +11 -0
  152. package/generated/api/sources/creator-docs.js +42 -0
  153. package/generated/api/sources/luau-types.js +34 -0
  154. package/generated/api/sources/mini-dump.js +17 -0
  155. package/generated/api/sources/studio-api.js +8 -0
  156. package/generated/api/sources/studio-apiv2.js +11 -0
  157. package/generated/api/sources/studio-full-api.js +8 -0
  158. package/generated/api/studio-smoke.js +80 -0
  159. package/generated/api/type-parse.js +49 -0
  160. package/generated/api/understander.js +51 -0
  161. package/generated/api/validate.js +135 -0
  162. package/generated/api-cli.js +421 -0
  163. package/generated/cli.js +16 -5
  164. package/generated/clpp/contract.js +3 -3
  165. package/generated/clpp/format-luau.js +236 -0
  166. package/generated/clpp/index.js +13 -1
  167. package/generated/clpp/modules.js +227 -0
  168. package/generated/clpp/postprocess.js +86 -5
  169. package/generated/clpp/rewrite-janitor.js +145 -0
  170. package/generated/clpp/runner.js +14 -2
  171. package/generated/compile.js +82 -0
  172. package/generated/flare/parse.js +12 -1
  173. package/generated/intellisense.js +57 -1
  174. package/generated/native/index.js +217 -16
  175. package/generated/target/authority-check.js +136 -0
  176. package/generated/target/authority-graph.js +74 -0
  177. package/generated/target/build-cache.js +112 -0
  178. package/generated/target/capabilities.js +89 -0
  179. package/generated/target/capability-profile.js +30 -0
  180. package/generated/target/component-contracts.js +60 -0
  181. package/generated/target/context-check.js +160 -0
  182. package/generated/target/datamodel-check.js +170 -0
  183. package/generated/target/datamodel-generate.js +74 -0
  184. package/generated/target/datamodel.js +233 -0
  185. package/generated/target/diagnostics.js +63 -0
  186. package/generated/target/doctor.js +152 -0
  187. package/generated/target/flare-version.js +58 -0
  188. package/generated/target/get-service.js +69 -0
  189. package/generated/target/lifetime-check.js +47 -0
  190. package/generated/target/luau-stamp.js +39 -0
  191. package/generated/target/optimizer-advise.js +88 -0
  192. package/generated/target/optimizer-apply.js +44 -0
  193. package/generated/target/optimizer-soa.js +254 -0
  194. package/generated/target/parallel-check.js +136 -0
  195. package/generated/target/pgo.js +148 -0
  196. package/generated/target/project-docs.js +69 -0
  197. package/generated/target/project-graph.js +71 -0
  198. package/generated/target/roblox.js +63 -0
  199. package/generated/target/security-check.js +41 -0
  200. package/generated/target/source-map.js +25 -0
  201. package/generated/target/studio-bridge.js +112 -0
  202. package/generated/utils/project.js +178 -8
  203. package/generated/utils/rojo-mapper.js +11 -3
  204. package/include/clpp/datatypes.clh +337 -373
  205. package/include/clpp/generated/enums.clh +1 -1
  206. package/include/clpp/generated/instances.clh +41135 -41064
  207. package/include/clpp/libs/axiom.clh +1 -1
  208. package/include/clpp/libs/hive.clh +1 -0
  209. package/include/clpp/libs/keep.clh +2 -0
  210. package/include/clpp/libs/math.clh +14 -0
  211. package/include/clpp/libs/spring.clh +17 -0
  212. package/include/clpp/libs/ward.clh +1 -0
  213. package/include/clpp/roblox.clh +3 -4
  214. package/package.json +10 -3
  215. package/plugins/CluauppNav/Plugin.luau +207 -0
  216. package/plugins/CluauppNav/ProfileLogger.luau +27 -0
  217. package/plugins/CluauppNav/README.md +24 -0
  218. package/runtime/Axiom/init.luau +10 -7
  219. package/runtime/Coil/init.luau +8 -2
  220. package/runtime/Crest/init.luau +1 -0
  221. package/runtime/Flare/init.luau +2 -1
  222. package/runtime/Gleam/init.luau +15 -4
  223. package/runtime/Hive/init.luau +36 -14
  224. package/runtime/Pin/init.luau +5 -2
  225. package/runtime/Roster/init.luau +2 -0
  226. package/runtime/Spark/init.luau +3 -0
  227. package/runtime/Sweep/init.luau +2 -0
  228. package/runtime/Trace/init.luau +3 -0
  229. package/runtime/Ward/init.luau +38 -5
  230. package/scripts/postinstall-editor.js +17 -0
  231. package/skills/README.md +13 -0
  232. package/skills/clpp-hive-flare/SKILL.md +79 -0
  233. package/skills/clpp-language/SKILL.md +123 -0
  234. package/skills/clpp-language/compiler.md +89 -0
  235. package/skills/clpp-style/SKILL.md +95 -0
  236. package/src/api/build-profile.ts +138 -0
  237. package/src/api/cache.ts +45 -0
  238. package/src/api/coverage.ts +46 -0
  239. package/src/api/diff.ts +143 -0
  240. package/src/api/generators/clpp-headers.ts +377 -0
  241. package/src/api/generators/docs-reference.ts +11 -0
  242. package/src/api/generators/lsp-index.ts +106 -0
  243. package/src/api/generators/luau-defs.ts +98 -0
  244. package/src/api/ide.ts +87 -0
  245. package/src/api/identifier.ts +47 -0
  246. package/src/api/index.ts +269 -0
  247. package/src/api/loader.ts +60 -0
  248. package/src/api/merge.ts +126 -0
  249. package/src/api/model.ts +283 -0
  250. package/src/api/normalize.ts +257 -0
  251. package/src/api/overrides-validate.ts +58 -0
  252. package/src/api/perf.ts +15 -0
  253. package/src/api/registry.ts +162 -0
  254. package/src/api/release.ts +47 -0
  255. package/src/api/resolver.ts +255 -0
  256. package/src/api/sources/aux-types-diff.ts +81 -0
  257. package/src/api/sources/client-tracker.ts +10 -0
  258. package/src/api/sources/creator-docs.ts +37 -0
  259. package/src/api/sources/luau-types.ts +30 -0
  260. package/src/api/sources/mini-dump.ts +50 -0
  261. package/src/api/sources/studio-api.ts +7 -0
  262. package/src/api/sources/studio-apiv2.ts +10 -0
  263. package/src/api/sources/studio-full-api.ts +7 -0
  264. package/src/api/studio-smoke.ts +82 -0
  265. package/src/api/type-parse.ts +48 -0
  266. package/src/api/understander.ts +72 -0
  267. package/src/api/validate.ts +160 -0
  268. package/src/api-cli.ts +493 -0
  269. package/src/api.generated.js +37 -22
  270. package/src/cli.ts +21 -6
  271. package/src/clpp/contract.ts +34 -3
  272. package/src/clpp/format-luau.ts +262 -0
  273. package/src/clpp/index.ts +13 -2
  274. package/src/clpp/modules.ts +252 -0
  275. package/src/clpp/postprocess.ts +100 -5
  276. package/src/clpp/rewrite-janitor.ts +156 -0
  277. package/src/clpp/runner.ts +14 -2
  278. package/src/compile.ts +87 -0
  279. package/src/flare/parse.ts +14 -1
  280. package/src/flare/types.ts +2 -0
  281. package/src/intellisense.ts +58 -1
  282. package/src/native/index.ts +225 -16
  283. package/src/target/authority-check.ts +162 -0
  284. package/src/target/authority-graph.ts +80 -0
  285. package/src/target/build-cache.ts +129 -0
  286. package/src/target/capabilities.ts +115 -0
  287. package/src/target/capability-profile.ts +25 -0
  288. package/src/target/component-contracts.ts +64 -0
  289. package/src/target/context-check.ts +177 -0
  290. package/src/target/datamodel-check.ts +188 -0
  291. package/src/target/datamodel-generate.ts +78 -0
  292. package/src/target/datamodel.ts +261 -0
  293. package/src/target/diagnostics.ts +67 -0
  294. package/src/target/doctor.ts +171 -0
  295. package/src/target/flare-version.ts +61 -0
  296. package/src/target/get-service.ts +85 -0
  297. package/src/target/lifetime-check.ts +45 -0
  298. package/src/target/luau-stamp.ts +33 -0
  299. package/src/target/optimizer-advise.ts +93 -0
  300. package/src/target/optimizer-apply.ts +63 -0
  301. package/src/target/optimizer-soa.ts +270 -0
  302. package/src/target/parallel-check.ts +135 -0
  303. package/src/target/pgo.ts +157 -0
  304. package/src/target/project-docs.ts +68 -0
  305. package/src/target/project-graph.ts +75 -0
  306. package/src/target/roblox.ts +78 -0
  307. package/src/target/security-check.ts +40 -0
  308. package/src/target/source-map.ts +36 -0
  309. package/src/target/studio-bridge.ts +140 -0
  310. package/src/types.ts +14 -0
  311. package/src/utils/project.ts +183 -9
  312. package/src/utils/rojo-mapper.ts +12 -3
  313. package/stylua.toml +9 -0
  314. package/templates/game/.vscode/settings.json +7 -1
  315. package/templates/game/include/clpp/datatypes.clh +337 -373
  316. package/templates/game/include/clpp/generated/enums.clh +1 -1
  317. package/templates/game/include/clpp/generated/instances.clh +41135 -41064
  318. package/templates/game/include/clpp/libs/axiom.clh +1 -1
  319. package/templates/game/include/clpp/libs/ward.clh +1 -0
  320. package/templates/game/include/clpp/roblox.clh +3 -4
  321. package/templates/game/src/ServerScriptService/Boot/DataBoot.server.clpp +1 -1
  322. package/templates/game/src/ServerScriptService/Handlers/PlayerHandler.server.clpp +1 -1
  323. package/templates/game/stylua.toml +9 -0
@@ -0,0 +1,377 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { projectRoot } from "../../package-info.js";
4
+ import { escapeIdent, escapeMember } from "../identifier.js";
5
+ import type {
6
+ ClassDefinition,
7
+ DatatypeDefinition,
8
+ EnumDefinition,
9
+ MethodDefinition,
10
+ ParameterDefinition,
11
+ RobloxTargetProfile,
12
+ } from "../model.js";
13
+ import { buildRegistry, flattenMembers } from "../registry.js";
14
+ import { typeToClpp } from "../resolver.js";
15
+
16
+ function mkdirp(dir: string): void {
17
+ fs.mkdirSync(dir, { recursive: true });
18
+ }
19
+
20
+ function atomicWrite(file: string, contents: string): void {
21
+ mkdirp(path.dirname(file));
22
+ const tmp = `${file}.${process.pid}.tmp`;
23
+ fs.writeFileSync(tmp, contents, "utf8");
24
+ fs.renameSync(tmp, file);
25
+ }
26
+
27
+ function headerType(type: import("../model.js").CanonicalType, memberName?: string): string {
28
+ if (type.kind === "Unsupported") {
29
+ return "auto";
30
+ }
31
+ if (type.kind === "Primitive") {
32
+ if (type.name === "int64") {
33
+ return "long long";
34
+ }
35
+ if (type.name === "boolean") {
36
+ return "bool";
37
+ }
38
+ return type.name;
39
+ }
40
+ if (type.kind === "Datatype" && type.name === "Instances") {
41
+ if (memberName === "GetPlayers" || memberName === "getPlayers" || memberName === "players") {
42
+ return "LuaArray<Player>";
43
+ }
44
+ return "LuaArray<Instance>";
45
+ }
46
+ if (type.kind === "Datatype" && (type.name === "ContentId" || type.name === "BinaryString" || type.name === "ProtectedString" || type.name === "SharedString")) {
47
+ return "string";
48
+ }
49
+ if (type.kind === "Class" || type.kind === "Datatype") {
50
+ return escapeIdent(type.name);
51
+ }
52
+ const mapped = typeToClpp(type);
53
+ if (mapped.includes("void*") || mapped === "auto") {
54
+ return "auto";
55
+ }
56
+ return mapped;
57
+ }
58
+
59
+ function emitParams(parameters: ParameterDefinition[]): string {
60
+ const defaults = parameters.map((p) => {
61
+ if (!p.default || String(p.default).includes("__api_dump")) {
62
+ return "";
63
+ }
64
+ const raw = String(p.default);
65
+ if (raw === "nil" || raw === "null") {
66
+ return " = null";
67
+ }
68
+ if (raw === "true" || raw === "false") {
69
+ return ` = ${raw}`;
70
+ }
71
+ if (/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(raw)) {
72
+ return ` = ${raw}`;
73
+ }
74
+ if (raw.startsWith("Enum.")) {
75
+ const parts = raw.split(".");
76
+ if (parts.length >= 3) {
77
+ return ` = Enum::${escapeIdent(parts[1])}::${escapeIdent(parts[2])}`;
78
+ }
79
+ }
80
+ return "";
81
+ });
82
+ const use = parameters.map(() => "");
83
+ for (let i = parameters.length - 1; i >= 0; i--) {
84
+ if (!defaults[i]) {
85
+ break;
86
+ }
87
+ use[i] = defaults[i];
88
+ }
89
+ return parameters
90
+ .map((p, i) => `${headerType(p.type)} ${escapeIdent(p.name)}${use[i]}`)
91
+ .join(", ");
92
+ }
93
+
94
+ function generateEnums(enums: Record<string, EnumDefinition>): string {
95
+ let out = `#pragma once
96
+ // Generated from RobloxTargetProfile. Enum.Name.Item → Enum::Name::Item
97
+ namespace Enum {
98
+ `;
99
+ for (const name of Object.keys(enums).sort()) {
100
+ const en = enums[name];
101
+ out += `\tenum class ${escapeIdent(en.name)} {\n`;
102
+ for (const item of en.items) {
103
+ out += `\t\t${escapeIdent(item.name)} = ${item.numericValue},\n`;
104
+ }
105
+ out += `\t};\n`;
106
+ }
107
+ out += `}\n`;
108
+ return out;
109
+ }
110
+
111
+ function emitDatatype(dt: DatatypeDefinition): string {
112
+ if (dt.name === "RBXScriptSignal") {
113
+ return `
114
+ // Event. PlayerAdded.Connect(callback) — F matches any listener arity.
115
+ struct RBXScriptSignal {
116
+ template <typename F>
117
+ RBXScriptConnection Connect(F callback);
118
+ template <typename F>
119
+ RBXScriptConnection Once(F callback);
120
+ template <typename F>
121
+ RBXScriptConnection ConnectParallel(F callback);
122
+ LuauValue Wait();
123
+ };
124
+ `;
125
+ }
126
+ let out = `\n// ${dt.summary || dt.name}\nstruct ${escapeIdent(dt.name)} {\n`;
127
+ for (const field of dt.fields) {
128
+ const ty = headerType(field.type);
129
+ if (ty === escapeIdent(dt.name)) {
130
+ out += `\t${escapeIdent(dt.name)} ${escapeIdent(field.name)}() const;\n`;
131
+ } else {
132
+ out += `\t${ty} ${escapeIdent(field.name)};\n`;
133
+ }
134
+ }
135
+ for (const ctor of dt.constructors) {
136
+ out += `\t${escapeIdent(dt.name)}(${emitParams(ctor.parameters)});\n`;
137
+ }
138
+ for (const st of dt.staticProperties) {
139
+ out += `\tstatic ${escapeIdent(dt.name)} ${escapeIdent(st)};\n`;
140
+ }
141
+ for (const m of dt.staticMethods) {
142
+ out += `\tstatic ${headerType(m.returnTypes[0] || { kind: "Primitive", name: "void" })} ${escapeIdent(m.name)}(${emitParams(m.parameters)});\n`;
143
+ }
144
+ for (const m of dt.instanceMethods) {
145
+ out += `\t${headerType(m.returnTypes[0] || { kind: "Primitive", name: "void" })} ${escapeIdent(m.name)}(${emitParams(m.parameters)});\n`;
146
+ }
147
+ out += `};\n`;
148
+ return out;
149
+ }
150
+
151
+ function generateDatatypes(profile: RobloxTargetProfile): string {
152
+ let out = `#pragma once
153
+ #include <clpp/generated/enums.clh>
154
+ using Enum::EasingStyle;
155
+ using Enum::EasingDirection;
156
+ using Enum::Material;
157
+ using Enum::FontWeight;
158
+ using Enum::FontStyle;
159
+ using Enum::RaycastFilterType;
160
+ using Enum::PathWaypointAction;
161
+ using Enum::CatalogSortType;
162
+ using Enum::CatalogSortAggregation;
163
+ using Enum::CatalogCategoryFilter;
164
+ using Enum::SalesTypeFilter;
165
+ using Enum::KeyInterpolationMode;
166
+ using Enum::NormalId;
167
+ using Enum::Axis;
168
+
169
+ using string = const char*;
170
+
171
+ // Variadic join. Cluaupp emits Luau a .. b .. c.
172
+ template <typename... Args>
173
+ string string_concat(Args... args);
174
+
175
+ struct Instance;
176
+ struct Player;
177
+
178
+ // Stand-in for values the C++ IntelliSense stubs cannot name precisely.
179
+ struct LuauValue {
180
+ LuauValue();
181
+ template <typename T>
182
+ LuauValue(const T&);
183
+ template <typename T>
184
+ operator T() const;
185
+ };
186
+
187
+ template <typename T>
188
+ struct LuaArray {
189
+ T* _begin;
190
+ T* _end;
191
+ T* begin() const { return _begin; }
192
+ T* end() const { return _end; }
193
+ int Size() const;
194
+ T operator[](int index) const;
195
+ };
196
+ `;
197
+ const skip = new Set(["Function", "Tuple", "Variant", "Array", "Dictionary", "Map", "User", "Instances", "ContentId"]);
198
+ for (const name of Object.keys(profile.datatypes).sort()) {
199
+ out += emitDatatype(profile.datatypes[name]);
200
+ }
201
+ // Stub any datatype-like Class names referenced only as DataType elsewhere — kept empty for now.
202
+ void skip;
203
+ return out;
204
+ }
205
+
206
+ function isCreatableClass(cls: ClassDefinition): boolean {
207
+ return (
208
+ cls.creatable ||
209
+ cls.name === "Folder" ||
210
+ cls.name === "Part" ||
211
+ cls.name === "MeshPart" ||
212
+ cls.name === "Model" ||
213
+ cls.name === "WedgePart" ||
214
+ cls.name === "CornerWedgePart" ||
215
+ cls.name === "TrussPart"
216
+ );
217
+ }
218
+
219
+ function emitMethod(clsName: string, method: MethodDefinition): string {
220
+ const name = escapeMember(clsName, method.name);
221
+ const ret = headerType(method.returnTypes[0] || { kind: "Primitive", name: "void" }, method.name);
222
+ if (method.name === "WaitForChild" && method.parameters.length >= 1) {
223
+ const first = `${headerType(method.parameters[0].type)} ${escapeIdent(method.parameters[0].name)}`;
224
+ return `\t${ret} ${name}(${first});\n\t${ret} ${name}(${first}, double timeOut);\n`;
225
+ }
226
+ return `\t${ret} ${name}(${emitParams(method.parameters)});\n`;
227
+ }
228
+
229
+ function generateInstances(profile: RobloxTargetProfile): string {
230
+ const registry = buildRegistry(profile);
231
+ let out = `#pragma once
232
+ #include <clpp/datatypes.clh>
233
+
234
+ // Flattened members: IntelliSense view from ClassGraph (does not mutate inheritance).
235
+ // Creatable classes get Class() and Class(Instance parent).
236
+
237
+ `;
238
+ const classNames = Object.keys(profile.classes).sort();
239
+ for (const name of classNames) {
240
+ out += `struct ${escapeIdent(name)};\n`;
241
+ }
242
+ out += "\n";
243
+
244
+ for (const name of classNames) {
245
+ const cls = profile.classes[name];
246
+ const superName = cls.superclass && profile.classes[cls.superclass] ? escapeIdent(cls.superclass) : "";
247
+ const parent = superName ? ` : ${superName}` : "";
248
+ out += `struct ${escapeIdent(cls.name)}${parent} {\n`;
249
+ if (isCreatableClass(cls)) {
250
+ out += `\t${escapeIdent(cls.name)}();\n`;
251
+ out += `\t${escapeIdent(cls.name)}(Instance parent);\n`;
252
+ } else if (!parent) {
253
+ out += `\t${escapeIdent(cls.name)}() = default;\n`;
254
+ }
255
+ const flat = flattenMembers(registry, cls.name);
256
+ for (const prop of flat.properties) {
257
+ out += `\t${headerType(prop.valueType)} ${escapeMember(cls.name, prop.name)};\n`;
258
+ }
259
+ for (const method of flat.methods) {
260
+ out += emitMethod(cls.name, method);
261
+ }
262
+ for (const event of flat.events) {
263
+ const params = event.parameters.map((p) => headerType(p.type)).join(", ");
264
+ out += `\tRBXScriptSignal ${escapeMember(cls.name, event.name)};${params ? ` /* (${params}) */` : ""}\n`;
265
+ }
266
+ for (const cb of cls.callbacks) {
267
+ out += `\tvoid (*${escapeMember(cls.name, cb.name)})();\n`;
268
+ }
269
+ out += `};\n\n`;
270
+ }
271
+ return out;
272
+ }
273
+
274
+ function generateApiJs(profile: RobloxTargetProfile): string {
275
+ const instanceTypes: string[] = [];
276
+ const services: string[] = [];
277
+ const methods = new Set(["Connect", "Once", "Disconnect", "Wait", "GetService"]);
278
+ for (const cls of Object.values(profile.classes)) {
279
+ if (cls.service || cls.creation.service) {
280
+ services.push(cls.name);
281
+ }
282
+ if (isCreatableClass(cls)) {
283
+ instanceTypes.push(cls.name);
284
+ }
285
+ for (const m of cls.methods) {
286
+ methods.add(m.name);
287
+ }
288
+ }
289
+ for (const dt of Object.values(profile.datatypes)) {
290
+ for (const m of dt.instanceMethods) {
291
+ methods.add(m.name);
292
+ }
293
+ }
294
+ const datatypes = Object.keys(profile.datatypes).sort();
295
+ return `// Generated from RobloxTargetProfile schemaVersion ${profile.schemaVersion}
296
+ "use strict";
297
+ module.exports = {
298
+ INSTANCE_TYPES: ${JSON.stringify(instanceTypes.sort(), null, "\t")},
299
+ SERVICES: ${JSON.stringify(services.sort(), null, "\t")},
300
+ METHODS: ${JSON.stringify([...methods].sort(), null, "\t")},
301
+ DATATYPES: ${JSON.stringify(datatypes, null, "\t")},
302
+ };
303
+ `;
304
+ }
305
+
306
+ function generateUmbrella(): string {
307
+ return `#pragma once
308
+ // Cluaupp — Roblox API stubs for CL++ IntelliSense (generated projection).
309
+ // Source of truth: RobloxTargetProfile registry — not this header.
310
+
311
+ #include <clpp/generated/enums.clh>
312
+ #include <clpp/datatypes.clh>
313
+ #include <clpp/generated/instances.clh>
314
+ #include <clpp/libs.clh>
315
+
316
+ template <typename T>
317
+ T GetService();
318
+
319
+ template <typename T>
320
+ T GetService(Instance game_);
321
+
322
+ extern DataModel game;
323
+ extern Workspace workspace;
324
+ extern LuaSourceContainer script;
325
+
326
+ void post(string message);
327
+ void warn(string message);
328
+ void report(string message);
329
+ string to_string(auto value);
330
+ double to_number(auto value);
331
+ bool to_bool(auto value);
332
+
333
+ double tick();
334
+ double time();
335
+ double wait();
336
+ double wait(double seconds);
337
+ void delay(double seconds, func callback);
338
+
339
+ namespace task {
340
+ double wait();
341
+ double wait(double seconds);
342
+ void delay(double seconds, func callback);
343
+ void defer(func callback);
344
+ void synchronize();
345
+ void desynchronize();
346
+ void spawn(func callback);
347
+ }
348
+ `;
349
+ }
350
+
351
+ export interface GenerateHeadersResult {
352
+ files: string[];
353
+ }
354
+
355
+ export function generateClppHeaders(
356
+ profile: RobloxTargetProfile,
357
+ includeRoot = path.join(projectRoot, "include", "clpp"),
358
+ ): GenerateHeadersResult {
359
+ const files: string[] = [];
360
+ const enumsPath = path.join(includeRoot, "generated", "enums.clh");
361
+ const dtPath = path.join(includeRoot, "datatypes.clh");
362
+ const instPath = path.join(includeRoot, "generated", "instances.clh");
363
+ const umbrellaPath = path.join(includeRoot, "roblox.clh");
364
+ const apiJs = path.join(projectRoot, "src", "api.generated.js");
365
+
366
+ atomicWrite(enumsPath, generateEnums(profile.enums));
367
+ files.push(enumsPath);
368
+ atomicWrite(dtPath, generateDatatypes(profile));
369
+ files.push(dtPath);
370
+ atomicWrite(instPath, generateInstances(profile));
371
+ files.push(instPath);
372
+ atomicWrite(umbrellaPath, generateUmbrella());
373
+ files.push(umbrellaPath);
374
+ atomicWrite(apiJs, generateApiJs(profile));
375
+ files.push(apiJs);
376
+ return { files };
377
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Non-product: does not mirror Creator Docs.
3
+ * Official docs stay at https://create.roblox.com/docs
4
+ * Prefer `cluaupp api search|inspect` and the LSP index for tooling.
5
+ */
6
+ import type { RobloxTargetProfile } from "../model.js";
7
+
8
+ export function generateReferenceDocs(_profile: RobloxTargetProfile, _outDir?: string): string[] {
9
+ // Intentionally a no-op — reuse-first: do not generate class/enum markdown mirrors.
10
+ return [];
11
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Stable LSP metadata index for the CL++ Language Server.
3
+ * Cluaupp writes JSON; CLPP reads it. No LSP protocol here.
4
+ */
5
+ import fs from "node:fs";
6
+ import path from "node:path";
7
+ import { projectRoot } from "../../package-info.js";
8
+ import { pkg } from "../../package-info.js";
9
+ import type { RobloxTargetProfile } from "../model.js";
10
+ import { ROBLOX_TARGET_SCHEMA_VERSION } from "../model.js";
11
+ import { typeToClpp } from "../resolver.js";
12
+ import { buildRegistry, flattenMembers } from "../registry.js";
13
+
14
+ export const LSP_INDEX_SCHEMA_VERSION = 1 as const;
15
+
16
+ export interface LspMemberIndex {
17
+ kind: "property" | "method" | "event" | "callback";
18
+ name: string;
19
+ detail?: string;
20
+ threadSafety?: string;
21
+ }
22
+
23
+ export interface LspClassIndex {
24
+ name: string;
25
+ superclass: string | null;
26
+ service: boolean;
27
+ creatable: boolean;
28
+ members: LspMemberIndex[];
29
+ }
30
+
31
+ export interface LspIndexDocument {
32
+ schemaVersion: typeof LSP_INDEX_SCHEMA_VERSION;
33
+ targetSchemaVersion: typeof ROBLOX_TARGET_SCHEMA_VERSION;
34
+ generatorVersion: string;
35
+ classes: Record<string, LspClassIndex>;
36
+ services: string[];
37
+ enums: string[];
38
+ datatypes: string[];
39
+ globals: string[];
40
+ }
41
+
42
+ export function buildLspIndex(profile: RobloxTargetProfile): LspIndexDocument {
43
+ const registry = buildRegistry(profile);
44
+ const classes: Record<string, LspClassIndex> = {};
45
+ for (const name of Object.keys(profile.classes).sort()) {
46
+ const cls = profile.classes[name];
47
+ const flat = flattenMembers(registry, name);
48
+ const members: LspMemberIndex[] = [];
49
+ for (const prop of flat.properties) {
50
+ members.push({
51
+ kind: "property",
52
+ name: prop.name,
53
+ detail: typeToClpp(prop.valueType),
54
+ threadSafety: prop.threadSafety,
55
+ });
56
+ }
57
+ for (const method of flat.methods) {
58
+ members.push({
59
+ kind: "method",
60
+ name: method.name,
61
+ detail: `(${method.parameters.map((p) => typeToClpp(p.type)).join(", ")})`,
62
+ threadSafety: method.threadSafety,
63
+ });
64
+ }
65
+ for (const event of flat.events) {
66
+ members.push({
67
+ kind: "event",
68
+ name: event.name,
69
+ detail: event.parameters.map((p) => typeToClpp(p.type)).join(", "),
70
+ threadSafety: event.threadSafety,
71
+ });
72
+ }
73
+ for (const cb of cls.callbacks) {
74
+ members.push({ kind: "callback", name: cb.name, threadSafety: cb.threadSafety });
75
+ }
76
+ classes[name] = {
77
+ name,
78
+ superclass: cls.superclass,
79
+ service: cls.service || cls.creation.service,
80
+ creatable: cls.creatable || cls.creation.creatable,
81
+ members,
82
+ };
83
+ }
84
+ return {
85
+ schemaVersion: LSP_INDEX_SCHEMA_VERSION,
86
+ targetSchemaVersion: ROBLOX_TARGET_SCHEMA_VERSION,
87
+ generatorVersion: pkg.version,
88
+ classes,
89
+ services: Object.keys(profile.services).sort(),
90
+ enums: Object.keys(profile.enums).sort(),
91
+ datatypes: Object.keys(profile.datatypes).sort(),
92
+ globals: Object.keys(profile.globals).sort(),
93
+ };
94
+ }
95
+
96
+ export function writeLspIndex(
97
+ profile: RobloxTargetProfile,
98
+ outPath = path.join(projectRoot, "api", "generated", "lsp-index.json"),
99
+ ): string {
100
+ const doc = buildLspIndex(profile);
101
+ fs.mkdirSync(path.dirname(outPath), { recursive: true });
102
+ const tmp = `${outPath}.${process.pid}.tmp`;
103
+ fs.writeFileSync(tmp, `${JSON.stringify(doc)}\n`, "utf8");
104
+ fs.renameSync(tmp, outPath);
105
+ return outPath;
106
+ }
@@ -0,0 +1,98 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { projectRoot } from "../../package-info.js";
4
+ import type { RobloxTargetProfile } from "../model.js";
5
+ import { typeToLuau } from "../resolver.js";
6
+ import { escapeIdent } from "../identifier.js";
7
+
8
+ function atomicWrite(file: string, contents: string): void {
9
+ fs.mkdirSync(path.dirname(file), { recursive: true });
10
+ const tmp = `${file}.${process.pid}.tmp`;
11
+ fs.writeFileSync(tmp, contents, "utf8");
12
+ fs.renameSync(tmp, file);
13
+ }
14
+
15
+ export function generateLuauDefs(
16
+ profile: RobloxTargetProfile,
17
+ outDir = path.join(projectRoot, "api", "generated", "luau"),
18
+ ): string[] {
19
+ const files: string[] = [];
20
+ fs.mkdirSync(outDir, { recursive: true });
21
+
22
+ let enums = `--!strict\n-- Generated Enums from RobloxTargetProfile\n`;
23
+ for (const name of Object.keys(profile.enums).sort()) {
24
+ const en = profile.enums[name];
25
+ enums += `export type Enum${escapeIdent(en.name)} = {\n`;
26
+ for (const item of en.items) {
27
+ enums += `\t${escapeIdent(item.name)}: EnumItem,\n`;
28
+ }
29
+ enums += `}\n`;
30
+ }
31
+ const enumsPath = path.join(outDir, "enums.d.luau");
32
+ atomicWrite(enumsPath, enums);
33
+ files.push(enumsPath);
34
+
35
+ let datatypes = `--!strict\n-- Generated Datatypes\n`;
36
+ for (const name of Object.keys(profile.datatypes).sort()) {
37
+ const dt = profile.datatypes[name];
38
+ datatypes += `declare class ${escapeIdent(dt.name)}\n`;
39
+ for (const field of dt.fields) {
40
+ datatypes += `\t${escapeIdent(field.name)}: ${typeToLuau(field.type)}\n`;
41
+ }
42
+ for (const m of dt.instanceMethods) {
43
+ const params = m.parameters.map((p) => `${escapeIdent(p.name)}: ${typeToLuau(p.type)}`).join(", ");
44
+ const ret = typeToLuau(m.returnTypes[0] || { kind: "Any" });
45
+ datatypes += `\tfunction ${escapeIdent(m.name)}(self${params ? `, ${params}` : ""}): ${ret}\n`;
46
+ }
47
+ datatypes += `end\n\n`;
48
+ }
49
+ const dtPath = path.join(outDir, "datatypes.d.luau");
50
+ atomicWrite(dtPath, datatypes);
51
+ files.push(dtPath);
52
+
53
+ let classes = `--!strict\n-- Generated Classes (direct members only; see flatten view in CL++ headers)\n`;
54
+ for (const name of Object.keys(profile.classes).sort()) {
55
+ const cls = profile.classes[name];
56
+ const extendsClause = cls.superclass ? ` extends ${escapeIdent(cls.superclass)}` : "";
57
+ classes += `declare class ${escapeIdent(cls.name)}${extendsClause}\n`;
58
+ for (const prop of cls.properties) {
59
+ classes += `\t${escapeIdent(prop.name)}: ${typeToLuau(prop.valueType)}\n`;
60
+ }
61
+ for (const method of cls.methods) {
62
+ const params = method.parameters.map((p) => `${escapeIdent(p.name)}: ${typeToLuau(p.type)}`).join(", ");
63
+ const ret = typeToLuau(method.returnTypes[0] || { kind: "Any" });
64
+ classes += `\tfunction ${escapeIdent(method.name)}(self${params ? `, ${params}` : ""}): ${ret}\n`;
65
+ }
66
+ for (const event of cls.events) {
67
+ classes += `\t${escapeIdent(event.name)}: RBXScriptSignal\n`;
68
+ }
69
+ classes += `end\n\n`;
70
+ }
71
+ const classesPath = path.join(outDir, "classes.d.luau");
72
+ atomicWrite(classesPath, classes);
73
+ files.push(classesPath);
74
+
75
+ let globals = `--!strict\n-- Generated Globals\n`;
76
+ for (const name of Object.keys(profile.globals).sort()) {
77
+ const g = profile.globals[name];
78
+ globals += `declare ${escapeIdent(g.name)}: ${typeToLuau(g.type)}\n`;
79
+ }
80
+ const globalsPath = path.join(outDir, "globals.d.luau");
81
+ atomicWrite(globalsPath, globals);
82
+ files.push(globalsPath);
83
+
84
+ return files;
85
+ }
86
+
87
+ export function tryLuauAnalyze(filePath: string): { ok: boolean; output: string } {
88
+ try {
89
+ const { spawnSync } = require("node:child_process") as typeof import("node:child_process");
90
+ const result = spawnSync("luau-analyze", [filePath], { encoding: "utf8" });
91
+ if (result.error) {
92
+ return { ok: true, output: "luau-analyze not available; skipped" };
93
+ }
94
+ return { ok: result.status === 0, output: (result.stdout || "") + (result.stderr || "") };
95
+ } catch {
96
+ return { ok: true, output: "luau-analyze not available; skipped" };
97
+ }
98
+ }
package/src/api/ide.ts ADDED
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Registry query helpers for the CL++ Language Server / tooling contract.
3
+ *
4
+ * NOT a Cluaupp IntelliSense product. Autocomplete, hover UI, go-to-def, and LSP
5
+ * protocol live in CLPP (`clpp` Language Server). Cluaupp only supplies data.
6
+ */
7
+ import type { ApiRegistry } from "../api/registry.js";
8
+ import { buildRegistry, flattenMembers, searchRegistry } from "../api/registry.js";
9
+ import { buildRobloxTargetProfile } from "../api/build-profile.js";
10
+ import { typeToClpp } from "../api/resolver.js";
11
+
12
+ let cached: ApiRegistry | null = null;
13
+
14
+ export function getApiRegistry(force = false): ApiRegistry {
15
+ if (!cached || force) {
16
+ cached = buildRegistry(buildRobloxTargetProfile({ skipValidate: true }));
17
+ }
18
+ return cached;
19
+ }
20
+
21
+ /** Member listing for CLPP LSP / tests — not an IDE completion engine. */
22
+ export function listMembers(
23
+ className: string,
24
+ prefix = "",
25
+ ): Array<{ label: string; kind: string; detail?: string }> {
26
+ const registry = getApiRegistry();
27
+ const flat = flattenMembers(registry, className);
28
+ const p = prefix.toLowerCase();
29
+ const out: Array<{ label: string; kind: string; detail?: string }> = [];
30
+ for (const prop of flat.properties) {
31
+ if (!p || prop.name.toLowerCase().startsWith(p)) {
32
+ out.push({ label: prop.name, kind: "property", detail: typeToClpp(prop.valueType) });
33
+ }
34
+ }
35
+ for (const method of flat.methods) {
36
+ if (!p || method.name.toLowerCase().startsWith(p)) {
37
+ out.push({
38
+ label: method.name,
39
+ kind: "method",
40
+ detail: `(${method.parameters.map((x) => typeToClpp(x.type)).join(", ")})`,
41
+ });
42
+ }
43
+ }
44
+ for (const event of flat.events) {
45
+ if (!p || event.name.toLowerCase().startsWith(p)) {
46
+ out.push({
47
+ label: event.name,
48
+ kind: "event",
49
+ detail: event.parameters.map((x) => typeToClpp(x.type)).join(", "),
50
+ });
51
+ }
52
+ }
53
+ return out;
54
+ }
55
+
56
+ /** @deprecated Use listMembers — name kept for callers during demotion. */
57
+ export const completeMember = listMembers;
58
+
59
+ export function describeSymbol(symbol: string): string | null {
60
+ const registry = getApiRegistry();
61
+ if (registry.classes.has(symbol)) {
62
+ const cls = registry.classes.get(symbol)!;
63
+ return `class ${cls.name}${cls.superclass ? ` : ${cls.superclass}` : ""}`;
64
+ }
65
+ if (registry.enums.has(symbol)) {
66
+ return `enum ${symbol} (${registry.enums.get(symbol)!.items.length} items)`;
67
+ }
68
+ if (registry.datatypes.has(symbol)) {
69
+ return `datatype ${symbol}`;
70
+ }
71
+ const member = registry.members.get(symbol);
72
+ if (member) {
73
+ return `${member.kind} ${symbol}`;
74
+ }
75
+ return null;
76
+ }
77
+
78
+ /** @deprecated Use describeSymbol. */
79
+ export const hoverSymbol = describeSymbol;
80
+
81
+ export function similarSymbols(symbol: string, limit = 5): string[] {
82
+ const registry = getApiRegistry();
83
+ return searchRegistry(registry, symbol.slice(0, Math.max(2, symbol.length - 1)), limit).map((h) => h.symbol);
84
+ }
85
+
86
+ /** @deprecated Use similarSymbols. */
87
+ export const suggestDidYouMean = similarSymbols;