Repository navigation
feat: add same-file navigation and downloads and install-size badges - #4
Merged
Merged
Conversation
Go to definition and find references need to know where a global gets its value, and the scope analysis only recorded declarations and reads. ScopeAnalysis gains `writes`: identifiers assigned without being declared, that is the Identifier targets of `x = …` and the name of `function x()`. `function x.y()` and `function x:m()` only read `x`, so they are not writes; declaring identifiers stay in `declarations`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
textDocument/definition for .lua and .menu files, within the document. - src/server/syntax/navigation.ts (pure): targetAt() finds the variable under the cursor by binary search over the identifiers the scope analysis knows about, so keywords, field names and method names never match. The index is built once per parsed document and kept in a WeakMap, so it lives exactly as long as the parse cache entry. A cursor right after a name still selects it. - definitions(): a local goes to its declaring identifier; a global to every assignment to it in the document (the new scope `writes`), in document order. The Lua chunks of a .menu file share one global environment, so globals are matched across chunks; locals stay in their chunk. - No result (null) for the implicit `self` of `function a:m()`, for globals the document never assigns (standard library, game and EEex functions, other files) and for table fields, which would need type inference. - src/server/features/definition.ts follows the documentSymbols handler pattern; capability `definitionProvider`. Tests: unit tests for targetAt/definitions, two new original fixtures (navigation.lua, NAVIGATION.MENU) and an integration test through vscode.executeDefinitionProvider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
textDocument/references for .lua and .menu files, within the document, using the same matching as go to definition (navigation.ts): - a local: its declaring identifier and every use, in document order, including the implicit `self` of a method (which has no declaration); - a global: every use in every Lua chunk of the document. `context.includeDeclaration` is honored: for a local it adds the declaring identifier, for a global the assignments to it (the same locations go to definition returns). src/server/features/references.ts follows the existing handler pattern; capability `referencesProvider`. Unit tests cover shadowing, recursion, `self`, globals with and without declarations and .menu chunks; the integration test goes through vscode.executeReferenceProvider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
textDocument/prepareRename and textDocument/rename for .lua and .menu
files, for locals and for globals the document assigns.
src/server/syntax/rename.ts (pure) refuses, rather than producing code
that behaves differently, when:
- the cursor is not on a variable name, or is on the implicit `self`;
- the variable is a global the document never assigns: it is defined in
another file, the game or EEex, which a same-file rename cannot update;
- the code where the variable can occur has syntax errors (its chunk for
a local, any chunk for a global). Found while testing: error recovery
drops the unfinished call in `print(a`, so that use of `a` is not in
the tree and a rename would silently miss it;
- the new name is not a Lua name or is a reserved word, decided by the
lexer itself (`lex(newName)` must yield exactly one name token);
- the rename would change what any name refers to. The renamed text is
re-parsed and every identifier's binding (declaration, or global by
name) is compared with the original: renamed uses must keep their
declaration, every other identifier must be unchanged. This catches
capture by an inner local and hiding an outer local or a global used
in the renamed local's scope. Merging two globals is refused
explicitly, since both sides keep a global binding.
Refusals are ResponseError(RequestFailed) with a fixed English message
per reason (src/shared/protocol.ts). LSP declares no error data for
these requests, and vscode-languageclient 11 rethrows a failed
prepareRename as `new Error(error.message)` (lib/common/rename.js), so
the client middleware (src/client/renameRefusals.ts) recognizes a
refusal by its exact message and rethrows it through vscode.l10n.t().
Other editors show the English message. The 7 strings are translated
into all 14 locales (machine-produced, like the existing ones); a unit
test checks that every server message has a client translation key.
Capability: `renameProvider: { prepareProvider: true }` only when the
client announces `rename.prepareSupport`, otherwise `true`. Edits are
sent as versioned documentChanges when the client supports them, so a
stale edit is rejected instead of applied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
definitions() and references() asked, for each use of a global, whether any chunk of the document records it as a write: O(uses x chunks). On the game's UI.MENU (local only, never committed: 3,109 chunks, 12,542 variable identifiers) that made go to definition take 13-21 ms for a common global, and pushed rename of the most-used assigned global (`characters`, 364 uses) to 58 ms, above the ~50 ms event-loop budget of .claude/rules/language-server.md. Each use is now checked against the `writes` of its own chunk while the uses are collected. Medians of 15 runs on the same file: definition `characters` 21.34 ms -> 0.19 ms references `characters` 0.09 ms -> 0.14 ms (unchanged, noise) rename `characters` 57.92 ms -> 33.97 ms rename `currentID` 45.80 ms -> 32.22 ms Rename is now dominated by the re-parse of the renamed text (about 25 ms for this file), which the conflict check needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- README: feature list and the early-version note now cover go to definition, find references and rename within a file. - docs/editors/README.md: three rows in "What you get" with the LSP requests, and the scope of navigation for other editors (variables only; no table fields or goto labels; .menu globals shared, locals per block or script). - CLAUDE.md: project purpose line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… notes The downloads badge added later in this branch uses GitHub's total download count of all assets of all releases (the only figure the GitHub API offers; it is anonymous, so maintainers' own downloads cannot be told apart). Each release attached two assets, the VSIX and a `.vsix.sha256` file, so every checksum download would have counted as an extension download. The publish job now attaches the VSIX only and appends "**SHA-256** of `<file>`: `<hash>`" to the release notes, and prints it in the job log. No release exists yet, so no earlier count is affected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No badge service reports an extension's installed size for a VSIX distributed through GitHub Releases, so the release tooling computes it and commits it as shields.io endpoint data, .github/badges/install-size.json (initially "no release yet"). What is measured is what VS Code shows as "Size" in the extension's details, derived from its source at tag 1.143.1 (references in scripts/release/vsix.mts): - installing extracts every ZIP entry matching the regular expression `^extension` (zip.ts:388, extensionManagementService.ts:649). The prefix has no slash, so `extension.vsixmanifest` is installed too, as `.vsixmanifest`; - `metadata.size = computeSize(folder)` right after extraction (:657), before VS Code adds `__metadata` to package.json; - the editor shows ByteSize.formatSize(size) (files.ts:1603), units of 1024, e.g. "933.08KB". Checked with a real install (VS Code 1.143.1, --extensions-dir in a scratch folder): the recorded `__metadata.size` was 955479 bytes, and installedSize() of the same VSIX gives 955479. scripts/release/vsix.mts reads the ZIP central directory itself (EOCD, then name and uncompressed size per entry), so no dependency is added; ZIP64 and corrupt archives are rejected with a clear error. New command `cli.mts install-size --vsix <file> (--write | --check) [--notes <file>]`, used by: - release.yml `prepare`: after the bump, bundles and packages the VSIX as `publish` will (with --pre-release for that channel) and writes the JSON, which the release pull request commits; - release.yml `publish`: checks the JSON against the VSIX it publishes, and appends the exact byte count to the release notes; - ci.yml checks: on release/v* branches only, packages with the same flags (odd minor = pre-release) and checks. The ruleset requires branches to be up to date before merging, so the merged content is the checked content; if main moves, the error says how to regenerate. The check compares what the badge shows. shields.io rejects unknown keys in endpoint data (services/endpoint-common.js), so the exact byte count cannot live in the file; it is printed and put in the release notes. Dry run in a scratch clone (nothing pushed): stable 1.0.0 -> 955668 bytes "933.27KB", pre-release 1.1.0 -> 955737 bytes "933.34KB" (the pre-release flag is in the manifest, which is installed); --check passes for both with the CI packaging logic, and fails once the shown value changes (21 more README bytes). actionlint 1.7.12 passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Downloads: shields.io `github/downloads/<repo>/total`, the sum of the download counts of all assets of all releases. Since the VSIX is now the only asset of a release, that is the number of VSIX downloads. GitHub's API only offers anonymous per-asset counts, so maintainers' and collaborators' own downloads cannot be excluded; the README says so next to the installation steps. - Install size: shields.io endpoint badge reading .github/badges/install-size.json from main, which the Release workflow keeps equal to the size VS Code shows for the latest release. It reads "no release yet" until the first release. `vsce package` accepts both badges (img.shields.io is a trusted badge source for the README shipped in the VSIX). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
CI timing review (222e4fc): all green
Minimum integration at 2.3× the baseline: investigated, caused by the runner.
🤖 Generated with Claude Code |
This was referenced Oct 29, 2026
4Luke4
added a commit
that referenced
this pull request
Oct 29, 2026
CodeQL flagged the download code on this pull request (js/http-to-file-access and js/file-system-race at third_party/lua52/tarball.mts:35). The same code was already flagged in build.mts on main (alerts #2 and #4, open); moving it made the alerts count as new. Both findings were real: - the downloaded bytes were written to .cache/lua before their SHA-256 was checked, so unverified data reached the disk and was deleted only afterwards; - `existsSync` followed by `writeFileSync` raced with anything else creating or removing the file in between. Now the cache file is read directly (a missing file is ENOENT, no separate existence check), and a download is hashed in memory and written only when it matches the published SHA-256; a mismatch writes nothing. A cached file with the wrong checksum is still deleted with the same message. The source (URL, checksum, cache path, downloader) can be injected, so the new unit tests cover every path without network: download and cache, tampered download, verified cache hit, corrupt cache, and a failed download. Checked by hand: `build:wasm -- --check` and `lua-manual -- --check` pass, including with an empty .cache/lua (fresh download, byte-identical to the previously cached file). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4Luke4
added a commit
that referenced
this pull request
Oct 29, 2026
* refactor(wasm): share the verified Lua 5.2.4 tarball download Move the pinned tarball URL, its published SHA-256, the download into .cache/lua and the verification from build.mts into tarball.mts, so the Lua manual data generator (next commits) uses the same verified source instead of a second copy of the logic. tarball.mts throws instead of exiting, so each caller reports failures under its own annotation title. No behaviour change: `npm run build:wasm -- --check` still reports that third_party/lua52/dist matches a fresh build byte for byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build: convert the Lua 5.2 manual's HTML subset to Markdown plan.md requires help text that keeps the wording and formatting of the Lua 5.2 reference manual. Add a pure converter from the manual's HTML to Markdown (for hovers) and plain text (for clients without Markdown). It accepts exactly the HTML the library entries of chapter 6 use (inventoried from lua-5.2.4/doc/manual.html: p, pre, ul/li, code, em, b, a href="#…", a name, sup; entities · § – π < >, plus &, " and the © of the copyright line) and throws on anything else, so a manual that changes shape fails the generator instead of producing wrong text: - paragraphs keep their text; whitespace collapses as in HTML, also across element boundaries, and a non-breaking space stays one; - <pre> becomes a fenced block, verbatim; list items keep their nested code blocks and paragraphs; - links into the manual become absolute links to https://www.lua.org/manual/5.2/manual.html#…; - text Markdown would interpret (* _ [ ] < > & ~ | ` \ and a leading #, -, + or 1.) is escaped. Three constructs have no Markdown equivalent; hovers render Markdown without HTML in VS Code, and other clients may not render HTML at all: - <sup> becomes Unicode superscripts (2³², eˣ); - <em> inside <code> (`%<em>d</em>` in string.gsub) becomes an emphasized code span of its own: `%`*`d`*; - <em> inside <pre> (the placeholder `body` in the ipairs and pairs examples) keeps its text without emphasis. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build: generate the Lua 5.2 library reference from the official manual Add `npm run lua-manual`, which writes data/lua52/manual.json from lua-5.2.4/doc/manual.html in the SHA-256-verified tarball (the release of the embedded compiler). `--check` fails when the committed file differs from a fresh run; `--compare-online` audits the online manual. Only the libraries the engine opens are included (CLAUDE.md §7, IESDP "Engine Lua globals"): §6.1 basic functions (24 entries), §6.4 string, §6.5 table, §6.6 math, §6.7 bit32 and §6.10 debug, each with its module table, 106 entries in all. Coroutines, modules (`require`), io and os are left out. Each entry keeps the manual's heading verbatim (`string.format (formatstring, ···)`), its anchor, and its text as Markdown and plain text (previous commit). Links point to https://www.lua.org/manual/5.2/manual.html, the URL plan.md names. The generator fails, with the section and entry at fault, when a section, an entry heading or a module anchor is missing, an entry belongs to another library, or the HTML is outside the supported subset. Audit (`--compare-online`, 2026-10-29): the sections and all 106 entries generated from https://www.lua.org/manual/5.2/manual.html are identical to those from the tarball. The only difference is the copyright line: 2011–2015 in the tarball, 2011–2013 online (that page was last modified on 2019-08-29). The tarball stays the source: it is pinned and verifiable, and it is the newer text. Tests check the committed data: the provenance, the section list, the per-section counts, the absence of coroutine/io/os/package/require, and golden text for math.huge, math.exp, select, bit32.extract, table.sort, debug.sethook, collectgarbage, string.gsub and the string module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: check that the Lua manual data matches the official tarball New job "Lua 5.2 manual data is current" runs `npm run lua-manual -- --check`, so data/lua52/manual.json can only change together with the generator or the pinned tarball. It is cheap: - it runs only when scripts/lua-manual/, data/lua52/, third_party/lua52/tarball.mts or ci.yml change (new `manual` output of the `changes` job; every job runs when there is no usable base); - no `npm ci`: the generator uses only Node built-ins and `tar`; - 5-minute timeout. The Lua tarball now has its own cache, keyed by the hash of tarball.mts (which pins the URL and SHA-256), shared by this job and the `wasm` job. Before, it was stored inside the emsdk cache entry. The emsdk cache now holds only .cache/emsdk; its path changed, so the first run after this commit misses it once. Errors are reported as `::error title=Lua manual data::` annotations naming the file and the command that fixes it. Checked with actionlint 1.7.12 (shellcheck is not installed locally, so the run steps were not shell-linted). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(server): record names resolved through a local _ENV In Lua 5.2 a free name `x` means `_ENV.x` (manual §2.2). While a local, parameter or `for` variable named `_ENV` is visible, `x` is a field of that table, not of the global environment. Record such identifiers in the new `ScopeAnalysis.environmentFields`, so that hover does not describe `print` or `string` from the standard library when they can be anything. They stay in `globals` by name, so navigation, rename and symbols are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(server): index member names and declaration sites Hover needs two things the syntax layer did not provide yet: - members.ts: the field and method names used in expressions (`string.format`, `s:rep()`), sorted by offset, with the expression and chunk they belong to, and `memberAt` to find one by position. Names in `function a.b:c()` and table constructor keys define fields and are not included. - signatures.ts: the statement that declares or assigns each name (`local function f(…)`, `local x = …`, `function x(…)`, `x = …`), with the value in the same position, for describing variables. Both are built lazily once per parsed document (WeakMap, dropped with it), like the variable index of navigation.ts, on a new generic walker (walk.ts) over statements and expressions. `identifierAt`, the binary search behind `targetAt`, is now exported so variables and members share the rule that a cursor just after a name selects it. `parameterList` moves from symbols.ts to signatures.ts; outline details are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(server): localize server messages from the client's locale Hover will show a few labels of the server's own (maintainer decision: localized on the server, from `InitializeParams.locale`, so that every LSP client benefits, not only VS Code). The server runs outside VS Code and cannot use `vscode.l10n`, so: - l10n/server/messages.json (English) and messages.<locale>.json for the 14 VS Code display languages are bundled into the server by esbuild through JSON import attributes (checked with tsc, ESLint, Node's type stripping for the unit tests, and esbuild); - src/server/l10n.ts resolves the requested locale (exact match, else the bare language: `de-AT` → `de`; regional variants are never substituted, so `pt-PT` and `zh-Hans` get English), substitutes `{n}` placeholders, and falls back to English per key; - the list of locales moves from scripts/check-l10n.mts to src/shared/locales.ts, so the server and the check share it; - `npm run check-l10n` gains step 6 (each server table has exactly the English keys, with code spans and placeholders unchanged, and exists) and step 7 (every English key is used in src/server). Both were checked to fail on a missing file, a missing or changed key and an unused key. The tables are empty in this commit; hover adds its keys. .vscodeignore now ships only l10n/bundle.l10n*.json, which the client loads at run time; the server tables are already inside server.js (`vsce ls` and the CI allow-list are unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(server): resolve hover targets Decide what a hover describes, without rendering it yet. knowledge.ts loads what the server knows about names it does not see defined: - the Lua 5.2 manual entries (data/lua52/manual.json), with their section and a link into https://www.lua.org/manual/5.2/manual.html; - the engine's replacement of `print` (IESDP "Engine Lua globals", commit 38e7532: "Replacement for Lua's print, registered by the engine's Lua bootstrap", with no behaviour given); - EEex-Docs names and links (data/eeex/eeex-functions.json and game-lua-functions.json; no text, as EEex-Docs has no license). Game structures are C++ types that Lua code never names, so they are not looked up and not bundled. resolve.ts maps the name under the cursor to a target: - a local: its declaration and how it gets its value; - a global, shared by the chunks of a .menu file: the document's own first assignment wins (an EEex-Docs link is kept); otherwise the engine's `print` note, the manual, EEex-Docs, or a bare global. io, os, require and coroutine get no documentation: the engine does not open those libraries; - a field or method: `string.format`, `_G.string.format`, `("x"):rep()` (strings index the string table, manual §6.4), `C:AddGold()` and `C.AddGold`, `EEex_Options_Option.new`. Fields of locals and of tables the document builds get no hover, as does any name resolved through a local `_ENV`, and `_ENV` itself. `TargetHit` from navigation.ts now also carries the chunk index that targetAt already knew. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(server): render hovers in Markdown and plain text Turn a hover target into text, in the format the client asks for: - the name as Lua: a ```lua block in Markdown (`local function f(a, b, ...)`, `local g = function(c)`, `(parameter) a`, `(for variable) i`, `(global) function G(a)`), or the manual's heading verbatim (`string.format (formatstring, ···)`); - the manual text, verbatim (Markdown or plain text from data/lua52/manual.json); - the source: `Lua 5.2 Reference Manual, §6.4 – String Manipulation`, or the EEex-Docs section title (`EEex Functions`, `EE Game Lua Functions`), linked to the entry. For `print`, the manual text is replaced by a note that the engine replaces the function, linking IESDP's "Engine Lua globals" page. The server's own four strings (`parameter`, `for variable`, `global` and that note) are added to l10n/server/ in English and the 14 VS Code display languages (machine-produced, like the existing translations; review welcome). `npm run check-l10n` passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(notices): credit the Lua 5.2 manual when its text is bundled Hovers will quote the Lua 5.2 reference manual, whose copyright line reads "Freely available under the terms of the Lua license". When the esbuild metafiles show data/lua52/manual.json in a bundle, the notices gain a section with the manual's title, source, copyright line (read from the data file) and the Lua license text already kept in third_party/lua52/licenses/lua.txt. Nothing bundles the file yet, so THIRD_PARTY_NOTICES.md is unchanged (`npm run notices -- --check` passes); the hover commit regenerates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(server): add hover Register `textDocument/hover` and advertise `hoverProvider`. The handler follows the other features: it uses the shared parse cache, checks cancellation before its synchronous work, and logs and returns null on any error. It answers in the first format of the client's `hover.contentFormat` it can produce (Markdown or plain text; plain text when the client lists none), with the server messages of the client's `locale`, and gives the range of the name. Integration tests (original fixtures hover.lua and HOVER.MENU) cover the manual text and link of string.format, a local function, a parameter, a `for` variable, a global function, the print note, an EEex-Docs link, a shadowed `string`, no hover on a keyword, and a .menu global assigned in another chunk. THIRD_PARTY_NOTICES.md now credits the Lua 5.2 manual, which the server bundle quotes. Measured on the game's UI.MENU (588 KB, 16,425 names; local, not committed), Node 24.22.1, five runs: - first hover of a parsed document (builds the member index and the declaration sites): 4.7 ms; - each name after that: 0.09–0.11 ms median, 4.4 ms at worst, against the 50 ms budget; - loading the hover modules and their data: 14.7 ms, once at startup. Size: dist/server/server.js 420,851 → 662,479 bytes (manual text 81.4 KB, EEex-Docs names and links 146.7 KB, code and messages the rest); VSIX 273.1 → 308.5 KB; installed size 950.05 KB → 1.16 MB. Stripping the shared URL prefixes of the EEex-Docs links would save about 58 KB but change the data format the EEex sync workflows write, so it is not done here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: document hover - README: hover in the feature list and the early-version note (no longer "planned"). - Editor guide: the hover row in "What you get", and what other editors need: `hover.contentFormat` for Markdown, `locale` for the server's own words (and how a locale is matched). - CONTRIBUTING: layout (src/server/hover/, data/lua52/, l10n/server/), `npm run lua-manual`, server strings under Localization, and a section on the Lua 5.2 manual data (regenerate, --check, --compare-online). - CLAUDE.md: purpose line, layout and the lua-manual command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(server): do not quote the manual for library members the document redefines Found by the project review. The document's own definition already won over the libraries for globals (`string = {}`), but not for members: after `string.format = myFormat` or `function string.format() end`, hovering `string.format` still showed the manual's description, which no longer applies. The resolver now collects, once per parsed document, the `table.field` names the document assigns on global tables (`t.f = …`, `_G.t.f = …`, `function t.f()`, `function t:f()`; not on locals or fields of a local `_ENV`), and skips the manual entry for those members, including `("x"):rep()` when `string.rep` is redefined. Other members of the same library are still documented. UI.MENU timings are unchanged within noise: first hover 5.0 ms (was 4.7), median 0.09–0.10 ms, worst 4.9 ms (was 4.4), five runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(build): escape `!` in Markdown generated from the Lua manual Found by the project review. In Markdown, `!` directly before a link makes it an image (``). No entry of the manual has text ending in `!` before a link today, but the converter did not guard against it. `!` is now escaped in text like the other characters Markdown interprets. The only change to data/lua52/manual.json is in `assert` ("assertion failed\!"), which renders the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(wasm): cache the Lua tarball only after verifying it, without a race CodeQL flagged the download code on this pull request (js/http-to-file-access and js/file-system-race at third_party/lua52/tarball.mts:35). The same code was already flagged in build.mts on main (alerts #2 and #4, open); moving it made the alerts count as new. Both findings were real: - the downloaded bytes were written to .cache/lua before their SHA-256 was checked, so unverified data reached the disk and was deleted only afterwards; - `existsSync` followed by `writeFileSync` raced with anything else creating or removing the file in between. Now the cache file is read directly (a missing file is ENOENT, no separate existence check), and a download is hashed in memory and written only when it matches the published SHA-256; a mismatch writes nothing. A cached file with the wrong checksum is still deleted with the same message. The source (URL, checksum, cache path, downloader) can be injected, so the new unit tests cover every path without network: download and cache, tampered download, verified cache hit, corrupt cache, and a failed download. Checked by hand: `build:wasm -- --check` and `lua-manual -- --check` pass, including with an empty .cache/lua (fresh download, byte-identical to the previously cached file). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The next step from
plan.mdafter #3: navigation within a file (Go to Definition, Find All References, Rename Symbol). It is built on the scope analysis from #3, which was designed for this. The PR also adds two README badges: downloads and install size.Decisions taken with the maintainer before implementation:
.sha256asset is dropped and the checksum moves into the release notes.Commits (one concern each; review them one by one)
feat(server): record assignments in the scope analysisScopeAnalysis.writes: targets ofx = …and the name infunction x().function x.y()andx:m()only readx.feat(server): add go to definitionnavigation.ts.targetAt()binary-searches the identifiers the scope analysis knows about, so keywords, field names and method names never match. A local goes to its declaration; a global goes to every assignment in the document. In.menufiles globals are shared by all Lua chunks and locals stay in their own chunk. No result for the implicitself, for globals the file never assigns, or for table fields.feat(server): add find referencesincludeDeclaration.feat: add same-file renamerename.tsrefuses rather than changing behaviour (see below). Refusals areRequestFailedwith a fixed English message, localized into 14 languages by client middleware. Edits are versioned when the client supportsdocumentChanges.perf(server): find global assignments without scanning every chunkUI.MENU. A global lookup was O(uses × chunks): definition took 21 ms and rename 58 ms, over the ~50 ms budget. Now 0.19 ms and 34 ms.docs: document navigationci(release): attach only the VSIX and give its SHA-256 in the release notesci(release): measure the installed size of the VSIX for the README badgescripts/release/vsix.mts+cli.mts install-size; wired intoprepare,publishand release-branch CI.docs(readme): add downloads and install-size badgesWhen rename refuses
Rename refuses in these cases:
The cursor isn't on a variable.
The cursor is on the implicit
self.The global is never assigned in the file, so it is defined in another file, the game or EEex.
The new name isn't a Lua name, or is a reserved word. This is decided by the project's own lexer:
lex(newName)must give exactly one name token.The code the variable can occur in has syntax errors. Found while testing: error recovery drops the unfinished call in
print(a, so a rename would silently miss thata.The rename would change what any name refers to. The renamed text is re-parsed, and every identifier's binding is compared with the original. This catches:
Merging two globals is refused explicitly, since both sides keep a global binding.
Install size: what is measured, and how it was verified
The badge shows exactly the Size VS Code displays in the extension's details. This is derived from VS Code's source at tag
1.143.1, with file and line references inscripts/release/vsix.mts:^extension(zip.ts:388,extensionManagementService.ts:649). The prefix has no slash, soextension.vsixmanifestis installed too, as.vsixmanifest.metadata.size = computeSize(folder)runs right after extraction (:657), before VS Code adds__metadatatopackage.json.ByteSize.formatSize(size)(files.ts:1603): units of 1024, formatted like933.08KB.Checked against a real install (VS Code 1.143.1, isolated
--extensions-dir): VS Code recorded__metadata.size: 955479, andinstalledSize()on the same VSIX gives 955479.How the size stays correct:
preparewrites the JSON into the release PR.release/v*branches checks it, packaging with the same--pre-releaserule (odd minor). The ruleset requires branches to be up to date before merging, so what is merged is what was checked.publishchecks it against the exact VSIX it publishes and adds the exact byte count to the release notes.The check compares what the badge shows, which is rounded to 0.01 KB. shields.io rejects unknown keys in endpoint JSON (
services/endpoint-common.js), so the exact byte count can't be stored in the file; it goes into the release notes instead.How it was tested
Locally (Linux/WSL2, Node 24):
check-types;lint(0 warnings);test:unit(186 passing, up from 141);check-l10n.package, thennotices -- --check, thenvsce package+vsce ls. The VSIX allow-list is unchanged.npm test: 22 passing on both VS Code 1.91.0 and 1.143.1 (11 new).Navigation on the game's own
UI.MENU(local only; never committed; 3,109 chunks; 12,542 variable identifiers). Medians of 15 runs:characters, 364 uses)Release dry run in a scratch clone (nothing pushed):
prepare --channel stablegives 1.0.0, 955,668 bytes, shown as "933.27KB".--channel pre-releasegives 1.1.0, 955,737 bytes, shown as "933.34KB". The pre-release flag is stored in the manifest, which is installed.--checkpasses for both with the CI packaging logic. It fails once the displayed value changes (21 more README bytes).::errormessages: missing--vsix, both or neither of--write/--check, a file that isn't a ZIP.Badges:
vsce packageaccepts them in the shipped README.Bundle size:
Known limitations
gotolabels (the parser doesn't check label rules)..menufile that means any chunk, so one broken script inUI.MENUblocks renaming every global in the file. Definition and references still work, on a best-effort basis.vscode.l10n.t()returns its key, so they would pass even without the middleware. Wiring is covered indirectly: a unit test checks that every server message is a key in the exported bundle, andcheck-l10nchecks the bundle against thevscode.l10n.t()calls. A real non-English run would need a language pack, which--disable-extensionsexcludes.vscode-languageclientlogs those asRequest textDocument/rename failed.in the "IE Lua" output, without a notification.Checklist
npm run check-types,npm run lintandnpm run test:unitpassnpm test(integration) passes, if activation, commands, settings or the LSP wiring changedvscode.l10n.t()/package.nls.json, andnpm run check-l10npasses (7 new strings, 14 locales, machine-produced like the existing ones)CHANGELOG.mdanddocs/CHANGELOG.vsix.mdhave entries under[Unreleased](if users notice the change)🤖 Generated with Claude Code