luaut-language-server 3.1.0 → 4.0.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.
@@ -1,5 +1,5 @@
1
1
  // src/features/members.ts
2
- import { formatType } from "luaut-parser";
2
+ import { formatType, substitute, union } from "luaut-parser";
3
3
  function literalKeys(key, aliases) {
4
4
  if (!key) return [];
5
5
  const resolved = key.kind === "genericRef" ? aliases.get(key.name) : key;
@@ -48,6 +48,20 @@ function membersOf(type, aliases, seen = /* @__PURE__ */ new Set()) {
48
48
  }
49
49
  case "typeParam":
50
50
  return membersOf(type.constraint, aliases, seen);
51
+ // An array and a string answer to the methods the language gives them
52
+ // — `names:filter(f)`, `text:trim()`. They are written in the parser's
53
+ // prelude as `ArrayMethods<T>` and `StringMethods`, so the element
54
+ // type goes in where `T` stands.
55
+ case "array":
56
+ case "tuple": {
57
+ const element = type.kind === "array" ? type.element : union(type.elements);
58
+ const methods = aliases.get("ArrayMethods");
59
+ return methods ? membersOf(substitute(methods, /* @__PURE__ */ new Map([["T", element]])), aliases, seen) : [];
60
+ }
61
+ case "primitive":
62
+ return type.name === "string" ? membersOf(aliases.get("StringMethods"), aliases, seen) : [];
63
+ case "literal":
64
+ return type.base === "string" ? membersOf(aliases.get("StringMethods"), aliases, seen) : [];
51
65
  default:
52
66
  return [];
53
67
  }
@@ -1495,12 +1509,7 @@ function memberItems(analysis, access) {
1495
1509
  const object = access.object;
1496
1510
  const type = withoutNil(analysis.types.typeOf.get(object));
1497
1511
  const colon = access.type === "MethodCallExpression";
1498
- if (isStringLike(type)) {
1499
- if (!colon) return [];
1500
- const id = analysis.scopes.globalsByName.get("string");
1501
- const library = id === void 0 ? void 0 : analysis.types.bindingType.get(id);
1502
- return membersOf(library, analysis.types.aliases).filter((member) => signaturesOf(member.property.type).length > 0).map((member) => memberItem(member.name, member.property.type, member.property.readonly));
1503
- }
1512
+ if (isMethodOnly(type) && !colon) return [];
1504
1513
  return membersOf(type, analysis.types.aliases).filter((member) => colon ? member.isMethod : true).map((member) => memberItem(member.name, member.property.type, member.property.readonly));
1505
1514
  }
1506
1515
  function withoutNil(type) {
@@ -1508,17 +1517,19 @@ function withoutNil(type) {
1508
1517
  const kept = type.types.filter((t) => !(t.kind === "primitive" && t.name === "nil"));
1509
1518
  return kept.length === 1 ? kept[0] : { ...type, types: kept };
1510
1519
  }
1511
- function isStringLike(type) {
1520
+ function isMethodOnly(type) {
1512
1521
  if (!type) return false;
1513
1522
  switch (type.kind) {
1523
+ case "array":
1524
+ case "tuple":
1525
+ case "templateLiteral":
1526
+ return true;
1514
1527
  case "primitive":
1515
1528
  return type.name === "string";
1516
1529
  case "literal":
1517
1530
  return typeof type.value === "string";
1518
- case "templateLiteral":
1519
- return true;
1520
1531
  case "union":
1521
- return type.types.length > 0 && type.types.every(isStringLike);
1532
+ return type.types.length > 0 && type.types.every(isMethodOnly);
1522
1533
  default:
1523
1534
  return false;
1524
1535
  }
@@ -2094,7 +2105,7 @@ function createServer(connection, options = {}) {
2094
2105
  severity: DiagnosticSeverity2.Information,
2095
2106
  source: "luaut",
2096
2107
  code: "no-config",
2097
- message: 'No luaut.config.json applies to this file, so no types are loaded \u2014 not even `print`. Add one to this folder or a folder above, such as { "types": ["luau"], "paths": {}, "sourceMap": null }'
2108
+ message: 'No luaut.config.json applies to this file, so no types are loaded \u2014 not even `print`. Add one to this folder or a folder above: { "types": [], "paths": {}, "sourceMap": null }, listing in `types` the type libraries the project has installed.'
2098
2109
  }];
2099
2110
  };
2100
2111
  documents.onDidOpen(publishAll);
@@ -2202,4 +2213,4 @@ export {
2202
2213
  createServer,
2203
2214
  startServer
2204
2215
  };
2205
- //# sourceMappingURL=chunk-SCZTSX3Y.js.map
2216
+ //# sourceMappingURL=chunk-XK3KS3T4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/features/members.ts","../src/analysis.ts","../src/ast-utils.ts","../src/features/imports.ts","../src/features/diagnostics.ts","../src/features/hover.ts","../src/features/navigation.ts","../src/features/completion.ts","../src/features/autoImport.ts","../src/features/signatureHelp.ts","../src/features/symbols.ts","../src/features/semanticTokens.ts","../src/server.ts"],"sourcesContent":["/** What members a type has — shared by completion and signature help. */\nimport { formatType, substitute, union, type FunctionType, type ObjectProperty, type Type } from \"luaut-parser\"\n\nexport interface Member {\n name: string\n property: ObjectProperty\n /** True when the member is a function whose first parameter is `self` —\n * i.e. it is meant to be called with `:`. */\n isMethod: boolean\n}\n\n/** The keys an index signature spells out one by one, if it does. */\nfunction literalKeys(key: Type | undefined, aliases: ReadonlyMap<string, Type>): string[] {\n if (!key) return []\n const resolved = key.kind === \"genericRef\" ? aliases.get(key.name) : key\n if (!resolved) return []\n const parts = resolved.kind === \"union\" ? resolved.types : [resolved]\n const out: string[] = []\n for (const part of parts) {\n const member = part.kind === \"genericRef\" ? aliases.get(part.name) ?? part : part\n if (member.kind !== \"literal\" || typeof member.value !== \"string\") return []\n out.push(member.value)\n }\n return out\n}\n\n/** The members of `type`, following aliases, merging intersections and keeping\n * only what every member of a union has (you can only reach a property that\n * is there whichever way the union went). */\nexport function membersOf(\n type: Type | undefined,\n aliases: ReadonlyMap<string, Type>,\n seen = new Set<Type>(),\n): Member[] {\n if (!type || seen.has(type)) return []\n seen.add(type)\n\n switch (type.kind) {\n case \"object\": {\n const out: Member[] = []\n for (const [name, property] of type.properties) {\n out.push({ name, property, isMethod: takesSelf(property.type) })\n }\n // `{ [(\"a\" | \"b\")]: V }` covers a countable set of keys, so those\n // keys are members too — optional, since an index signature does\n // not promise any of them is there. `[string]` names none.\n for (const name of literalKeys(type.indexer?.key, aliases)) {\n if (type.properties.has(name)) continue\n const property = { type: type.indexer!.value, optional: true }\n out.push({ name, property, isMethod: takesSelf(property.type) })\n }\n return out\n }\n case \"intersection\": {\n // Overload sets are intersections of functions and have no\n // members of their own; a `A & B` object contributes both sides.\n const merged = new Map<string, Member>()\n for (const part of type.types) {\n for (const member of membersOf(part, aliases, seen)) merged.set(member.name, member)\n }\n return [...merged.values()]\n }\n case \"union\": {\n const perBranch = type.types.map(part => membersOf(part, aliases, seen))\n if (!perBranch.length) return []\n const [first, ...rest] = perBranch\n return first.filter(member => rest.every(other => other.some(m => m.name === member.name)))\n }\n case \"genericRef\": {\n const alias = aliases.get(type.name)\n return alias ? membersOf(alias, aliases, seen) : []\n }\n case \"typeParam\":\n return membersOf(type.constraint, aliases, seen)\n // An array and a string answer to the methods the language gives them\n // — `names:filter(f)`, `text:trim()`. They are written in the parser's\n // prelude as `ArrayMethods<T>` and `StringMethods`, so the element\n // type goes in where `T` stands.\n case \"array\":\n case \"tuple\": {\n const element = type.kind === \"array\" ? type.element : union(type.elements)\n const methods = aliases.get(\"ArrayMethods\")\n return methods\n ? membersOf(substitute(methods, new Map([[\"T\", element]])), aliases, seen)\n : []\n }\n case \"primitive\":\n return type.name === \"string\" ? membersOf(aliases.get(\"StringMethods\"), aliases, seen) : []\n case \"literal\":\n return type.base === \"string\" ? membersOf(aliases.get(\"StringMethods\"), aliases, seen) : []\n default:\n return []\n }\n}\n\nexport function takesSelf(type: Type): boolean {\n for (const signature of signaturesOf(type)) {\n if (signature.params[0]?.name === \"self\") return true\n }\n return false\n}\n\n/** Every call signature of `type` — one for a function, several for an\n * overload set (which is an intersection of function types). */\nexport function signaturesOf(type: Type | undefined, aliases?: ReadonlyMap<string, Type>): FunctionType[] {\n if (!type) return []\n if (type.kind === \"function\") return [type]\n if (type.kind === \"intersection\") return type.types.flatMap(t => signaturesOf(t, aliases))\n if (type.kind === \"genericRef\" && aliases) {\n const alias = aliases.get(type.name)\n return alias ? signaturesOf(alias, aliases) : []\n }\n return []\n}\n\n/** `(a: number, b?: string) -> boolean`, and the pieces of it, for signature\n * help — which needs each parameter's own label to highlight the active one. */\nexport function signatureLabel(signature: FunctionType): { label: string; parameters: string[] } {\n const parameters = signature.params.map((p, i) => {\n const name = p.name ?? `arg${i + 1}`\n return `${name}${p.optional ? \"?\" : \"\"}: ${formatType(p.type)}`\n })\n const generics = signature.typeParams?.length ? `<${signature.typeParams.join(\", \")}>` : \"\"\n const varargs = signature.varargs ? [`...: ${formatType(signature.varargs)}`] : []\n const label = `${generics}(${[...parameters, ...varargs].join(\", \")}) -> ${formatType(signature.returns)}`\n return { label, parameters }\n}\n","/**\n * Analysis cache, projects, and the module graph behind `import`.\n *\n * The three parser passes are cheap (single-digit milliseconds for a normal\n * file) but not free, and every LSP request wants the same result for the same\n * document version — so each document is analyzed once per version and the\n * result is reused by hover, definition, completion and the rest.\n *\n * Nothing is built in. A file belongs to the project of the nearest\n * `luaut.config.json`: the type libraries it names, its `paths` aliases, and\n * its sourcemap's instance tree. A file no config covers gets no types at all.\n *\n * An import is resolved to a file, that file is analyzed the same way, and its\n * exports become the importing file's types. Open documents are read in\n * preference to disk, so an import sees unsaved edits. A cached result is only\n * reused while every file it read — the modules it imports, its config, type\n * libraries and sourcemap — still has the text it was analyzed against.\n */\nimport { readFileSync, statSync } from \"node:fs\"\nimport { dirname, resolve } from \"node:path\"\nimport { fileURLToPath, pathToFileURL } from \"node:url\"\nimport {\n parse, parseWithRecovery, analyzeScopes, analyzeTypes, moduleExports, getBinding,\n findConfig, resolveTypeLibraries, moduleCandidates, sourceMapTypes,\n type Program, type ScopeAnalysis, type TypeAnalysis, type ParseError, type ModuleExports,\n type Binding, type Identifier, type Type, type LuautConfig, type ConfigProblem, type ProjectHost,\n type SourceMapTypes, type Directives,\n} from \"luaut-parser\"\nimport type { TextDocument } from \"vscode-languageserver-textdocument\"\nimport { membersOf } from \"./features/members.js\"\n\nexport interface Analysis {\n readonly uri: string\n readonly version: number\n readonly source: string\n readonly program: Program\n readonly parseErrors: readonly ParseError[]\n /** `--@luaut-nocheck` / `--@luaut-ignore` / `--@luaut-expect-error`. */\n readonly directives: Directives\n readonly scopes: ScopeAnalysis\n readonly types: TypeAnalysis\n /** Every file this analysis read — imported modules, its config, type\n * libraries, sourcemap — with the text it read, or `undefined` for a file\n * it looked for and did not find. How a cached result tells that something\n * changed, appeared or vanished under it. */\n readonly dependencies: ReadonlyMap<string, string | undefined>\n /** The project the file belongs to. */\n readonly project: Project\n}\n\nexport interface Project {\n /** The config that applies to the file, or `undefined` when none does. */\n readonly config?: LuautConfig\n /** The types came from `AnalyzerOptions.libs`, not from a config. */\n readonly fixed: boolean\n /** What is wrong with the config, a type library it names, or its sourcemap. */\n readonly problems: readonly ConfigProblem[]\n}\n\nexport interface AnalyzerOptions {\n /** Analyze every file against these definitions instead of the ones its\n * `luaut.config.json` names — for tests and for embedding the server. */\n libs?: readonly Program[]\n /** The open document for a file path, if there is one. */\n openDocument?: (path: string) => TextDocument | undefined\n}\n\n/** Names a file may use undeclared: whatever the definitions declare. */\nfunction globalsOf(libs: readonly Program[]): string[] {\n const names = new Set<string>()\n for (const lib of libs) {\n for (const statement of lib.body.statements) {\n if (statement.type === \"DeclareStatement\") names.add(statement.name)\n }\n }\n return [...names]\n}\n\n/** The binding a node names, whether it *uses* the binding or *declares* it.\n *\n * Scope analysis indexes the two differently: every use is in `bindingOf`,\n * but a declaration only appears as its binding's `declarationNode`. Asking\n * `bindingOf` alone is why hovering `const x` — as opposed to a later `x` —\n * used to show nothing. */\nexport function bindingOfNode(analysis: Analysis, node: object): Binding | undefined {\n const used = getBinding(analysis.scopes, node as Identifier)\n if (used) return used\n return declarationIndex(analysis).get(node)\n}\n\nconst declarationIndexes = new WeakMap<Analysis, Map<object, Binding>>()\n\nfunction declarationIndex(analysis: Analysis): Map<object, Binding> {\n let index = declarationIndexes.get(analysis)\n if (!index) {\n index = new Map()\n for (const binding of analysis.scopes.bindings.values()) {\n if (binding.declarationNode) index.set(binding.declarationNode, binding)\n }\n declarationIndexes.set(analysis, index)\n }\n return index\n}\n\n// --------------------------------------------------------------------------\n// Paths\n// --------------------------------------------------------------------------\n\n/** A file URI's path, or `undefined` for anything that is not a file. */\nexport function pathOfUri(uri: string): string | undefined {\n if (!uri.startsWith(\"file:\")) return undefined\n try {\n return fileURLToPath(uri)\n } catch {\n return undefined\n }\n}\n\nexport function uriOfPath(path: string): string {\n return pathToFileURL(path).href\n}\n\n/** Paths compare case-insensitively on Windows, where editors and the file\n * system disagree about drive-letter case. */\nexport function samePath(a: string, b: string): boolean {\n return pathKey(a) === pathKey(b)\n}\n\nfunction pathKey(path: string): string {\n const normalized = resolve(path)\n return process.platform === \"win32\" ? normalized.toLowerCase() : normalized\n}\n\n/** What an import of a module still being analyzed up the chain sees, when\n * there is nothing better yet: its names read as `any`. */\nconst CYCLE: ModuleExports = { values: new Map(), types: new Map(), partial: true }\n\n/**\n * One analysis of a module and everything it imports.\n *\n * An import cycle can only be broken by letting one side see the other before\n * it is finished — as `any`. A value exported from the far side and inferred\n * from the near side then comes back as `any` too. So a run that met a cycle\n * goes once more: the modules it analyzed are redone, and where an import\n * meets a module mid-analysis it reads that module's exports from the first\n * pass instead of `any`.\n */\ninterface Run {\n /** Modules an import reached while they were still being analyzed. */\n readonly cycles: Set<string>\n /** Modules analyzed in this run — the ones a second pass redoes. */\n readonly analyzed: Set<string>\n /** Exports from the first pass, read in place of `any` in the second. */\n readonly provisional: Map<string, ModuleExports>\n}\n\n// --------------------------------------------------------------------------\n// Analyzer\n// --------------------------------------------------------------------------\n\ninterface Module {\n analysis: Analysis\n exports: ModuleExports\n}\n\n/** Everything a folder's files are analyzed with. */\ninterface Context {\n readonly project: Project\n /** The type libraries, then the sourcemap's tree. */\n readonly libs: readonly Program[]\n readonly globals: readonly string[]\n readonly sourceMap?: SourceMapTypes\n /** Every file read to build this, with what it held. */\n readonly reads: ReadonlyMap<string, string | undefined>\n}\n\nconst NO_PROJECT: Context = { project: { fixed: false, problems: [] }, libs: [], globals: [], reads: new Map() }\n\nexport class Analyzer {\n private readonly fixed?: Context\n private readonly openDocument?: (path: string) => TextDocument | undefined\n private readonly cache = new Map<string, Analysis>()\n /** Imported modules, by path key. */\n private readonly modules = new Map<string, Module>()\n /** Project contexts, by folder. */\n private readonly contexts = new Map<string, Context>()\n /** Parsed type libraries, by path — reparsed only when the text changes. */\n private readonly libraries = new Map<string, { source: string; program?: Program; problem?: ConfigProblem }>()\n /** Sourcemaps turned into types, by path, with what they were built from. */\n private readonly sourceMaps = new Map<string, { text: string; libraries: string; result: ReturnType<typeof sourceMapTypes> }>()\n /** The analysis run in progress, if any. */\n private run: Run | undefined\n\n constructor(options: AnalyzerOptions = {}) {\n this.openDocument = options.openDocument\n if (options.libs) {\n this.fixed = {\n project: { fixed: true, problems: [] },\n libs: options.libs,\n globals: globalsOf(options.libs),\n reads: new Map(),\n }\n }\n }\n\n /** Analyze `document`, reusing the previous result while neither it nor\n * anything it read has changed. */\n get(document: TextDocument): Analysis {\n const cached = this.cache.get(document.uri)\n const source = document.getText()\n if (cached && cached.version === document.version && cached.source === source && this.isFresh(cached)) {\n return cached\n }\n const analysis = this.analyze(document.uri, document.version, source)\n this.cache.set(document.uri, analysis)\n return analysis\n }\n\n /** Analyze source text that is not a tracked document — used by\n * completion, which analyzes a speculatively edited copy of the file. */\n analyze(uri: string, version: number, source: string): Analysis {\n const path = pathOfUri(uri)\n if (!path) return this.analyzeModule(uri, version, source, new Set())\n const key = pathKey(path)\n return this.resolvingCycles(key, () => {\n const analysis = this.analyzeModule(uri, version, source, new Set([key]))\n return { result: analysis, exports: () => this.exportsFrom(analysis, new Set([key])) }\n })\n }\n\n forget(uri: string): void {\n this.cache.delete(uri)\n }\n\n /** The project a file belongs to. */\n projectOf(uri: string): Project {\n return this.contextFor(pathOfUri(uri)).project\n }\n\n /** The file an import in `fromUri` names: a relative path, or a `paths`\n * alias from the file's config. */\n resolveModulePath(fromUri: string, specifier: string): string | undefined {\n const from = pathOfUri(fromUri)\n if (!from) return undefined\n return this.candidatesFor(from, specifier).find(candidate => this.readFile(candidate) !== undefined)\n }\n\n /** What the module at `path` exports, analyzing it if need be. */\n exportsAt(path: string): ModuleExports | undefined {\n return this.resolvingCycles(pathKey(path), () => {\n const exports = this.exportsOf(path, new Set())\n return { result: exports, exports: () => exports }\n })\n }\n\n /** The analysis of the module at `path`, analyzing it if need be. */\n moduleAt(path: string): Analysis | undefined {\n this.exportsAt(path)\n return this.modules.get(pathKey(path))?.analysis\n }\n\n /** A file's text: the open document if there is one, else the disk. */\n readFile(path: string): string | undefined {\n const open = this.openDocument?.(path)\n if (open) return open.getText()\n try {\n return statSync(path).isFile() ? readFileSync(path, \"utf8\") : undefined\n } catch {\n return undefined\n }\n }\n\n private candidatesFor(from: string, specifier: string): string[] {\n return moduleCandidates(from, specifier, this.contextFor(from).project.config)\n }\n\n // ---------------------------------------------------------------- projects\n\n private contextFor(path: string | undefined): Context {\n if (this.fixed) return this.fixed\n if (!path) return NO_PROJECT\n const key = pathKey(dirname(path))\n const cached = this.contexts.get(key)\n if (cached && this.unchanged(cached.reads)) return cached\n const context = this.buildContext(path)\n this.contexts.set(key, context)\n return context\n }\n\n private buildContext(path: string): Context {\n const reads = new Map<string, string | undefined>()\n const host: ProjectHost = {\n readFile: file => {\n const text = this.readFile(file)\n reads.set(file, text)\n return text\n },\n }\n\n const lookup = findConfig(path, host)\n const problems: ConfigProblem[] = [...lookup.problems]\n const config = lookup.config\n if (!config) return { project: { fixed: false, problems }, libs: [], globals: [], reads }\n\n const libraries = resolveTypeLibraries(config, host)\n problems.push(...libraries.problems)\n const libs: Program[] = []\n for (const file of libraries.files) {\n const program = this.library(file, host, problems)\n if (program) libs.push(program)\n }\n\n let sourceMap: SourceMapTypes | undefined\n if (config.sourceMap) {\n const text = host.readFile(config.sourceMap)\n if (text === undefined) {\n problems.push({\n file: config.path,\n message: `Cannot find the sourceMap file ${config.sourceMap}`,\n ...optionPosition(config, \"sourceMap\"),\n })\n } else {\n const result = this.sourceMap(config.sourceMap, text, libs, libraries.files)\n if (result.problem) problems.push({ file: config.sourceMap, message: result.problem, line: 1, column: 1 })\n sourceMap = result.types\n if (sourceMap) libs.push(sourceMap.program)\n }\n }\n\n return { project: { config, fixed: false, problems }, libs, globals: globalsOf(libs), sourceMap, reads }\n }\n\n /** A type library's definitions, parsed once per text. */\n private library(file: string, host: ProjectHost, problems: ConfigProblem[]): Program | undefined {\n const source = host.readFile(file)\n if (source === undefined) return undefined\n const key = pathKey(file)\n let entry = this.libraries.get(key)\n if (!entry || entry.source !== source) {\n try {\n entry = { source, program: parse(source) }\n } catch (error) {\n const { message, line, column } = error as { message: string; line?: number; column?: number }\n entry = {\n source,\n problem: { file, message: `Syntax error in type library: ${message.replace(/\\s*\\(\\d+:\\d+\\)$/, \"\")}`, line, column },\n }\n }\n this.libraries.set(key, entry)\n }\n if (entry.problem) problems.push(entry.problem)\n return entry.program\n }\n\n /** A sourcemap's types, rebuilt only when it or the libraries change. */\n private sourceMap(path: string, text: string, libs: readonly Program[], files: readonly string[]): ReturnType<typeof sourceMapTypes> {\n const key = pathKey(path)\n const libraries = files.join(\"\\n\")\n const cached = this.sourceMaps.get(key)\n if (cached && cached.text === text && cached.libraries === libraries) return cached.result\n\n const aliases = aliasesOf(libs)\n const members = new Map<string, ReadonlySet<string>>()\n const result = sourceMapTypes(text, path, {\n classes: new Set(aliases.keys()),\n membersOf: className => {\n let names = members.get(className)\n if (!names) {\n names = new Set(membersOf(aliases.get(className), aliases).map(member => member.name))\n members.set(className, names)\n }\n return names\n },\n })\n this.sourceMaps.set(key, { text, libraries, result })\n return result\n }\n\n private unchanged(reads: ReadonlyMap<string, string | undefined>): boolean {\n for (const [file, text] of reads) if (this.readFile(file) !== text) return false\n return true\n }\n\n // ----------------------------------------------------------------- modules\n\n /** Run one analysis of `root` and everything it imports; if that met an\n * import cycle, run it once more with the first pass's exports standing\n * in for the `any` the cycle left (see `Run`). A call made while a run is\n * already going is part of that run. */\n private resolvingCycles<T>(\n root: string,\n analyzeRoot: () => { result: T; exports: () => ModuleExports | undefined },\n ): T {\n if (this.run) return analyzeRoot().result\n const run: Run = { cycles: new Set(), analyzed: new Set(), provisional: new Map() }\n this.run = run\n try {\n const first = analyzeRoot()\n if (!run.cycles.size) return first.result\n\n for (const key of run.cycles) {\n const exports = key === root ? first.exports() : this.modules.get(key)?.exports\n if (exports && !exports.partial) run.provisional.set(key, exports)\n }\n // Anything the first pass analyzed may have read `any` through the\n // cycle, so all of it is redone.\n for (const key of run.analyzed) this.modules.delete(key)\n return analyzeRoot().result\n } finally {\n this.run = undefined\n }\n }\n\n /** A module's exports, from its analysis. */\n private exportsFrom(analysis: Analysis, importing: Set<string>): ModuleExports {\n // Re-exports (`export ... from`) resolve relative to this module.\n return moduleExports(analysis.program, analysis.scopes, analysis.types, specifier => {\n const next = this.resolveModulePath(analysis.uri, specifier)\n return next ? this.exportsOf(next, importing) : undefined\n })\n }\n\n /** `importing` holds every module on the current import chain, so an\n * import back into one of them is recognized as a cycle. */\n private analyzeModule(uri: string, version: number, source: string, importing: Set<string>): Analysis {\n const path = pathOfUri(uri)\n const context = this.contextFor(path)\n // A file the sourcemap maps has its own `script`.\n const script = path ? context.sourceMap?.scriptFor(path) : undefined\n const libs = script ? [...context.libs, script] : context.libs\n const globals = script ? [...context.globals, \"script\"] : context.globals\n\n const { program, errors, directives } = parseWithRecovery(source)\n // A name nothing declares is only an error against type libraries:\n // without one, `print` itself is undeclared.\n const reportUndeclared = context.libs.length > 0\n const scopes = analyzeScopes(program, { builtinGlobals: [...globals], reportUndeclared })\n const dependencies = new Map(context.reads)\n const types = analyzeTypes(program, scopes, {\n libs,\n reportUnknownTypes: reportUndeclared,\n resolveModule: specifier => {\n if (!path) return undefined\n const candidates = this.candidatesFor(path, specifier)\n const target = candidates.find(candidate => this.readFile(candidate) !== undefined)\n if (!target) {\n // Remember where it was looked for. Otherwise creating the\n // file later would leave this module's \"Cannot find module\"\n // — and its unresolved types — cached until its own text\n // changed.\n for (const candidate of candidates) dependencies.set(candidate, undefined)\n return undefined\n }\n const exports = this.exportsOf(target, importing)\n dependencies.set(target, this.readFile(target))\n return exports\n },\n })\n return { uri, version, source, program, parseErrors: errors, directives, scopes, types, dependencies, project: context.project }\n }\n\n private exportsOf(path: string, importing: Set<string>): ModuleExports | undefined {\n const key = pathKey(path)\n if (importing.has(key)) {\n this.run?.cycles.add(key)\n return this.run?.provisional.get(key) ?? CYCLE\n }\n const source = this.readFile(path)\n if (source === undefined) return undefined\n const cached = this.modules.get(key)\n if (cached && cached.analysis.source === source && this.isFresh(cached.analysis)) return cached.exports\n importing.add(key)\n try {\n const analysis = this.analyzeModule(uriOfPath(path), -1, source, importing)\n const exports = this.exportsFrom(analysis, importing)\n this.modules.set(key, { analysis, exports })\n this.run?.analyzed.add(key)\n return exports\n } finally {\n importing.delete(key)\n }\n }\n\n /** Does every file `analysis` read — and everything the modules it\n * imported read — still have the text it was analyzed against? */\n private isFresh(analysis: Analysis, seen = new Set<Analysis>()): boolean {\n if (seen.has(analysis)) return true\n seen.add(analysis)\n for (const [path, source] of analysis.dependencies) {\n if (this.readFile(path) !== source) return false\n const module = this.modules.get(pathKey(path))\n if (module && !this.isFresh(module.analysis, seen)) return false\n }\n return true\n }\n}\n\n/** The type aliases a set of libraries defines, resolved. */\nfunction aliasesOf(libs: readonly Program[]): ReadonlyMap<string, Type> {\n const empty = parse(\"\")\n return analyzeTypes(empty, analyzeScopes(empty, {}), { libs, diagnostics: false }).aliases\n}\n\n/** Where an option is written in a config, to point a problem at it. */\nexport function optionPosition(config: LuautConfig, key: string): { line?: number; column?: number } {\n const offset = config.source.indexOf(JSON.stringify(key))\n if (offset < 0) return { line: 1, column: 1 }\n const before = config.source.slice(0, offset)\n return { line: before.split(\"\\n\").length, column: offset - before.lastIndexOf(\"\\n\") }\n}\n","/**\n * Position mapping and AST lookup.\n *\n * luaut spans are 1-based with an exclusive end column; LSP positions are\n * 0-based. Every conversion between the two lives here so the features never\n * do the arithmetic themselves.\n */\nimport type { Position, Range } from \"vscode-languageserver\"\n\n/** The shape every luaut AST node shares. */\nexport interface Spanned {\n type?: string\n line: { start: number; end: number }\n column: { start: number; end: number }\n}\n\nexport function isSpanned(v: unknown): v is Spanned {\n if (!v || typeof v !== \"object\") return false\n const n = v as Record<string, unknown>\n return typeof n.line === \"object\" && n.line !== null && typeof n.column === \"object\" && n.column !== null\n}\n\nexport function toRange(node: Spanned): Range {\n return {\n start: { line: node.line.start - 1, character: node.column.start - 1 },\n end: { line: node.line.end - 1, character: node.column.end - 1 },\n }\n}\n\n/** A one-character range, for a diagnostic on a node with a collapsed span. */\nexport function toPosition(line: number, column: number): Position {\n return { line: line - 1, character: column - 1 }\n}\n\n/** Is `pos` inside `node`'s span? The end is exclusive, except that `inclusive`\n * admits a cursor sitting immediately after the node — which is where it is\n * while you are still typing the identifier under it. */\nexport function containsPosition(node: Spanned, pos: Position, inclusive = false): boolean {\n const startLine = node.line.start - 1\n const endLine = node.line.end - 1\n if (pos.line < startLine || pos.line > endLine) return false\n if (pos.line === startLine && pos.character < node.column.start - 1) return false\n if (pos.line === endLine) {\n const end = node.column.end - 1\n if (inclusive ? pos.character > end : pos.character >= end) return false\n }\n return true\n}\n\n/** Every child node of `node`, in source order-ish (declaration order of the\n * fields). Generic on purpose: it walks the object graph rather than knowing\n * the node types, so a new node kind in the parser needs no change here.\n *\n * Some nodes carry no span — the field wrappers of object literals\n * (`TableFieldNamed`) and type literals (`TableTypeProperty`). They are\n * walked *through*: their own children are returned in their place. Skipping\n * them would hide everything inside, which is how hovering an object key used\n * to land on the whole object. */\nexport function children(node: Spanned): Spanned[] {\n const out: Spanned[] = []\n collect(node, out)\n return out\n}\n\nfunction collect(container: object, out: Spanned[]): void {\n for (const key of Object.keys(container)) {\n if (key === \"line\" || key === \"column\") continue\n const value = (container as Record<string, unknown>)[key]\n for (const item of Array.isArray(value) ? value : [value]) {\n if (isSpanned(item)) out.push(item)\n else if (isSpanlessNode(item)) collect(item, out)\n }\n }\n}\n\n/** A node-shaped object (it has a `type` tag) that has no span of its own. */\nfunction isSpanlessNode(v: unknown): v is object {\n // Anything in the tree that carries no span of its own: a template's parts\n // (`{ kind: \"expression\", expression }`), a ternary's clauses\n // (`{ condition, body }`). What they hold are nodes like any other.\n return !!v && typeof v === \"object\" && !Array.isArray(v)\n}\n\n/** The chain of nodes containing `pos`, outermost first — the last entry is\n * the innermost node at the cursor and the ones before it are its ancestors.\n *\n * It descends through every child rather than only children that contain\n * `pos`, because a parent's span does not always cover its child's: a\n * binding's span is the name alone, while its type annotation sits after it.\n * So an ancestor in this path is a real ancestor, but not necessarily one\n * whose own span contains the cursor. */\nexport function pathAt(root: Spanned, pos: Position, inclusive = false): Spanned[] {\n let best: Spanned[] | undefined\n\n const descend = (node: Spanned, ancestors: Spanned[]): void => {\n const here = [...ancestors, node]\n if (containsPosition(node, pos, inclusive)) {\n // Prefer the narrowest hit, and among equals the deepest — that is\n // the node the cursor is really \"on\".\n const incumbent = best?.[best.length - 1]\n if (!incumbent\n || spanLength(node) < spanLength(incumbent)\n || (spanLength(node) === spanLength(incumbent) && here.length > best!.length)) {\n best = here\n }\n }\n for (const child of children(node)) descend(child, here)\n }\n\n descend(root, [])\n return best ?? []\n}\n\n/** The innermost node containing `pos`. */\nexport function nodeAt(root: Spanned, pos: Position, inclusive = false): Spanned | undefined {\n const path = pathAt(root, pos, inclusive)\n return path[path.length - 1]\n}\n\n/** The innermost node of one of `types` containing `pos`. */\nexport function enclosing<T extends Spanned>(\n root: Spanned,\n pos: Position,\n types: readonly string[],\n inclusive = false,\n): T | undefined {\n const path = pathAt(root, pos, inclusive)\n for (let i = path.length - 1; i >= 0; i--) {\n if (path[i].type && types.includes(path[i].type as string)) return path[i] as T\n }\n return undefined\n}\n\nfunction spanLength(node: Spanned): number {\n // Line count dominates: a node spanning fewer lines is nested deeper.\n return (node.line.end - node.line.start) * 10000 + (node.column.end - node.column.start)\n}\n\n/** Walk every node under `root`, depth first. */\nexport function walk(root: Spanned, visit: (node: Spanned, parent?: Spanned) => void, parent?: Spanned): void {\n visit(root, parent)\n for (const child of children(root)) walk(child, visit, root)\n}\n","/**\n * Modules, across files: completing module paths and the names they export,\n * and jumping from an `import` (or `export ... from`) to the declaration.\n *\n * Completion works on the line's text rather than the AST — a statement that\n * is being typed does not parse yet, and those are exactly the moments\n * completion is asked for.\n */\nimport { readdirSync } from \"node:fs\"\nimport { dirname, resolve } from \"node:path\"\nimport {\n CompletionItemKind,\n type Command, type CompletionItem, type Location, type Position, type Range,\n} from \"vscode-languageserver\"\nimport type { TextDocument } from \"vscode-languageserver-textdocument\"\nimport {\n formatType,\n type BindingTarget, type ExportAllStatement, type ExportNamedStatement, type Identifier, type ImportStatement,\n} from \"luaut-parser\"\nimport { bindingOfNode, pathOfUri, samePath, uriOfPath, type Analysis, type Analyzer } from \"../analysis.js\"\nimport { pathAt, toRange, type Spanned } from \"../ast-utils.js\"\nimport { signaturesOf } from \"./members.js\"\n\n/** Keep the suggestion list open after picking a folder, to go one level in. */\nconst SUGGEST_AGAIN: Command = { title: \"Suggest\", command: \"editor.action.triggerSuggest\" }\n\n/** Completion inside an `import` or `export ... from`, or `undefined` when the\n * cursor is not in one. */\nexport function importCompletion(\n analyzer: Analyzer,\n document: TextDocument,\n position: Position,\n): CompletionItem[] | undefined {\n const text = document.getText()\n const cursor = document.offsetAt(position)\n const lineStart = document.offsetAt({ line: position.line, character: 0 })\n const lineEnd = document.offsetAt({ line: position.line + 1, character: 0 })\n const before = text.slice(lineStart, cursor)\n const after = text.slice(cursor, lineEnd)\n if (!/^\\s*(?:import|export)\\b/.test(before)) return undefined\n\n // In the module path: `from \"./sha|\"`.\n const path = /\\bfrom\\s*([\"'])([^\"']*)$/.exec(before)\n if (path) return pathItems(analyzer, document.uri, position, path[2])\n\n // In the braces: `import { a, | } from \"./x\"`.\n const braces = /^\\s*(import|export)\\s+(?:[A-Za-z_][A-Za-z0-9_]*\\s*,\\s*)?\\{[^}]*$/.exec(before)\n if (braces) {\n const module = /\\}\\s*from\\s*([\"'])([^\"']+)\\1/.exec(after)\n if (module) return nameItems(analyzer, document.uri, module[2], before)\n // `export { | }` with no `from` names this file's own declarations:\n // ordinary completion answers that.\n return braces[1] === \"import\" ? [] : undefined\n }\n return undefined\n}\n\nfunction pathItems(analyzer: Analyzer, fromUri: string, position: Position, typed: string): CompletionItem[] {\n const from = pathOfUri(fromUri)\n if (!from) return []\n\n if (typed.startsWith(\"./\") || typed.startsWith(\"../\")) {\n const slash = typed.lastIndexOf(\"/\")\n return entryItems(resolve(dirname(from), typed.slice(0, slash + 1)), rangeBack(position, typed.length - slash - 1), from)\n }\n\n // Not started yet, or an alias: offer the ways in — `./`, `../` and each\n // `paths` alias — and inside an alias, what its targets hold.\n const items = new Map<string, CompletionItem>()\n const whole = rangeBack(position, typed.length)\n const offer = (label: string, folder: boolean): void => {\n if (!label.startsWith(typed) || label === typed) return\n items.set(label, {\n label,\n kind: folder ? CompletionItemKind.Folder : CompletionItemKind.File,\n textEdit: { range: whole, newText: label },\n command: folder ? SUGGEST_AGAIN : undefined,\n })\n }\n offer(\"./\", true)\n offer(\"../\", true)\n\n const config = analyzer.projectOf(fromUri).config\n for (const [pattern, targets] of Object.entries(config?.paths ?? {})) {\n const star = pattern.indexOf(\"*\")\n if (star < 0) {\n offer(pattern, false)\n continue\n }\n const prefix = pattern.slice(0, star)\n if (!typed.startsWith(prefix)) {\n offer(prefix, true)\n continue\n }\n const rest = typed.slice(prefix.length)\n const slash = rest.lastIndexOf(\"/\")\n const range = rangeBack(position, rest.length - slash - 1)\n for (const target of targets) {\n const cut = target.indexOf(\"*\")\n const head = cut < 0 ? target : target.slice(0, cut)\n for (const item of entryItems(resolve(config!.baseUrl, head + rest.slice(0, slash + 1)), range, from)) {\n items.set(item.label, item)\n }\n }\n }\n return [...items.values()]\n}\n\n/** The luaut files and folders in `directory`, as import path completions. */\nfunction entryItems(directory: string, range: Range, from: string): CompletionItem[] {\n let entries\n try {\n entries = readdirSync(directory, { withFileTypes: true })\n } catch {\n return []\n }\n\n const items: CompletionItem[] = []\n for (const entry of entries) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue\n if (entry.isDirectory()) {\n items.push({\n label: `${entry.name}/`,\n kind: CompletionItemKind.Folder,\n textEdit: { range, newText: `${entry.name}/` },\n command: SUGGEST_AGAIN,\n })\n } else if (entry.name.endsWith(\".luaut\")) {\n // A file does not import itself.\n if (samePath(resolve(directory, entry.name), from)) continue\n const name = entry.name.replace(/(\\.d)?\\.luaut$/, \"\")\n items.push({\n label: name,\n kind: CompletionItemKind.File,\n detail: entry.name,\n textEdit: { range, newText: name },\n })\n }\n }\n return items\n}\n\nfunction nameItems(analyzer: Analyzer, fromUri: string, specifier: string, before: string): CompletionItem[] {\n const target = analyzer.resolveModulePath(fromUri, specifier)\n const exports = target ? analyzer.exportsAt(target) : undefined\n if (!exports) return []\n\n // Names already in the braces are not offered again.\n const braces = before.slice(before.indexOf(\"{\") + 1)\n const listed = new Set(braces.split(\",\").map(part => part.trim().split(/\\s+/)[0]).filter(Boolean))\n\n const items: CompletionItem[] = []\n for (const [name, type] of exports.values) {\n if (listed.has(name)) continue\n items.push({\n label: name,\n kind: signaturesOf(type).length ? CompletionItemKind.Function : CompletionItemKind.Variable,\n detail: formatType(type),\n })\n }\n for (const [name, exported] of exports.types) {\n if (listed.has(name) || exports.values.has(name)) continue\n items.push({\n label: name,\n kind: CompletionItemKind.Interface,\n detail: `type ${name} = ${formatType(exported.type)}`,\n })\n }\n return items\n}\n\nfunction rangeBack(position: Position, length: number): Range {\n return { start: { line: position.line, character: position.character - length }, end: position }\n}\n\n// --------------------------------------------------------------------------\n// Definition\n// --------------------------------------------------------------------------\n\n/** A statement that names another module. */\ntype ModuleReference = ImportStatement | ExportNamedStatement | ExportAllStatement\n\n/** Go-to-definition inside a statement that names another module: the module\n * string opens the module, a name jumps to where it is really declared —\n * through any `export { } from` and `export *` in between. `undefined` when\n * the cursor is not in such a statement, so the caller can fall back to\n * ordinary definition. */\nexport function importDefinition(\n analyzer: Analyzer,\n analysis: Analysis,\n position: Position,\n): Location | null | undefined {\n const path = pathAt(analysis.program, position, true)\n const statement = path.find(isModuleReference) as unknown as ModuleReference | undefined\n if (!statement?.source) return undefined\n\n const target = analyzer.resolveModulePath(analysis.uri, statement.source.value)\n if (!target) return null\n const fileStart: Location = {\n uri: uriOfPath(target),\n range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },\n }\n\n const name = referencedName(statement, path[path.length - 1] as unknown)\n if (!name) return fileStart\n const module = analyzer.moduleAt(target)\n const found = module && exportDeclaration(analyzer, module, name)\n return found ? { uri: found.uri, range: toRange(found.node) } : fileStart\n}\n\nfunction isModuleReference(node: Spanned): boolean {\n return node.type === \"ImportStatement\"\n || node.type === \"ExportAllStatement\"\n || (node.type === \"ExportNamedStatement\" && !!(node as unknown as ExportNamedStatement).source)\n}\n\n/** The name, as the other module exports it, that `node` stands for. */\nfunction referencedName(statement: ModuleReference, node: unknown): string | undefined {\n switch (statement.type) {\n case \"ImportStatement\":\n if (node === statement.defaultImport) return \"default\"\n return statement.specifiers.find(s => node === s.imported || node === s.local)?.imported.name\n case \"ExportNamedStatement\":\n return statement.specifiers.find(s => node === s.local || node === s.exported)?.local.name\n case \"ExportAllStatement\":\n return undefined\n }\n}\n\nexport interface Declaration {\n uri: string\n node: Spanned\n}\n\n/** Where the export `name` (`\"default\"` for the default) of `module` is\n * declared — following re-exports into the module that declares it. */\nexport function exportDeclaration(\n analyzer: Analyzer,\n module: Analysis,\n name: string,\n seen = new Set<string>(),\n): Declaration | undefined {\n // Re-exports can form a cycle; each (module, name) is visited once.\n const key = `${module.uri}#${name}`\n if (seen.has(key)) return undefined\n seen.add(key)\n\n const here = (node: unknown): Declaration => ({ uri: module.uri, node: node as Spanned })\n const stars: string[] = []\n\n for (const statement of module.program.body.statements) {\n switch (statement.type) {\n case \"ExportDefaultStatement\":\n if (name === \"default\") return here(statement)\n break\n case \"ExportTypeAliasStatement\":\n if (statement.alias.name.name === name) return here(statement.alias.name)\n break\n case \"ExportStatement\": {\n const declaration = statement.declaration\n if (declaration.type === \"FunctionDeclaration\") {\n if (declaration.name.name === name) return here(declaration.name)\n } else {\n for (const target of declaration.names) {\n const found = patternNamed(target, name)\n if (found) return here(found)\n }\n }\n break\n }\n case \"ExportNamedStatement\": {\n const specifier = statement.specifiers.find(s => s.exported.name === name)\n if (!specifier) break\n if (statement.source) {\n const next = moduleFrom(analyzer, module, statement.source.value)\n return next && exportDeclaration(analyzer, next, specifier.local.name, seen)\n }\n return here(localDeclaration(module, specifier.local) ?? specifier.local)\n }\n case \"ExportAllStatement\":\n stars.push(statement.source.value)\n break\n }\n }\n\n // `export *` never carries the default, and a name declared here wins.\n if (name === \"default\") return undefined\n for (const specifier of stars) {\n const next = moduleFrom(analyzer, module, specifier)\n const found = next && exportDeclaration(analyzer, next, name, seen)\n if (found) return found\n }\n return undefined\n}\n\nfunction moduleFrom(analyzer: Analyzer, module: Analysis, specifier: string): Analysis | undefined {\n const target = analyzer.resolveModulePath(module.uri, specifier)\n return target ? analyzer.moduleAt(target) : undefined\n}\n\n/** The declaration of a top-level value or type that `export { x }` names. */\nfunction localDeclaration(module: Analysis, local: Identifier): unknown {\n const binding = bindingOfNode(module, local)\n if (binding?.declarationNode) return binding.declarationNode\n for (const statement of module.program.body.statements) {\n const alias = statement.type === \"TypeAliasStatement\" ? statement\n : statement.type === \"ExportTypeAliasStatement\" ? statement.alias\n : undefined\n if (alias?.name.name === local.name) return alias.name\n }\n return undefined\n}\n\nfunction patternNamed(target: BindingTarget, name: string): Spanned | undefined {\n switch (target.type) {\n case \"IdentifierPattern\":\n return target.name === name ? (target as unknown as Spanned) : undefined\n case \"ObjectPattern\":\n for (const property of target.properties) {\n const found = patternNamed(property.value, name)\n if (found) return found\n }\n return target.rest && patternNamed(target.rest, name)\n case \"ArrayPattern\":\n for (const element of target.elements) {\n const found = element && patternNamed(element.value, name)\n if (found) return found\n }\n return target.rest && patternNamed(target.rest, name)\n }\n}\n","/** Syntax errors, scope errors and type errors, as one list. */\nimport { DiagnosticSeverity, type Diagnostic } from \"vscode-languageserver\"\nimport { applyDirectives, UNUSED_EXPECT_ERROR } from \"luaut-parser\"\nimport type { Analysis } from \"../analysis.js\"\nimport { toRange, toPosition } from \"../ast-utils.js\"\n\nexport function diagnostics(analysis: Analysis): Diagnostic[] {\n const out: Diagnostic[] = []\n\n // Syntax errors are always shown: no directive makes broken code compile.\n for (const error of analysis.parseErrors) {\n // A parse error points at a token, not a span; highlight to the end of\n // the word under it so the squiggle is visible.\n const start = toPosition(error.line, error.column)\n out.push({\n range: { start, end: { line: start.line, character: start.character + 1 } },\n severity: DiagnosticSeverity.Error,\n source: \"luaut\",\n code: \"syntax\",\n // The parser appends `(line:column)`; the range already says that.\n message: error.message.replace(/\\s*\\(\\d+:\\d+\\)$/, \"\"),\n })\n }\n\n const semantic: Diagnostic[] = [\n ...analysis.scopes.diagnostics.map(d => ({\n range: toRange(d.node),\n severity: DiagnosticSeverity.Error,\n source: \"luaut\",\n code: d.kind,\n message: d.message,\n })),\n ...analysis.types.diagnostics.map(d => ({\n range: toRange(d.node),\n severity: DiagnosticSeverity.Error,\n source: \"luaut\",\n code: \"type\",\n message: d.message,\n })),\n ]\n\n // `--@luaut-nocheck`, `--@luaut-ignore`, `--@luaut-expect-error`.\n const { kept, unusedExpectErrors } = applyDirectives(analysis.directives, semantic, d => d.range.start.line + 1)\n out.push(...kept)\n for (const directive of unusedExpectErrors) {\n const start = toPosition(directive.line, directive.column)\n out.push({\n range: { start, end: { line: start.line, character: start.character + \"--@luaut-expect-error\".length } },\n severity: DiagnosticSeverity.Error,\n source: \"luaut\",\n code: \"directive\",\n message: UNUSED_EXPECT_ERROR,\n })\n }\n\n return out\n}\n","/**\n * Hover: what the thing under the cursor is, as luaut would write it.\n *\n * Every answer comes from the parser's own tables — binding types, the type of\n * each expression, the resolved type of each type annotation — and every name\n * has a node of its own to point at. Nothing is recovered from the source\n * text.\n */\nimport type { Hover, Position } from \"vscode-languageserver\"\nimport {\n formatType, isClassType,\n type Binding, type Expression, type Identifier, type Type, type TypeNode,\n} from \"luaut-parser\"\nimport { bindingOfNode, type Analysis } from \"../analysis.js\"\nimport { pathAt, toRange, type Spanned } from \"../ast-utils.js\"\nimport { signaturesOf } from \"./members.js\"\n\nexport function hover(analysis: Analysis, position: Position): Hover | null {\n const path = pathAt(analysis.program, position, true)\n for (let i = path.length - 1; i >= 0; i--) {\n // On an operator, a parenthesis or a dot the cursor is on no name:\n // nothing to say, as in TypeScript — not the type of the whole\n // expression around it.\n if (UNNAMED.has(path[i].type as string)) return null\n const text = describe(analysis, path, i)\n if (text) return { contents: { kind: \"markdown\", value: code(text) }, range: toRange(path[i]) }\n }\n return null\n}\n\n/** Expressions made of other expressions plus operators or punctuation. The\n * names inside them have hovers of their own. */\nconst UNNAMED = new Set([\n \"BinaryExpression\", \"UnaryExpression\", \"CallExpression\", \"MethodCallExpression\",\n \"MemberExpression\", \"IndexExpression\", \"ParenthesizedExpression\", \"IfElseExpression\",\n \"TableExpression\", \"ArrayExpression\", \"TypeAssertionExpression\", \"SatisfiesExpression\",\n \"AsConstExpression\", \"InterpolatedStringExpression\",\n])\n\ntype AnyNode = Spanned & Record<string, unknown>\n\nconst PRIMITIVES = new Set([\"any\", \"unknown\", \"never\", \"nil\", \"boolean\", \"number\", \"string\", \"thread\", \"buffer\"])\n\nfunction describe(analysis: Analysis, path: readonly Spanned[], index: number): string | undefined {\n const { types } = analysis\n const node = path[index] as AnyNode\n const parent = path[index - 1] as AnyNode | undefined\n const typeOfNode = (n: unknown): Type | undefined => types.typeOfTypeNode.get(n as TypeNode)\n\n switch (node.type) {\n case \"Identifier\": {\n const identifier = node as unknown as Identifier\n const name = identifier.name\n\n switch (parent?.type) {\n // `{ name: \"n\" }` — read the property off the object's type, so\n // it widens the way the object did (`string`, not `\"n\"`).\n case \"TableExpression\": {\n const field = fieldWithKey(parent, node)\n if (!field) break\n const objectType = types.typeOf.get(parent as unknown as Expression)\n const property = objectType?.kind === \"object\" ? objectType.properties.get(name) : undefined\n const type = property?.type ?? types.typeOf.get(field.value)\n return type && `(property) ${name}: ${pretty(type)}`\n }\n // `const { name } = t`: a shorthand key *is* the binding it\n // declares, and has the same span, so the cursor can land on\n // either. A renamed key (`{ name: other }`) names the property\n // the value is read from.\n case \"ObjectPatternProperty\": {\n if (parent.key !== node || parent.computed) break\n const value = parent.value as AnyNode\n if (parent.shorthand) return describe(analysis, [...path.slice(0, index), value], index)\n const binding = value.type === \"IdentifierPattern\" ? bindingOfNode(analysis, value) : undefined\n const type = binding && types.bindingType.get(binding.id)\n return type && `(property) ${name}: ${pretty(type)}`\n }\n // One line of an overload set reads as its own signature.\n // The line the body is on reads as the whole set, which is\n // what the binding says and what the default path gives.\n case \"FunctionSignature\": {\n if (parent.name !== node) break\n const own = types.typeOfTypeNode.get(parent as unknown as TypeNode)\n if (own) return `function ${name}${pretty(own)}`\n break\n }\n case \"ImportSpecifier\": {\n // A type-only import has no value worth showing (`any`);\n // the type it brings in is the answer.\n const alias = types.aliases.get(name)\n const binding = bindingOfNode(analysis, identifier)\n const value = binding && types.bindingType.get(binding.id)\n if (alias && (!value || value.kind === \"any\")) return `type ${name} = ${pretty(alias)}`\n break\n }\n case \"ExportSpecifier\": {\n // `export { Size }` can name a type, which has no binding.\n if (bindingOfNode(analysis, identifier)) break\n const alias = types.aliases.get(name)\n if (alias) return `type ${name} = ${pretty(alias)}`\n break\n }\n case \"TypeAliasStatement\":\n case \"ExportTypeAliasStatement\":\n if (parent.name === node) return aliasText(analysis, parent)\n break\n case \"DeclareStatement\":\n if (parent.id === node) return declareText(analysis, parent)\n break\n case \"DeclareClassStatement\":\n if (parent.name === node) return classText(analysis, name)\n break\n case \"TableTypeProperty\":\n if (parent.key === node) {\n const type = typeOfNode(parent.valueType)\n const readonly = parent.readonly ? \"readonly \" : \"\"\n return type && `(property) ${readonly}${name}${parent.optional ? \"?\" : \"\"}: ${pretty(type)}`\n }\n break\n case \"FunctionTypeParameter\":\n if (parent.id === node) {\n const type = typeOfNode(parent.typeAnnotation)\n return type && `(parameter) ${name}${parent.optional ? \"?\" : \"\"}: ${pretty(type)}`\n }\n break\n case \"GenericTypeParameter\":\n if (parent.id === node) return typeParameterText(analysis, parent)\n break\n case \"InferTypeNode\":\n if (parent.id === node) return `(type parameter) infer ${name}`\n break\n case \"MappedTypeNode\":\n if (parent.parameterId === node) {\n const keys = typeOfNode(parent.constraint)\n return `(type parameter) ${name}${keys ? ` in ${formatType(keys)}` : \"\"}`\n }\n break\n }\n\n // A reference: prefer the narrowed type — what the code sees here,\n // and the whole reason for narrowing.\n const narrowed = types.narrowedTypeOf.get(identifier)\n if (narrowed) return `${name}: ${pretty(narrowed)}`\n const binding = bindingOfNode(analysis, identifier)\n if (binding) {\n const type = types.bindingType.get(binding.id)\n if (type) return bindingText(binding, type)\n }\n // `x.foo` / `x:foo()` — the member's own type.\n if (parent?.type === \"MemberExpression\" || parent?.type === \"MethodCallExpression\") {\n const type = types.typeOf.get(parent as unknown as Expression)\n if (type) return `${name}: ${pretty(type)}`\n }\n return undefined\n }\n\n // `...` — what this function's extra arguments are.\n case \"VarargExpression\": {\n const type = types.typeOf.get(node as unknown as Expression)\n return type ? `(vararg) ...: ${pretty(type)}` : undefined\n }\n\n // Declarations: `const x`, a parameter.\n case \"IdentifierPattern\":\n case \"FunctionParameter\":\n case \"TypedIdentifier\": {\n const binding = bindingOfNode(analysis, node)\n const type = binding && types.bindingType.get(binding.id)\n return type ? bindingText(binding, type) : undefined\n }\n\n // A type written by name: `number`, `Shape`, `Partial<User>`, or a type\n // parameter in scope.\n case \"TypeReference\": {\n const base = node.base as string\n if (!node.namespace) {\n const parameter = typeParameterInScope(path, index, base)\n if (parameter) return typeParameterText(analysis, parameter)\n if (PRIMITIVES.has(base)) return `type ${base}`\n }\n // A plain alias: its definition. The resolved type carries the\n // alias's name, so printing that would read `type Shape = Shape`.\n if (!(node.typeArguments as unknown[]).length) {\n // `Enum.Material` is declared under its qualified name.\n const qualified = node.namespace ? `${node.namespace}.${base}` : base\n const alias = types.aliases.get(qualified)\n if (alias && isClassType(alias)) return classText(analysis, qualified)\n if (alias) return `type ${qualified} = ${pretty(alias)}`\n }\n const type = typeOfNode(node)\n return type && `type ${referenceText(analysis, node)} = ${pretty(type)}`\n }\n }\n\n // Any other part of a type — `typeof x`, `keyof T`, a union — reads as what\n // it resolves to; any expression as its type.\n const annotated = typeOfNode(node)\n if (annotated) return pretty(annotated)\n const type = types.typeOf.get(node as unknown as Expression)\n return type ? pretty(type) : undefined\n}\n\n/** `type Name<T extends C> = ...` */\nfunction aliasText(analysis: Analysis, statement: AnyNode): string | undefined {\n const name = (statement.name as Identifier).name\n const alias = analysis.types.aliases.get(name)\n if (!alias) return undefined\n const generics = (statement.generics as AnyNode[] | undefined) ?? []\n const parameters = generics.length\n ? `<${generics.map(g => typeParameterSignature(analysis, g)).join(\", \")}>`\n : \"\"\n return `type ${name}${parameters} = ${pretty(alias)}`\n}\n\n/** `declare math: {...}` / `declare function f(x: number) -> string (+2 overloads)`.\n * A name declared several times is an overload set: show the signature this\n * particular declaration contributes, and how many others there are. */\nfunction declareText(analysis: Analysis, statement: AnyNode): string | undefined {\n const name = statement.name as string\n const own = analysis.types.typeOfTypeNode.get(statement.valueType as TypeNode)\n if (!own) return undefined\n if (own.kind !== \"function\") return `declare ${name}: ${pretty(own)}`\n // Declaring a name more than once makes an overload set. Count what every\n // top-level declaration of the name contributes — read from the AST, since\n // a declared name nothing references has no binding to read it from.\n const total = (analysis.program.body.statements as unknown as AnyNode[])\n .filter(s => s.type === \"DeclareStatement\" && s.name === name)\n .reduce((n, s) => n + signaturesOf(analysis.types.typeOfTypeNode.get(s.valueType as TypeNode)).length, 0)\n const others = total - 1\n const overloads = others > 0 ? ` (+${others} overload${others > 1 ? \"s\" : \"\"})` : \"\"\n return `declare function ${name}${formatType(own)}${overloads}`\n}\n\n/** `declare class Part extends BasePart { ... }` — the members this class\n * adds. What it inherits is a hover away, on the superclass. */\nfunction classText(analysis: Analysis, name: string): string | undefined {\n const type = analysis.types.aliases.get(name)\n if (!type || !isClassType(type)) return undefined\n const superclass = type.class.superclass\n const inherited = superclass ? analysis.types.aliases.get(superclass) : undefined\n const own = [...type.properties].filter(([key, property]) =>\n inherited?.kind !== \"object\" || inherited.properties.get(key) !== property)\n const head = `declare class ${name}${superclass ? ` extends ${superclass}` : \"\"}`\n if (!own.length) return `${head} {}`\n const lines = own.map(([key, property]) =>\n ` ${property.readonly ? \"readonly \" : \"\"}${key}${property.optional ? \"?\" : \"\"}: ${formatType(property.type)},`)\n return `${head} {\\n${lines.join(\"\\n\")}\\n}`\n}\n\ninterface TypeParameterNode {\n name: string\n constraint?: unknown\n isConst?: boolean\n infer?: boolean\n}\n\nfunction typeParameterText(analysis: Analysis, parameter: TypeParameterNode | AnyNode): string {\n return `(type parameter) ${typeParameterSignature(analysis, parameter)}`\n}\n\nfunction typeParameterSignature(analysis: Analysis, parameter: TypeParameterNode | AnyNode): string {\n const p = parameter as TypeParameterNode\n if (p.infer) return `infer ${p.name}`\n const constraint = p.constraint ? analysis.types.typeOfTypeNode.get(p.constraint as TypeNode) : undefined\n return `${p.isConst ? \"const \" : \"\"}${p.name}${constraint ? ` extends ${formatType(constraint)}` : \"\"}`\n}\n\n/** The type parameter `name` refers to at this point: from an enclosing\n * generic list, a mapped type's key, or an `infer` in a conditional. */\nfunction typeParameterInScope(path: readonly Spanned[], index: number, name: string): TypeParameterNode | undefined {\n for (let i = index - 1; i >= 0; i--) {\n const a = path[i] as AnyNode\n const generic = (a.generics as TypeParameterNode[] | undefined)?.find(g => g.name === name)\n if (generic) return generic\n if (a.type === \"MappedTypeNode\" && a.parameter === name) return { name }\n if (a.type === \"ConditionalTypeNode\" && bindsInfer(a.extendsType, name)) return { name, infer: true }\n }\n return undefined\n}\n\nfunction bindsInfer(node: unknown, name: string): boolean {\n if (!node || typeof node !== \"object\") return false\n if (Array.isArray(node)) return node.some(n => bindsInfer(n, name))\n const n = node as AnyNode\n if (n.type === \"InferTypeNode\" && n.name === name) return true\n return Object.values(n).some(v => bindsInfer(v, name))\n}\n\n/** `Partial<User>` — the reference with its arguments resolved. */\nfunction referenceText(analysis: Analysis, reference: AnyNode): string {\n const name = reference.namespace ? `${reference.namespace}.${reference.base}` : (reference.base as string)\n const args = (reference.typeArguments as unknown[]) ?? []\n if (!args.length) return name\n const resolved = args.map(a => {\n const t = analysis.types.typeOfTypeNode.get(a as TypeNode)\n return t ? formatType(t) : \"?\"\n })\n return `${name}<${resolved.join(\", \")}>`\n}\n\nfunction fieldWithKey(table: AnyNode, key: AnyNode): { value: Expression } | undefined {\n const fields = table.fields as { type: string; key?: unknown; value: Expression }[]\n return fields.find(f => f.type === \"TableFieldNamed\" && f.key === key)\n}\n\n/** Long object types one member per line, overload sets one signature per\n * line — `math` on a single line is thousands of characters. */\nfunction pretty(type: Type): string {\n const flat = formatType(type)\n if (flat.length <= 80) return flat\n if (type.kind === \"object\") {\n const lines: string[] = []\n if (type.indexer) lines.push(` [${formatType(type.indexer.key)}]: ${formatType(type.indexer.value)},`)\n for (const [name, property] of type.properties) {\n const readonly = property.readonly ? \"readonly \" : \"\"\n lines.push(` ${readonly}${name}${property.optional ? \"?\" : \"\"}: ${formatType(property.type)},`)\n }\n return `{\\n${lines.join(\"\\n\")}\\n}`\n }\n if (type.kind === \"intersection\" && type.types.every(t => t.kind === \"function\")) {\n return type.types.map(formatType).join(\"\\n& \")\n }\n return flat\n}\n\n/** `const x: number`, `function f(a: string) -> number`, `(import) util: {...}`. */\nfunction bindingText(binding: Binding, type: Type): string {\n if (binding.declaredBy === \"function\" && type.kind === \"function\") {\n return `function ${binding.name}${formatType(type)}`\n }\n return `${keyword(binding)} ${binding.name}: ${pretty(type)}`\n}\n\nfunction keyword(binding: Binding): string {\n if (binding.kind === \"param\" || binding.kind === \"self\") return \"(parameter)\"\n if (binding.kind === \"global\") return \"(global)\"\n if (binding.kind.startsWith(\"for-\")) return \"(loop variable)\"\n if (binding.declaredBy === \"import\" || binding.declaredBy === \"namespace\") return \"(import)\"\n if (binding.declaredBy === \"type\") return \"(type import)\"\n if (binding.declaredBy === \"function\") return \"function\"\n return binding.isConst ? \"const\" : \"let\"\n}\n\nfunction code(text: string): string {\n // Its own grammar: VS Code colours a hover's code block with TextMate\n // only, and the editor's luaut grammar deliberately leaves names and\n // types to semantic tokens. Hover text is output this server formats,\n // so a grammar for that format is exact rather than a guess.\n return \"```luaut-hover\\n\" + text + \"\\n```\"\n}\n","/**\n * Go-to-definition, find-references, rename and document highlight — all four\n * are the same question (\"which binding is this, and where else does it\n * appear?\") asked with different answers.\n */\nimport {\n DocumentHighlightKind,\n type DocumentHighlight, type Location, type Position, type Range,\n type TextEdit, type WorkspaceEdit,\n} from \"vscode-languageserver\"\nimport type { Binding } from \"luaut-parser\"\nimport { bindingOfNode, type Analysis } from \"../analysis.js\"\nimport { pathAt, toRange, type Spanned } from \"../ast-utils.js\"\n\n/** Nodes that can name a binding — as a use or as its declaration. */\nconst NAMING = new Set([\"Identifier\", \"IdentifierPattern\", \"FunctionParameter\", \"TypedIdentifier\"])\n\n/** The binding referred to at `position`, if the cursor is on a variable —\n * a use of it or its declaration. */\nexport function bindingAt(analysis: Analysis, position: Position): Binding | undefined {\n const path = pathAt(analysis.program, position, true)\n for (let i = path.length - 1; i >= 0; i--) {\n const node = path[i]\n if (!node.type || !NAMING.has(node.type)) continue\n const binding = bindingOfNode(analysis, node)\n if (binding) return binding\n }\n return undefined\n}\n\n/** Every place the binding appears: its declaration plus every reference. */\nfunction sites(binding: Binding): Spanned[] {\n const out: Spanned[] = []\n if (binding.declarationNode) out.push(binding.declarationNode as unknown as Spanned)\n out.push(...(binding.references as unknown as Spanned[]))\n return out\n}\n\nexport function definition(analysis: Analysis, position: Position): Location | null {\n const binding = bindingAt(analysis, position)\n if (!binding?.declarationNode) return null\n return { uri: analysis.uri, range: toRange(binding.declarationNode as unknown as Spanned) }\n}\n\nexport function references(\n analysis: Analysis,\n position: Position,\n includeDeclaration: boolean,\n): Location[] {\n const binding = bindingAt(analysis, position)\n if (!binding) return []\n const nodes = includeDeclaration ? sites(binding) : (binding.references as unknown as Spanned[])\n return nodes.map(node => ({ uri: analysis.uri, range: toRange(node) }))\n}\n\nexport function highlights(analysis: Analysis, position: Position): DocumentHighlight[] {\n const binding = bindingAt(analysis, position)\n if (!binding) return []\n return sites(binding).map(node => ({\n range: toRange(node),\n kind: node === binding.declarationNode\n ? DocumentHighlightKind.Write\n : DocumentHighlightKind.Read,\n }))\n}\n\n/** The range rename would replace, and the current name — so the editor can\n * refuse before it asks for a new one. */\nexport function prepareRename(\n analysis: Analysis,\n position: Position,\n): { range: Range; placeholder: string } | null {\n const binding = bindingAt(analysis, position)\n if (!binding) return null\n // A builtin lives in a definitions file; renaming it here would rename the\n // uses and leave the declaration behind.\n if (binding.isBuiltin || !binding.declarationNode) return null\n const path = pathAt(analysis.program, position, true)\n const identifier = [...path].reverse().find(n => !!n.type && NAMING.has(n.type))\n if (!identifier) return null\n return { range: toRange(identifier), placeholder: binding.name }\n}\n\nexport function rename(analysis: Analysis, position: Position, newName: string): WorkspaceEdit | null {\n if (!isIdentifier(newName)) return null\n const binding = bindingAt(analysis, position)\n if (!binding || binding.isBuiltin || !binding.declarationNode) return null\n const edits: TextEdit[] = sites(binding).map(node => ({ range: toRange(node), newText: newName }))\n return { changes: { [analysis.uri]: edits } }\n}\n\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/\nfunction isIdentifier(name: string): boolean {\n return IDENTIFIER.test(name)\n}\n","/**\n * Completion.\n *\n * `x.` and `x:` are syntax errors, so the file as typed cannot answer \"what\n * are `x`'s members?\". The trick every language server of this shape uses:\n * substitute a placeholder identifier at the cursor, analyze *that* text, and\n * read the answer off the AST it produces. The user's document is untouched —\n * only the speculative copy is analyzed, and it is never cached.\n */\nimport {\n CompletionItemKind, InsertTextFormat,\n type CompletionItem, type Position,\n} from \"vscode-languageserver\"\nimport type { TextDocument } from \"vscode-languageserver-textdocument\"\nimport { formatType, isClassType, type Expression, type Type, type TypeNode } from \"luaut-parser\"\nimport type { Analysis, Analyzer } from \"../analysis.js\"\nimport { pathAt, type Spanned } from \"../ast-utils.js\"\nimport { importItems, serviceItems } from \"./autoImport.js\"\nimport { importCompletion } from \"./imports.js\"\nimport { membersOf, signaturesOf, signatureLabel } from \"./members.js\"\n\nconst PLACEHOLDER = \"__luautCompletion__\"\nconst IDENTIFIER_CHAR = /[A-Za-z0-9_]/\n\nexport function completion(\n analyzer: Analyzer,\n document: TextDocument,\n position: Position,\n): CompletionItem[] {\n // A module path or imported name: answered from the other module.\n const inImport = importCompletion(analyzer, document, position)\n if (inImport) return inImport\n\n // Inside a string argument: the values its parameter accepts.\n const inString = stringCompletion(analyzer, document, position)\n if (inString) return inString\n\n const source = document.getText()\n const offset = document.offsetAt(position)\n\n // The word being typed, if any — replaced wholesale so a half-written\n // name cannot break the speculative parse.\n let start = offset\n while (start > 0 && IDENTIFIER_CHAR.test(source[start - 1])) start--\n let end = offset\n while (end < source.length && IDENTIFIER_CHAR.test(source[end])) end++\n\n const operator = memberOperator(source, start)\n const alreadyCalled = /^\\s*\\(/.test(source.slice(end))\n\n // A member access on its own is not a statement — `obj.foo` alone on a\n // line is a syntax error, which is exactly where people type `obj.` — so\n // after `.` the placeholder is also tried as a call, which parses wherever\n // the access would and on a line of its own too. A method name after `:`\n // must be called to parse at all.\n const standIns = operator === \":\"\n ? [alreadyCalled ? PLACEHOLDER : `${PLACEHOLDER}()`]\n : operator === \".\" && !alreadyCalled\n ? [PLACEHOLDER, `${PLACEHOLDER}()`]\n : [PLACEHOLDER]\n\n // Where the placeholder sits, in the patched document's coordinates —\n // the same line, since the patch never spans one.\n const at: Position = { line: position.line, character: position.character - (offset - start) }\n\n let first: { analysis: Analysis; path: Spanned[] } | undefined\n for (const standIn of standIns) {\n const patched = source.slice(0, start) + standIn + source.slice(end)\n const analysis = analyzer.analyze(document.uri, -1, patched)\n const path = pathAt(analysis.program, at, true)\n const index = path.findLastIndex(\n n => n.type === \"Identifier\" && (n as unknown as { name: string }).name === PLACEHOLDER,\n )\n const parent = index > 0 ? path[index - 1] : undefined\n if (parent && (parent.type === \"MemberExpression\" || parent.type === \"MethodCallExpression\")) {\n return memberItems(analysis, parent)\n }\n first ??= { analysis, path }\n }\n\n // After `.` or `:` only members make sense. If none could be found, an\n // empty list is honest; the globals are never what was meant there.\n if (operator || !first) return []\n\n // A key of an object literal written where a type says what belongs in it.\n const keys = objectKeyItems(first.analysis, first.path, source.slice(end))\n if (keys) return keys\n\n // A type position wants type names, not values.\n if (inTypePosition(first.path)) {\n const named: CompletionItem[] = [...first.analysis.types.aliases].map(([name, type]) => ({\n label: name,\n kind: isClassType(type) ? CompletionItemKind.Class : CompletionItemKind.Interface,\n detail: isClassType(type) ? \"class\" : \"type\",\n }))\n const primitives: CompletionItem[] = PRIMITIVES.map(name => ({\n label: name,\n kind: CompletionItemKind.Keyword,\n detail: \"type\",\n }))\n const keywords: CompletionItem[] = TYPE_KEYWORDS.map(name => ({\n label: name,\n kind: CompletionItemKind.Keyword,\n sortText: `3${name}`,\n }))\n const typeNames = new Set(first.analysis.types.aliases.keys())\n const imported = importItems(analyzer, analyzer.get(document), true, typeNames)\n return [...named, ...primitives, ...keywords, ...imported]\n }\n\n // Names in scope, then what picking an item can bring into scope: another\n // file's export (with its `import`), or a service (with its `GetService`).\n const taken = new Set<string>()\n for (const binding of first.analysis.scopes.bindings.values()) taken.add(binding.name)\n const current = analyzer.get(document)\n return [\n ...valueItems(first.analysis, at),\n ...contextKeywords(source.slice(0, start)),\n ...importItems(analyzer, current, false, taken),\n ...serviceItems(current, taken),\n ]\n}\n\n/** Completion inside a string literal, or `undefined` when the cursor is not\n * in one. A string that is a call argument offers the string values its\n * parameter accepts — `game:GetService(\"|\")` lists the services. Any other\n * string offers nothing: a variable name is never what goes inside quotes. */\nfunction stringCompletion(\n analyzer: Analyzer,\n document: TextDocument,\n position: Position,\n): CompletionItem[] | undefined {\n let analysis = analyzer.get(document)\n let literal = stringAt(analysis, position)\n if (!literal) {\n // Mid-typing, the line around the string rarely parses yet —\n // `if name == \"` has neither its closing quote nor its `then`. Try the\n // likeliest endings on a copy, and read the string from the first\n // that parses. The endings go after the cursor, so positions hold.\n const repaired = repairedStrings(document, position)\n for (const text of repaired) {\n const candidate = analyzer.analyze(document.uri, -1, text)\n literal = stringAt(candidate, position)\n if (literal) {\n analysis = candidate\n break\n }\n }\n if (!literal) return repaired.length ? [] : undefined\n }\n\n const expected = analysis.types.expectedTypeOf.get(literal as unknown as Expression)\n const values = [...new Set([\n ...stringLiterals(expected, analysis.types.aliases),\n ...indexKeys(analysis, position, literal),\n ])]\n if (!values.length) return []\n\n // Replace what is between the quotes. A string spanning lines is left to\n // the editor's own filtering.\n const line = literal.line.start - 1\n const range = literal.line.start === literal.line.end\n ? {\n start: { line, character: literal.column.start },\n end: { line, character: literal.column.end - 2 },\n }\n : undefined\n return values.map(value => ({\n label: value,\n kind: CompletionItemKind.Constant,\n ...(range ? { textEdit: { range, newText: value } } : {}),\n }))\n}\n\nfunction stringAt(analysis: Analysis, position: Position): Spanned | undefined {\n const path = pathAt(analysis.program, position, false)\n return [...path].reverse().find(n => n.type === \"StringLiteral\" || n.type === \"TypeLiteralString\")\n}\n\n/** Inside `{ | }` written against a type — an annotation, `satisfies`, an\n * argument — the keys that type names, minus the ones already written. */\nfunction objectKeyItems(\n analysis: Analysis,\n path: readonly Spanned[],\n after: string,\n): CompletionItem[] | undefined {\n const index = path.findLastIndex(\n n => n.type === \"Identifier\" && (n as unknown as { name: string }).name === PLACEHOLDER,\n )\n const literal = index > 0 ? (path[index - 1] as unknown as Record<string, unknown>) : undefined\n if (literal?.type !== \"TableExpression\") return undefined\n const fields = literal.fields as { type: string; key?: { name?: string; value?: string }; name?: { name: string } }[]\n // Only where a key is being written: `{ width: | }` is a value.\n const atKey = fields.some(f => f.type === \"TableFieldShorthand\" && f.name?.name === PLACEHOLDER)\n if (!atKey) return undefined\n // `{ ... } as const satisfies T` records the expectation on the whole\n // `as const`, so read through the wrappers the literal sits in.\n let expected = analysis.types.expectedTypeOf.get(literal as unknown as Expression)\n for (let up = index - 2; expected === undefined && up >= 0; up--) {\n const outer = path[up]\n if (outer.type !== \"AsConstExpression\" && outer.type !== \"ParenthesizedExpression\") break\n expected = analysis.types.expectedTypeOf.get(outer as unknown as Expression)\n }\n const members = membersOf(expected, analysis.types.aliases)\n if (!members.length) return undefined\n\n const written = new Set<string>()\n for (const field of fields) {\n if (field.type === \"TableFieldNamed\") written.add(field.key?.name ?? field.key?.value ?? \"\")\n else if (field.type === \"TableFieldShorthand\" && field.name?.name !== PLACEHOLDER) written.add(field.name!.name)\n }\n // `name: ` unless the line already has the colon.\n const colon = /^\\s*:/.test(after)\n return members\n .filter(member => !written.has(member.name))\n .map(member => ({\n label: member.name,\n kind: CompletionItemKind.Field,\n detail: `${member.property.optional ? \"?\" : \"\"}: ${formatType(member.property.type)}`,\n insertText: colon ? member.name : `${member.name}: `,\n }))\n}\n\n/** The keys a string can name where it indexes something: `T[\"|\"]` in a type\n * offers `T`'s property names, and `obj[\"|\"]` those of `obj`'s type. */\nfunction indexKeys(analysis: Analysis, position: Position, literal: Spanned): string[] {\n const path = pathAt(analysis.program, position, false)\n const at = path.indexOf(literal)\n const parent = at > 0 ? (path[at - 1] as unknown as Record<string, unknown>) : undefined\n if (!parent) return []\n let indexed: Type | undefined\n if (parent.type === \"IndexedAccessTypeNode\" && parent.indexType === literal) {\n indexed = analysis.types.typeOfTypeNode.get(parent.objectType as TypeNode)\n } else if (parent.type === \"IndexExpression\" && parent.index === literal) {\n indexed = withoutNil(analysis.types.typeOf.get(parent.object as Expression))\n }\n return membersOf(indexed, analysis.types.aliases).map(member => member.name)\n}\n\n/** Copies of the document where the string the cursor is in — possibly\n * unclosed — could parse: its quote closed if need be, and the line finished\n * as an `if`, a loop or a call would be. Empty when the cursor is not inside\n * quotes at all. */\nfunction repairedStrings(document: TextDocument, position: Position): string[] {\n const source = document.getText()\n const offset = document.offsetAt(position)\n const lineStart = offset - position.character\n const lineEndIndex = source.indexOf(\"\\n\", offset)\n const lineEnd = lineEndIndex < 0 ? source.length : lineEndIndex\n const before = source.slice(lineStart, offset)\n\n // Which quote, if any, the cursor is inside.\n let quote: string | undefined\n for (let i = 0; i < before.length; i++) {\n const ch = before[i]\n if (quote) {\n if (ch === \"\\\\\") i++\n else if (ch === quote) quote = undefined\n } else if (ch === '\"' || ch === \"'\") {\n quote = ch\n }\n }\n if (!quote) return []\n\n let rest = source.slice(offset, lineEnd).replace(/\\r$/, \"\")\n if (!rest.includes(quote)) rest += quote\n const line = before + rest\n const endings = [\"\", \" then end\", \" do end\", \")\", \") then end\", \"]\"]\n return endings.map(ending => source.slice(0, lineStart) + line + ending + source.slice(lineEnd))\n}\n\n/** The string literal types a type admits — through unions, aliases and a\n * type parameter's constraint. */\nfunction stringLiterals(type: Type | undefined, aliases: ReadonlyMap<string, Type>, seen = new Set<Type>()): string[] {\n if (!type || seen.has(type)) return []\n seen.add(type)\n switch (type.kind) {\n case \"literal\":\n return typeof type.value === \"string\" ? [type.value] : []\n case \"union\":\n return [...new Set(type.types.flatMap(t => stringLiterals(t, aliases, seen)))]\n case \"genericRef\": {\n const alias = aliases.get(type.name)\n return alias ? stringLiterals(alias, aliases, seen) : []\n }\n case \"typeParam\":\n return stringLiterals(type.constraint, aliases, seen)\n default:\n return []\n }\n}\n\n/** The member operator right before the word being typed, if there is one.\n * `..` is concatenation and `1.` is a number, neither of which has members. */\nfunction memberOperator(source: string, wordStart: number): \".\" | \":\" | undefined {\n const ch = source[wordStart - 1]\n if (ch === \":\") return source[wordStart - 2] === \":\" ? undefined : \":\"\n if (ch !== \".\") return undefined\n if (source[wordStart - 2] === \".\") return undefined\n // A run of digits right before the dot, not part of a longer name.\n let i = wordStart - 2\n while (i >= 0 && /[0-9]/.test(source[i])) i--\n const digits = wordStart - 2 - i\n if (digits > 0 && (i < 0 || !/[A-Za-z_]/.test(source[i]))) return undefined\n return \".\"\n}\n\nfunction memberItems(analysis: Analysis, access: Spanned): CompletionItem[] {\n const object = (access as unknown as { object: Expression }).object\n // `a?.` reads from `a` when it is not nil, and so, in practice, does `a.`\n // on a `T | nil` a check has not narrowed yet: offer what `T` has.\n const type = withoutNil(analysis.types.typeOf.get(object))\n const colon = access.type === \"MethodCallExpression\"\n\n // An array and a string have no fields of their own: what they answer to\n // is the language's own methods, and only with `:`. `names.filter` would\n // be a read of a key the table does not have.\n if (isMethodOnly(type) && !colon) return []\n\n return membersOf(type, analysis.types.aliases)\n .filter(member => (colon ? member.isMethod : true))\n .map(member => memberItem(member.name, member.property.type, member.property.readonly))\n}\n\nfunction withoutNil(type: Type | undefined): Type | undefined {\n if (type?.kind !== \"union\") return type\n const kept = type.types.filter(t => !(t.kind === \"primitive\" && t.name === \"nil\"))\n return kept.length === 1 ? kept[0] : { ...type, types: kept }\n}\n\n/** A value whose members are all methods the language gives it — an array or\n * a string — rather than fields of its own. */\nfunction isMethodOnly(type: Type | undefined): boolean {\n if (!type) return false\n switch (type.kind) {\n case \"array\":\n case \"tuple\":\n case \"templateLiteral\":\n return true\n case \"primitive\": return type.name === \"string\"\n case \"literal\": return typeof type.value === \"string\"\n case \"union\": return type.types.length > 0 && type.types.every(isMethodOnly)\n default: return false\n }\n}\n\n/** Names in scope at `at`. Scope analysis records where each binding is\n * declared but not the extent of its scope, so this approximates: everything\n * declared earlier in the file, plus the globals, which are visible\n * everywhere. Over-offering is the right failure — a name the editor lists\n * and the file rejects is a diagnostic away from being obvious. */\nfunction valueItems(analysis: Analysis, at: Position): CompletionItem[] {\n const items: CompletionItem[] = []\n const seen = new Set<string>()\n for (const binding of analysis.scopes.bindings.values()) {\n if (binding.name === PLACEHOLDER || seen.has(binding.name)) continue\n // `import type` names are not values.\n if (binding.declaredBy === \"type\") continue\n const declaration = binding.declarationNode as unknown as Spanned | undefined\n if (declaration && declaration.line.start - 1 > at.line) continue\n seen.add(binding.name)\n const type = analysis.types.bindingType.get(binding.id)\n items.push({\n label: binding.name,\n kind: kindOf(type, binding.kind),\n detail: type ? formatType(type) : undefined,\n // Locals before globals, and globals before library names.\n sortText: `${binding.isBuiltin ? 2 : binding.kind === \"global\" ? 1 : 0}${binding.name}`,\n })\n }\n for (const keyword of KEYWORDS) {\n items.push({ label: keyword, kind: CompletionItemKind.Keyword, sortText: `3${keyword}` })\n }\n return items\n}\n\nfunction memberItem(name: string, type: Type, readonly?: boolean): CompletionItem {\n const signatures = signaturesOf(type)\n if (signatures.length) {\n return {\n label: name,\n kind: CompletionItemKind.Method,\n detail: signatureLabel(signatures[0]).label,\n insertText: `${name}($0)`,\n insertTextFormat: InsertTextFormat.Snippet,\n }\n }\n return {\n label: name,\n kind: CompletionItemKind.Field,\n detail: `${readonly ? \"readonly \" : \"\"}${formatType(type)}`,\n }\n}\n\nfunction kindOf(type: Type | undefined, bindingKind: string): CompletionItemKind {\n if (type && signaturesOf(type).length) return CompletionItemKind.Function\n if (bindingKind === \"param\" || bindingKind === \"self\") return CompletionItemKind.Variable\n return CompletionItemKind.Variable\n}\n\n/** Is the cursor inside a type annotation? Every type node's name ends in\n * `TypeNode`, plus the couple that do not. */\nfunction inTypePosition(path: readonly Spanned[]): boolean {\n return path.some(n =>\n !!n.type && (n.type.endsWith(\"TypeNode\") || n.type === \"TypeReference\"\n || n.type === \"TypeAliasStatement\" || n.type === \"ExportTypeAliasStatement\"\n || n.type === \"DeclareClassStatement\"),\n )\n}\n\nconst PRIMITIVES = [\n \"any\", \"unknown\", \"never\", \"nil\", \"boolean\", \"number\", \"string\", \"thread\", \"buffer\",\n]\n\n/** Keywords only a type position can hold. */\nconst TYPE_KEYWORDS = [\"keyof\", \"typeof\", \"infer\", \"extends\"]\n\n/** Keywords that only follow something particular: `as` / `satisfies` an\n * expression, `extends` a type parameter's name. Offered only there, so\n * ordinary code is not littered with them. */\nfunction contextKeywords(before: string): CompletionItem[] {\n const keyword = (name: string): CompletionItem => ({\n label: name,\n kind: CompletionItemKind.Keyword,\n sortText: `3${name}`,\n })\n // `function f<K |`, `type Box<T |`\n if (/<\\s*[A-Za-z_]\\w*(?:\\s*,\\s*[A-Za-z_]\\w*)*\\s+$/.test(before)) return [keyword(\"extends\")]\n // Something an expression can end with, on this line: `x |`, `f() |`.\n if (/[)\\]}\"'`\\w][^\\S\\n]+$/.test(before)) return [keyword(\"as\"), keyword(\"satisfies\")]\n return []\n}\n\nconst KEYWORDS = [\n \"const\", \"let\", \"function\", \"return\", \"if\", \"then\", \"elseif\", \"else\", \"end\",\n \"for\", \"in\", \"while\", \"do\", \"repeat\", \"until\", \"break\", \"continue\",\n \"type\", \"declare\", \"export\", \"import\", \"and\", \"or\", \"not\", \"true\", \"false\", \"nil\",\n]\n","/**\n * Completions that write a line at the top of the file when picked:\n *\n * - a name another file of the project exports adds\n * `import { name } from \"./path\"` (or joins an import of that file already\n * there);\n * - a Roblox service adds `const Players = game:GetService(\"Players\")`.\n *\n * The inserted line is an `additionalTextEdits` of the item, so nothing\n * happens until the item is actually accepted.\n */\nimport { readdirSync } from \"node:fs\"\nimport { dirname, join, relative, resolve } from \"node:path\"\nimport { CompletionItemKind, type CompletionItem, type Position, type TextEdit } from \"vscode-languageserver\"\nimport type { ImportStatement, LuautConfig, Statement } from \"luaut-parser\"\nimport { pathOfUri, samePath, type Analysis, type Analyzer } from \"../analysis.js\"\nimport { signaturesOf } from \"./members.js\"\n\n/** Names exported by the project's other files, as completions that import\n * them. `taken` are the names already in scope, which need no import. */\nexport function importItems(\n analyzer: Analyzer,\n analysis: Analysis,\n typePosition: boolean,\n taken: ReadonlySet<string>,\n): CompletionItem[] {\n const from = pathOfUri(analysis.uri)\n if (!from) return []\n const config = analysis.project.config\n const items: CompletionItem[] = []\n const offered = new Set<string>()\n for (const file of projectFiles(config?.directory ?? dirname(from))) {\n if (samePath(file, from)) continue\n const exports = analyzer.exportsAt(file)\n if (!exports || exports.partial) continue\n const names = typePosition ? [...exports.types.keys()] : [...exports.values.keys()]\n const specifier = specifierFor(from, file, config)\n for (const name of names) {\n // One offer per name: two files exporting it would be a guess.\n if (taken.has(name) || offered.has(name)) continue\n offered.add(name)\n const type = typePosition ? exports.types.get(name)?.type : exports.values.get(name)\n items.push({\n label: name,\n kind: typePosition\n ? CompletionItemKind.Interface\n : type && signaturesOf(type).length ? CompletionItemKind.Function : CompletionItemKind.Variable,\n labelDetails: { description: specifier },\n detail: `import { ${name} } from \"${specifier}\"`,\n sortText: `4${name}`,\n additionalTextEdits: [importEdit(analyzer, analysis, file, name, specifier, typePosition)],\n })\n }\n }\n return items\n}\n\n/** Roblox's services, as completions that declare them. */\nexport function serviceItems(analysis: Analysis, taken: ReadonlySet<string>): CompletionItem[] {\n const services = analysis.types.aliases.get(\"Services\")\n if (!services || services.kind !== \"object\") return []\n const at = serviceInsertion(analysis.program.body.statements)\n const items: CompletionItem[] = []\n for (const name of services.properties.keys()) {\n if (taken.has(name)) continue\n const line = `const ${name} = game:GetService(\"${name}\")`\n items.push({\n label: name,\n kind: CompletionItemKind.Module,\n labelDetails: { description: \"service\" },\n detail: line,\n sortText: `5${name}`,\n additionalTextEdits: [{ range: { start: at.position, end: at.position }, newText: `${line}\\n${at.gap}` }],\n })\n }\n return items\n}\n\n// ---------------------------------------------------------------- edits\n\nfunction importEdit(\n analyzer: Analyzer,\n analysis: Analysis,\n file: string,\n name: string,\n specifier: string,\n typePosition: boolean,\n): TextEdit {\n const statements = analysis.program.body.statements\n const imports = statements.filter((s): s is ImportStatement => s.type === \"ImportStatement\")\n\n // Join an import of the same file: `import { a } from \"./m\"` -> `{ a, name }`.\n const existing = imports.find(s =>\n !s.namespaceImport && (typePosition || !s.isTypeOnly) &&\n samePathOrUndefined(analyzer.resolveModulePath(analysis.uri, s.source.value), file))\n if (existing) {\n const last = existing.specifiers[existing.specifiers.length - 1]\n if (last) {\n const at = endOf(last)\n return { range: { start: at, end: at }, newText: `, ${name}` }\n }\n if (existing.defaultImport) {\n const at = endOf(existing.defaultImport)\n return { range: { start: at, end: at }, newText: `, { ${name} }` }\n }\n }\n\n // A new line after the last import, or before the first statement.\n const line = `import { ${name} } from \"${specifier}\"`\n const lastImport = imports[imports.length - 1]\n if (lastImport) {\n const at = { line: lastImport.line.end, character: 0 }\n return { range: { start: at, end: at }, newText: `${line}\\n` }\n }\n const first = statements[0]\n const at = { line: first ? first.line.start - 1 : 0, character: 0 }\n return { range: { start: at, end: at }, newText: first ? `${line}\\n\\n` : `${line}\\n` }\n}\n\n/** Where a service declaration goes: after the imports and the services\n * already declared at the top, or before the first statement. */\nfunction serviceInsertion(statements: readonly Statement[]): { position: Position; gap: string } {\n let last: Statement | undefined\n for (const statement of statements) {\n if (statement.type !== \"ImportStatement\" && !isServiceDeclaration(statement)) break\n last = statement\n }\n if (last) return { position: { line: last.line.end, character: 0 }, gap: \"\" }\n // Nothing declared at the top yet: a blank line before the code.\n const first = statements[0]\n return first\n ? { position: { line: first.line.start - 1, character: 0 }, gap: \"\\n\" }\n : { position: { line: 0, character: 0 }, gap: \"\" }\n}\n\n/** `const X = game:GetService(\"X\")` */\nfunction isServiceDeclaration(statement: Statement): boolean {\n if (statement.type !== \"VariableDeclaration\") return false\n const init = statement.init[0]\n return init?.type === \"MethodCallExpression\" && init.method.name === \"GetService\" &&\n init.object.type === \"Identifier\" && init.object.name === \"game\"\n}\n\nfunction endOf(node: { line: { end: number }; column: { end: number } }): Position {\n return { line: node.line.end - 1, character: node.column.end - 1 }\n}\n\nfunction samePathOrUndefined(a: string | undefined, b: string): boolean {\n return a !== undefined && samePath(a, b)\n}\n\n// ---------------------------------------------------------------- paths\n\n/** How `from` imports `target`: through a `paths` alias when the relative\n * path would have to climb out of the folder, else relatively. */\nfunction specifierFor(from: string, target: string, config: LuautConfig | undefined): string {\n const withoutExtension = (path: string): string => {\n const bare = path.replace(/\\\\/g, \"/\").replace(/\\.luaut$/, \"\")\n return bare.endsWith(\"/index\") ? bare.slice(0, -\"/index\".length) : bare\n }\n let relativePath = withoutExtension(relative(dirname(from), target))\n if (!relativePath.startsWith(\".\")) relativePath = `./${relativePath}`\n if (!relativePath.startsWith(\"../\") || !config) return relativePath\n\n for (const [pattern, targets] of Object.entries(config.paths)) {\n const star = pattern.indexOf(\"*\")\n if (star < 0) continue\n for (const targetPattern of targets) {\n const cut = targetPattern.indexOf(\"*\")\n if (cut < 0) continue\n const head = resolve(config.baseUrl, targetPattern.slice(0, cut))\n const rest = relative(head, target)\n if (rest.startsWith(\"..\") || resolve(head, rest) !== resolve(target)) continue\n return `${pattern.slice(0, star)}${withoutExtension(rest)}${pattern.slice(star + 1)}`\n }\n }\n return relativePath\n}\n\nconst FILE_LIMIT = 2000\nconst LISTING_TTL = 3000\nconst listings = new Map<string, { at: number; files: string[] }>()\n\n/** The project's `.luaut` modules — not definitions files, not\n * `node_modules`, not hidden folders. Listed at most every few seconds. */\nfunction projectFiles(root: string): string[] {\n const cached = listings.get(root)\n if (cached && Date.now() - cached.at < LISTING_TTL) return cached.files\n const files: string[] = []\n const walk = (directory: string, depth: number): void => {\n if (files.length >= FILE_LIMIT || depth > 12) return\n let entries\n try {\n entries = readdirSync(directory, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue\n const path = join(directory, entry.name)\n if (entry.isDirectory()) walk(path, depth + 1)\n else if (entry.name.endsWith(\".luaut\") && !entry.name.endsWith(\".d.luaut\")) files.push(path)\n if (files.length >= FILE_LIMIT) return\n }\n }\n walk(root, 0)\n listings.set(root, { at: Date.now(), files })\n return files\n}\n","/**\n * Signature help: the parameter list of the call the cursor sits inside.\n *\n * A call being typed is usually not yet a call — `add(1, ` has no argument\n * after the comma and no closing paren, and the parser drops the statement.\n * So, like completion, this analyzes a repaired copy of the text: the fewest\n * characters that make the call parse, tried in order.\n */\nimport type { Position, SignatureHelp, SignatureInformation } from \"vscode-languageserver\"\nimport type { TextDocument } from \"vscode-languageserver-textdocument\"\nimport type { Expression } from \"luaut-parser\"\nimport type { Analyzer, Analysis } from \"../analysis.js\"\nimport { containsPosition, pathAt, type Spanned } from \"../ast-utils.js\"\nimport { signaturesOf, signatureLabel } from \"./members.js\"\n\ninterface CallLike extends Spanned {\n type: \"CallExpression\" | \"MethodCallExpression\"\n arguments: Expression[]\n}\n\nexport function signatureHelp(\n analyzer: Analyzer,\n document: TextDocument,\n position: Position,\n): SignatureHelp | null {\n const source = document.getText()\n const offset = document.offsetAt(position)\n for (const repair of [\"\", \"nil\", \"nil)\", \")\"]) {\n const text = source.slice(0, offset) + repair + source.slice(offset)\n const analysis = analyzer.analyze(document.uri, -1, text)\n const found = helpAt(analysis, position)\n if (found) return found\n }\n return null\n}\n\nfunction helpAt(analysis: Analysis, position: Position): SignatureHelp | null {\n const path = pathAt(analysis.program, position, true)\n const call = [...path].reverse().find(\n n => n.type === \"CallExpression\" || n.type === \"MethodCallExpression\",\n ) as CallLike | undefined\n if (!call) return null\n\n const callee = call.type === \"CallExpression\"\n ? (call as unknown as { callee: Expression }).callee\n : (call as unknown as Expression)\n // For a method call the callee has no node of its own, so read the type of\n // the whole `obj:m` receiver path from the object plus the method name.\n const calleeType = call.type === \"CallExpression\"\n ? analysis.types.typeOf.get(callee)\n : methodType(analysis, call)\n\n const signatures = signaturesOf(calleeType, analysis.types.aliases)\n if (!signatures.length) return null\n\n // `:` supplies `self`, so the first written argument is the second param.\n const selfOffset = call.type === \"MethodCallExpression\" ? 1 : 0\n const written = activeArgument(call, position)\n\n const infos: SignatureInformation[] = signatures.map(signature => {\n const { label, parameters } = signatureLabel(signature)\n return { label, parameters: parameters.map(p => ({ label: p })) }\n })\n\n // Pick the overload that could still accept this many arguments.\n const wanted = written + selfOffset + 1\n let active = signatures.findIndex(s => s.params.length >= wanted || s.varargs)\n if (active < 0) active = 0\n\n return {\n signatures: infos,\n activeSignature: active,\n activeParameter: Math.min(\n written + selfOffset,\n Math.max(0, signatures[active].params.length - 1),\n ),\n }\n}\n\nfunction methodType(analysis: Analysis, call: CallLike): undefined | ReturnType<Analysis[\"types\"][\"typeOf\"][\"get\"]> {\n const object = (call as unknown as { object: Expression }).object\n const method = (call as unknown as { method: { name: string } }).method\n const objectType = analysis.types.typeOf.get(object)\n if (!objectType) return undefined\n return memberType(objectType, method.name, analysis)\n}\n\nfunction memberType(\n type: NonNullable<ReturnType<Analysis[\"types\"][\"typeOf\"][\"get\"]>>,\n name: string,\n analysis: Analysis,\n): ReturnType<Analysis[\"types\"][\"typeOf\"][\"get\"]> {\n if (type.kind === \"object\") return type.properties.get(name)?.type\n if (type.kind === \"intersection\") {\n for (const part of type.types) {\n const found = memberType(part, name, analysis)\n if (found) return found\n }\n }\n if (type.kind === \"genericRef\") {\n const alias = analysis.types.aliases.get(type.name)\n if (alias) return memberType(alias, name, analysis)\n }\n return undefined\n}\n\n/** Which argument the cursor is in — counted by which argument spans it, or\n * by how many end before it when the cursor is in the gap after a comma. */\nfunction activeArgument(call: CallLike, position: Position): number {\n const args = call.arguments\n for (let i = 0; i < args.length; i++) {\n if (containsPosition(args[i] as unknown as Spanned, position, true)) return i\n }\n let count = 0\n for (const arg of args as unknown as Spanned[]) {\n const before = arg.line.end - 1 < position.line\n || (arg.line.end - 1 === position.line && arg.column.end - 1 <= position.character)\n if (before) count++\n }\n return count\n}\n","/** Document symbols: the outline of a file. */\nimport { SymbolKind, type DocumentSymbol } from \"vscode-languageserver\"\nimport { formatType, type Identifier } from \"luaut-parser\"\nimport { bindingOfNode, type Analysis } from \"../analysis.js\"\nimport { toRange, walk, type Spanned } from \"../ast-utils.js\"\n\nexport function documentSymbols(analysis: Analysis): DocumentSymbol[] {\n const out: DocumentSymbol[] = []\n\n walk(analysis.program, node => {\n switch (node.type) {\n case \"FunctionDeclaration\":\n case \"FunctionDeclarationStatement\": {\n const name = functionName(node)\n if (name) out.push(symbol(name, SymbolKind.Function, node, detailOf(analysis, node)))\n break\n }\n case \"TypeAliasStatement\":\n case \"ExportTypeAliasStatement\": {\n // The alias name is an Identifier node here, a bare string on\n // a `declare` — take either.\n const named = (node as unknown as { name?: string | { name?: string } }).name\n const name = typeof named === \"string\" ? named : named?.name\n if (name) {\n const alias = analysis.types.aliases.get(name)\n out.push(symbol(name, SymbolKind.Interface, node, alias ? formatType(alias) : undefined))\n }\n break\n }\n case \"DeclareClassStatement\": {\n const name = (node as unknown as { name: Identifier }).name.name\n const superclass = (node as unknown as { superclass?: { base: string } }).superclass?.base\n out.push(symbol(name, SymbolKind.Class, node, superclass && `extends ${superclass}`))\n break\n }\n case \"VariableDeclaration\": {\n for (const target of (node as unknown as { names?: Spanned[] }).names ?? []) {\n const name = (target as unknown as { name?: string }).name\n if (name) out.push(symbol(name, SymbolKind.Variable, target))\n }\n break\n }\n }\n })\n\n return out\n}\n\nfunction functionName(node: Spanned): string | undefined {\n const named = node as unknown as {\n name?: string | { name?: string }\n target?: { base?: { name?: string }; path?: { name?: string }[]; method?: { name: string } }\n }\n if (typeof named.name === \"string\") return named.name\n if (named.name && typeof named.name === \"object\") return named.name.name\n if (named.target?.base?.name) {\n const path = (named.target.path ?? []).map(p => p.name).filter(Boolean)\n const dotted = [named.target.base.name, ...path].join(\".\")\n return named.target.method ? `${dotted}:${named.target.method.name}` : dotted\n }\n return undefined\n}\n\n/** A function declaration is a statement, not an expression, so its type\n * comes from the binding it creates rather than from `typeOf`. */\nfunction detailOf(analysis: Analysis, node: Spanned): string | undefined {\n const name = (node as unknown as { name?: Identifier }).name\n if (name && typeof name === \"object\") {\n const binding = bindingOfNode(analysis, name)\n const type = binding && analysis.types.bindingType.get(binding.id)\n if (type) return formatType(type)\n }\n return undefined\n}\n\nfunction symbol(name: string, kind: SymbolKind, node: Spanned, detail?: string): DocumentSymbol {\n const range = toRange(node)\n return { name, kind, detail, range, selectionRange: range }\n}\n","/**\n * Semantic highlighting, from the parser rather than from patterns.\n *\n * A TextMate grammar only sees characters, and in luaut a word's role depends\n * on where it stands: `extends` is a keyword inside a type and a plain name\n * elsewhere, `type Foo = ...` declares an alias while `type(x)` calls a\n * builtin, and `typeof x` in a type is a query while `typeof(v)` in code is a\n * call. Guessing that with regexes is how `extends (` came out coloured as a\n * function call. Here every token is classified from the same lexer and AST\n * the analyzer uses, so the colours cannot disagree with what the file means.\n *\n * The grammar still colours what is unambiguous — comments, strings, numbers,\n * reserved words — so the file looks right before the server answers.\n */\nimport type { SemanticTokens, SemanticTokensLegend } from \"vscode-languageserver\"\nimport { tokenize, isClassType, unknownType, type Binding, type Expression, type Identifier, type Token, type Type, type TypeNode } from \"luaut-parser\"\nimport { bindingOfNode, type Analysis } from \"../analysis.js\"\nimport { children, type Spanned } from \"../ast-utils.js\"\nimport { signaturesOf } from \"./members.js\"\n\nconst TOKEN_TYPES = [\n \"namespace\", \"type\", \"class\", \"typeParameter\", \"parameter\", \"variable\",\n \"property\", \"function\", \"method\", \"keyword\",\n] as const\nconst TOKEN_MODIFIERS = [\"declaration\", \"readonly\", \"defaultLibrary\", \"control\"] as const\n\ntype TokenType = typeof TOKEN_TYPES[number]\ntype TokenModifier = typeof TOKEN_MODIFIERS[number]\n\nexport const semanticTokensLegend: SemanticTokensLegend = {\n tokenTypes: [...TOKEN_TYPES],\n tokenModifiers: [...TOKEN_MODIFIERS],\n}\n\n/** Words the lexer reads as identifiers but the parser treats as keywords\n * where they stand in the right place. A word is only coloured as one if the\n * AST did not already claim it as a name. */\nconst SOFT_KEYWORDS = new Set([\n \"type\", \"declare\", \"class\", \"extends\", \"keyof\", \"infer\", \"readonly\", \"is\", \"asserts\", \"satisfies\", \"typeof\",\n \"default\",\n])\n\n/** Soft keywords that belong with `export` / `return` rather than with\n * `const` / `type`: marked `control`, which the editor extension maps to the\n * scope themes colour control keywords with. */\nconst CONTROL_KEYWORDS = new Set([\"default\"])\n\nconst PRIMITIVES = new Set([\"any\", \"unknown\", \"never\", \"nil\", \"boolean\", \"number\", \"string\", \"thread\", \"buffer\"])\n\ninterface Entry {\n line: number\n character: number\n length: number\n type: TokenType\n modifiers: readonly TokenModifier[]\n}\n\ntype Add = (at: { line: { start: number }; column: { start: number } }, length: number,\n type: TokenType, modifiers?: readonly TokenModifier[]) => void\n\nexport function semanticTokens(analysis: Analysis): SemanticTokens {\n // Keyed by start position: the first classification of a token wins, so\n // the AST's reading of a word takes precedence over the keyword fallback.\n const entries = new Map<string, Entry>()\n const add: Add = (at, length, type, modifiers = []) => {\n const line = at.line.start - 1\n const character = at.column.start - 1\n const key = `${line}:${character}`\n if (!entries.has(key)) entries.set(key, { line, character, length, type, modifiers })\n }\n\n let tokens: Token[] = []\n try {\n tokens = tokenize(analysis.source)\n } catch {\n // A lex error: only what the (empty) AST knows gets coloured.\n }\n const identifiers = tokens.filter(t => t.type === \"Identifier\")\n\n const ancestors: Spanned[] = []\n const walk = (node: Spanned): void => {\n classify(analysis, node, ancestors, identifiers, add)\n ancestors.push(node)\n for (const child of children(node)) walk(child)\n ancestors.pop()\n }\n walk(analysis.program)\n\n // Reserved words are left to the grammar: it already tells a control\n // keyword (`if`, `export`) from a declaration keyword (`const`), the way\n // themes colour them. Overriding them with one \"keyword\" type flattened\n // that. Only soft keywords need the parser's say-so.\n for (const token of tokens) {\n const value = (token as { value?: unknown }).value\n if (token.type !== \"Identifier\" || typeof value !== \"string\" || !SOFT_KEYWORDS.has(value)) continue\n add(token, value.length, \"keyword\", CONTROL_KEYWORDS.has(value) ? [\"control\"] : [])\n }\n\n return { data: encode([...entries.values()]) }\n}\n\ntype AnyNode = Spanned & Record<string, unknown>\n\nfunction classify(\n analysis: Analysis,\n spanned: Spanned,\n ancestors: readonly Spanned[],\n identifiers: readonly Token[],\n add: Add,\n): void {\n const node = spanned as AnyNode\n switch (node.type) {\n case \"Identifier\":\n identifier(analysis, node, ancestors[ancestors.length - 1] as AnyNode | undefined, add)\n return\n\n // Declarations whose node starts at the name.\n case \"IdentifierPattern\":\n case \"TypedIdentifier\":\n case \"FunctionParameter\": {\n const name = node.name\n // A destructured parameter has no name; its leaves are patterns.\n if (typeof name !== \"string\" || !name) return\n const binding = bindingOfNode(analysis, node)\n add(node, name.length, valueKind(analysis, binding), modifiersOf(binding, true))\n return\n }\n\n case \"TypeReference\": {\n const base = node.base as string\n const namespace = node.namespace as string | undefined\n const names = firstTokensWithin(identifiers, node, namespace ? 2 : 1)\n if (namespace && names[0]) add(names[0], namespace.length, \"namespace\")\n const baseToken = names[namespace ? 1 : 0]\n if (!baseToken) return\n if (!namespace && typeParameterInScope(ancestors, base)) {\n add(baseToken, base.length, \"typeParameter\")\n } else if (isClassType(analysis.types.aliases.get(namespace ? `${namespace}.${base}` : base) ?? unknownType)) {\n add(baseToken, base.length, \"class\")\n } else {\n add(baseToken, base.length, \"type\", PRIMITIVES.has(base) ? [\"defaultLibrary\"] : [])\n }\n return\n }\n }\n}\n\nfunction identifier(analysis: Analysis, node: AnyNode, parent: AnyNode | undefined, add: Add): void {\n const name = (node as unknown as Identifier).name\n const as = (type: TokenType, modifiers: readonly TokenModifier[] = []): void => add(node, name.length, type, modifiers)\n const typeOfNode = (n: unknown): Type | undefined => analysis.types.typeOfTypeNode.get(n as TypeNode)\n\n switch (parent?.type) {\n case \"MemberExpression\":\n if (parent.property === node) {\n return as(isFunction(analysis.types.typeOf.get(parent as unknown as Expression)) ? \"method\" : \"property\")\n }\n break\n case \"MethodCallExpression\":\n if (parent.method === node) return as(\"method\")\n break\n case \"TableExpression\":\n if (isFieldKey(parent, node)) return as(\"property\", [\"declaration\"])\n break\n case \"TypeAliasStatement\":\n case \"ExportTypeAliasStatement\":\n if (parent.name === node) return as(\"type\", [\"declaration\"])\n break\n case \"DeclareClassStatement\":\n if (parent.name === node) return as(\"class\", [\"declaration\"])\n break\n case \"DeclareStatement\":\n if (parent.id === node) return as(isFunction(typeOfNode(parent.valueType)) ? \"function\" : \"variable\", [\"declaration\"])\n break\n case \"TableTypeProperty\":\n if (parent.key === node) {\n return as(\n isFunction(typeOfNode(parent.valueType)) ? \"method\" : \"property\",\n parent.readonly ? [\"declaration\", \"readonly\"] : [\"declaration\"],\n )\n }\n break\n case \"FunctionTypeParameter\":\n if (parent.id === node) return as(\"parameter\", [\"declaration\"])\n break\n case \"GenericTypeParameter\":\n case \"InferTypeNode\":\n if (parent.id === node) return as(\"typeParameter\", [\"declaration\"])\n break\n case \"MappedTypeNode\":\n if (parent.parameterId === node) return as(\"typeParameter\", [\"declaration\"])\n break\n case \"ImportSpecifier\": {\n // A type-only import is a type, not an `any` value.\n const binding = bindingOfNode(analysis, node)\n if (binding?.declaredBy === \"type\") return as(\"type\", [\"declaration\"])\n const value = binding && analysis.types.bindingType.get(binding.id)\n if (analysis.types.aliases.has(name) && (!value || value.kind === \"any\")) return as(\"type\", [\"declaration\"])\n break\n }\n case \"ImportStatement\":\n // `import * as Module`\n if (parent.namespaceImport === node) return as(\"namespace\", [\"declaration\"])\n break\n case \"ExportSpecifier\":\n // `export { Size }` can name a type, which has no value binding.\n if (!bindingOfNode(analysis, node) && analysis.types.aliases.has(name)) return as(\"type\")\n break\n case \"FunctionName\":\n // `function a.b.c:d()` — `a` is a variable, `b`/`c` are properties,\n // `d` is the method being defined.\n if ((parent.path as unknown[]).includes(node)) return as(\"property\")\n if (parent.method === node) return as(\"method\", [\"declaration\"])\n break\n }\n\n const binding = bindingOfNode(analysis, node)\n // No binding: a name the analysis has no reading of (inside a syntax\n // error, say). Leave it to the grammar rather than guess.\n if (!binding) return\n as(valueKind(analysis, binding), modifiersOf(binding, binding.declarationNode === (node as unknown)))\n}\n\nfunction valueKind(analysis: Analysis, binding: Binding | undefined): TokenType {\n if (!binding) return \"variable\"\n if (binding.kind === \"param\" || binding.kind === \"self\") return \"parameter\"\n if (binding.declaredBy === \"namespace\") return \"namespace\"\n return isFunction(analysis.types.bindingType.get(binding.id)) ? \"function\" : \"variable\"\n}\n\nfunction modifiersOf(binding: Binding | undefined, isDeclaration: boolean): TokenModifier[] {\n const modifiers: TokenModifier[] = []\n if (isDeclaration) modifiers.push(\"declaration\")\n if (binding?.isConst) modifiers.push(\"readonly\")\n if (binding?.isBuiltin) modifiers.push(\"defaultLibrary\")\n return modifiers\n}\n\nfunction isFunction(type: Type | undefined): boolean {\n return signaturesOf(type).length > 0\n}\n\nfunction isFieldKey(table: AnyNode, key: AnyNode): boolean {\n const fields = table.fields as { type: string; key?: unknown }[]\n return fields.some(f => f.type === \"TableFieldNamed\" && f.key === key)\n}\n\n/** Is `name` a type parameter at this point — declared by an enclosing\n * generic list, a mapped type's key, or an `infer` in a conditional? */\nfunction typeParameterInScope(ancestors: readonly Spanned[], name: string): boolean {\n for (let i = ancestors.length - 1; i >= 0; i--) {\n const a = ancestors[i] as AnyNode\n if ((a.generics as { name: string }[] | undefined)?.some(g => g.name === name)) return true\n if (a.type === \"MappedTypeNode\" && a.parameter === name) return true\n if (a.type === \"ConditionalTypeNode\" && bindsInfer(a.extendsType, name)) return true\n }\n return false\n}\n\nfunction bindsInfer(node: unknown, name: string): boolean {\n if (!node || typeof node !== \"object\") return false\n if (Array.isArray(node)) return node.some(n => bindsInfer(n, name))\n const n = node as AnyNode\n if (n.type === \"InferTypeNode\" && n.name === name) return true\n return Object.values(n).some(v => bindsInfer(v, name))\n}\n\n/** The first `count` identifier tokens inside `node`'s span. Tokens are in\n * source order, so binary search to the start and read forward. */\nfunction firstTokensWithin(tokens: readonly Token[], node: Spanned, count: number): Token[] {\n let lo = 0\n let hi = tokens.length\n while (lo < hi) {\n const mid = (lo + hi) >> 1\n const t = tokens[mid]\n const before = t.line.start < node.line.start\n || (t.line.start === node.line.start && t.column.start < node.column.start)\n if (before) lo = mid + 1\n else hi = mid\n }\n const out: Token[] = []\n for (let i = lo; i < tokens.length && out.length < count; i++) {\n const t = tokens[i]\n const after = t.line.start > node.line.end\n || (t.line.start === node.line.end && t.column.start >= node.column.end)\n if (after) break\n out.push(t)\n }\n return out\n}\n\n/** LSP's relative encoding: each token as five integers relative to the\n * previous one. */\nfunction encode(entries: Entry[]): number[] {\n entries.sort((a, b) => a.line - b.line || a.character - b.character)\n const data: number[] = []\n let line = 0\n let character = 0\n for (const e of entries) {\n const deltaLine = e.line - line\n data.push(\n deltaLine,\n deltaLine === 0 ? e.character - character : e.character,\n e.length,\n TOKEN_TYPES.indexOf(e.type),\n e.modifiers.reduce((bits, m) => bits | (1 << TOKEN_MODIFIERS.indexOf(m)), 0),\n )\n line = e.line\n character = e.character\n }\n return data\n}\n","/**\n * The language server: LSP wiring only.\n *\n * Every handler is the same three steps — get the cached analysis for the\n * document, ask one feature module a question, hand back the answer. The\n * thinking lives in `features/`; nothing here knows about luaut.\n */\nimport {\n createConnection, DiagnosticSeverity, ProposedFeatures, TextDocuments, TextDocumentSyncKind,\n type Connection, type Diagnostic, type InitializeParams, type InitializeResult,\n} from \"vscode-languageserver/node\"\nimport { TextDocument } from \"vscode-languageserver-textdocument\"\nimport type { ConfigProblem } from \"luaut-parser\"\nimport { Analyzer, pathOfUri, samePath, uriOfPath, type Analysis, type AnalyzerOptions } from \"./analysis.js\"\nimport { importDefinition } from \"./features/imports.js\"\nimport { diagnostics } from \"./features/diagnostics.js\"\nimport { hover } from \"./features/hover.js\"\nimport { definition, references, highlights, prepareRename, rename } from \"./features/navigation.js\"\nimport { completion } from \"./features/completion.js\"\nimport { signatureHelp } from \"./features/signatureHelp.js\"\nimport { documentSymbols } from \"./features/symbols.js\"\nimport { semanticTokens, semanticTokensLegend } from \"./features/semanticTokens.js\"\n\nexport interface ServerOptions extends AnalyzerOptions {}\n\n/** Attach the luaut language server to a connection. Exported separately from\n * `startServer` so an editor extension can run it in-process over its own\n * transport, and so the tests can drive it without spawning anything. */\nexport function createServer(connection: Connection, options: ServerOptions = {}): void {\n const documents = new TextDocuments(TextDocument)\n // Imports and configs read open documents before disk, so they see\n // unsaved edits.\n const analyzer = new Analyzer({\n ...options,\n openDocument: path => documents.all().find(document => {\n const documentPath = pathOfUri(document.uri)\n return documentPath !== undefined && samePath(documentPath, path)\n }),\n })\n\n connection.onInitialize((_params: InitializeParams): InitializeResult => ({\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Incremental,\n hoverProvider: true,\n definitionProvider: true,\n referencesProvider: true,\n documentHighlightProvider: true,\n documentSymbolProvider: true,\n renameProvider: { prepareProvider: true },\n completionProvider: {\n // `.` and `:` open a member list; the rest of the time\n // completion is asked for as you type a word.\n // plus the characters that start or extend an import path.\n triggerCharacters: [\".\", \":\", \"\\\"\", \"'\", \"/\"],\n resolveProvider: false,\n },\n signatureHelpProvider: { triggerCharacters: [\"(\", \",\"], retriggerCharacters: [\",\"] },\n // Colours from the parser, not from patterns: whether a word is a\n // keyword, a type or a name depends on where it stands.\n semanticTokensProvider: { legend: semanticTokensLegend, full: true },\n },\n serverInfo: { name: \"luaut-language-server\" },\n }))\n\n // --- semantic highlighting ---------------------------------------------\n connection.languages.semanticTokens.on(p => {\n const document = documents.get(p.textDocument.uri)\n return document ? semanticTokens(analyzer.get(document)) : { data: [] }\n })\n\n // --- diagnostics -------------------------------------------------------\n /** Config files currently showing problems, so fixed ones get cleared. */\n let configUris = new Set<string>()\n\n const publishAll = (): void => {\n const problems = new Map<string, ConfigProblem[]>()\n for (const document of documents.all()) {\n const analysis = analyzer.get(document)\n void connection.sendDiagnostics({\n uri: document.uri,\n version: document.version,\n diagnostics: [...diagnostics(analysis), ...projectHint(analysis)],\n })\n // A problem is shown on the config (or sourcemap) it is about, once\n // however many files share that config.\n for (const problem of analysis.project.problems) {\n const uri = uriOfPath(problem.file)\n const list = problems.get(uri) ?? []\n if (!list.some(p => p.message === problem.message && p.line === problem.line)) list.push(problem)\n problems.set(uri, list)\n }\n }\n for (const [uri, list] of problems) {\n void connection.sendDiagnostics({ uri, diagnostics: list.map(problemDiagnostic) })\n }\n for (const uri of configUris) {\n if (!problems.has(uri)) void connection.sendDiagnostics({ uri, diagnostics: [] })\n }\n configUris = new Set(problems.keys())\n }\n\n const problemDiagnostic = (problem: ConfigProblem): Diagnostic => {\n const line = Math.max((problem.line ?? 1) - 1, 0)\n const character = Math.max((problem.column ?? 1) - 1, 0)\n // Underline to the end of the line: the option or entry the problem is about.\n const text = analyzer.readFile(problem.file)?.split(\"\\n\")[line] ?? \"\"\n const end = Math.max(text.replace(/\\r$/, \"\").trimEnd().length, character + 1)\n return {\n range: { start: { line, character }, end: { line, character: end } },\n severity: DiagnosticSeverity.Error,\n source: \"luaut\",\n code: \"config\",\n message: problem.message,\n }\n }\n\n /** A file no config covers gets no types at all, which is easy to miss —\n * so say so, once, at the top of the file. */\n const projectHint = (analysis: Analysis): Diagnostic[] => {\n const { project } = analysis\n if (project.fixed || project.config || !pathOfUri(analysis.uri)) return []\n return [{\n range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },\n severity: DiagnosticSeverity.Information,\n source: \"luaut\",\n code: \"no-config\",\n message: \"No luaut.config.json applies to this file, so no types are loaded — not even `print`. \"\n + \"Add one to this folder or a folder above: \"\n + \"{ \\\"types\\\": [], \\\"paths\\\": {}, \\\"sourceMap\\\": null }, \"\n + \"listing in `types` the type libraries the project has installed.\",\n }]\n }\n\n // Any change can affect every open file that imports the changed one, or\n // shares its config, so all of them are re-checked; unchanged ones come\n // straight from the cache.\n documents.onDidOpen(publishAll)\n documents.onDidChangeContent(publishAll)\n // A module, config, type library or sourcemap changed outside the editor.\n connection.onDidChangeWatchedFiles(publishAll)\n documents.onDidClose(e => {\n analyzer.forget(e.document.uri)\n void connection.sendDiagnostics({ uri: e.document.uri, diagnostics: [] })\n })\n\n // --- language features -------------------------------------------------\n const withDocument = <T>(uri: string, f: (document: TextDocument) => T, fallback: T): T => {\n const document = documents.get(uri)\n return document ? f(document) : fallback\n }\n\n connection.onHover(p => withDocument(\n p.textDocument.uri, d => hover(analyzer.get(d), p.position), null,\n ))\n\n connection.onDefinition(p => withDocument(\n p.textDocument.uri,\n d => {\n const analysis = analyzer.get(d)\n // Inside an import, the definition is in the other module.\n const across = importDefinition(analyzer, analysis, p.position)\n return across !== undefined ? across : definition(analysis, p.position)\n },\n null,\n ))\n\n connection.onReferences(p => withDocument(\n p.textDocument.uri,\n d => references(analyzer.get(d), p.position, p.context.includeDeclaration),\n [],\n ))\n\n connection.onDocumentHighlight(p => withDocument(\n p.textDocument.uri, d => highlights(analyzer.get(d), p.position), [],\n ))\n\n connection.onDocumentSymbol(p => withDocument(\n p.textDocument.uri, d => documentSymbols(analyzer.get(d)), [],\n ))\n\n connection.onPrepareRename(p => withDocument(\n p.textDocument.uri,\n d => {\n const prepared = prepareRename(analyzer.get(d), p.position)\n return prepared ? { range: prepared.range, placeholder: prepared.placeholder } : null\n },\n null,\n ))\n\n connection.onRenameRequest(p => withDocument(\n p.textDocument.uri, d => rename(analyzer.get(d), p.position, p.newName), null,\n ))\n\n connection.onCompletion(p => withDocument(\n p.textDocument.uri, d => completion(analyzer, d, p.position), [],\n ))\n\n connection.onSignatureHelp(p => withDocument(\n p.textDocument.uri, d => signatureHelp(analyzer, d, p.position), null,\n ))\n\n documents.listen(connection)\n connection.listen()\n}\n\n/** Run the server over stdio — the transport editors launch it with. */\nexport function startServer(options: ServerOptions = {}): void {\n createServer(createConnection(ProposedFeatures.all), options)\n}\n"],"mappings":";AACA,SAAS,YAAY,YAAY,aAAgE;AAWjG,SAAS,YAAY,KAAuB,SAA8C;AACtF,MAAI,CAAC,IAAK,QAAO,CAAC;AAClB,QAAM,WAAW,IAAI,SAAS,eAAe,QAAQ,IAAI,IAAI,IAAI,IAAI;AACrE,MAAI,CAAC,SAAU,QAAO,CAAC;AACvB,QAAM,QAAQ,SAAS,SAAS,UAAU,SAAS,QAAQ,CAAC,QAAQ;AACpE,QAAM,MAAgB,CAAC;AACvB,aAAW,QAAQ,OAAO;AACtB,UAAM,SAAS,KAAK,SAAS,eAAe,QAAQ,IAAI,KAAK,IAAI,KAAK,OAAO;AAC7E,QAAI,OAAO,SAAS,aAAa,OAAO,OAAO,UAAU,SAAU,QAAO,CAAC;AAC3E,QAAI,KAAK,OAAO,KAAK;AAAA,EACzB;AACA,SAAO;AACX;AAKO,SAAS,UACZ,MACA,SACA,OAAO,oBAAI,IAAU,GACb;AACR,MAAI,CAAC,QAAQ,KAAK,IAAI,IAAI,EAAG,QAAO,CAAC;AACrC,OAAK,IAAI,IAAI;AAEb,UAAQ,KAAK,MAAM;AAAA,IACf,KAAK,UAAU;AACX,YAAM,MAAgB,CAAC;AACvB,iBAAW,CAAC,MAAM,QAAQ,KAAK,KA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AkB;AAAA,IACzE,CAAC;AAAA,EACL,CAAC;AAED,aAAW,oBAAoB,OAAK;AAAA,IAChC,EAAE,aAAa;AAAA,IAAK,OAAK,WAAW,SAAS,IAAI,CAAC,GAAG,EAAE,QAAQ;AAAA,IAAG,CAAC;AAAA,EACvE,CAAC;AAED,aAAW,iBAAiB,OAAK;AAAA,IAC7B,EAAE,aAAa;AAAA,IAAK,OAAK,gBAAgB,SAAS,IAAI,CAAC,CAAC;AAAA,IAAG,CAAC;AAAA,EAChE,CAAC;AAED,aAAW,gBAAgB,OAAK;AAAA,IAC5B,EAAE,aAAa;AAAA,IACf,OAAK;AACD,YAAM,WAAW,cAAc,SAAS,IAAI,CAAC,GAAG,EAAE,QAAQ;AAC1D,aAAO,WAAW,EAAE,OAAO,SAAS,OAAO,aAAa,SAAS,YAAY,IAAI;AAAA,IACrF;AAAA,IACA;AAAA,EACJ,CAAC;AAED,aAAW,gBAAgB,OAAK;AAAA,IAC5B,EAAE,aAAa;AAAA,IAAK,OAAK,OAAO,SAAS,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO;AAAA,IAAG;AAAA,EAC7E,CAAC;AAED,aAAW,aAAa,OAAK;AAAA,IACzB,EAAE,aAAa;AAAA,IAAK,OAAK,WAAW,UAAU,GAAG,EAAE,QAAQ;AAAA,IAAG,CAAC;AAAA,EACnE,CAAC;AAED,aAAW,gBAAgB,OAAK;AAAA,IAC5B,EAAE,aAAa;AAAA,IAAK,OAAK,cAAc,UAAU,GAAG,EAAE,QAAQ;AAAA,IAAG;AAAA,EACrE,CAAC;AAED,YAAU,OAAO,UAAU;AAC3B,aAAW,OAAO;AACtB;AAGO,SAAS,YAAY,UAAyB,CAAC,GAAS;AAC3D,eAAa,iBAAiB,iBAAiB,GAAG,GAAG,OAAO;AAChE;","names":["dirname","resolve","formatType","resolve","dirname","formatType","formatType","identifier","type","binding","formatType","n","identifier","CompletionItemKind","formatType","isClassType","readdirSync","dirname","resolve","CompletionItemKind","dirname","CompletionItemKind","at","resolve","walk","readdirSync","isClassType","CompletionItemKind","PRIMITIVES","formatType","keyword","formatType","formatType","isClassType","PRIMITIVES","walk","typeParameterInScope","isClassType","binding","bindsInfer","n","DiagnosticSeverity","DiagnosticSeverity"]}