Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A message's text is known only when nothing in it reads runtime input, and a library decides what its syntax means. A plugin now contributes `messageSyntax`: literal forms that decode to fixed text, and characters that start syntax. `Project.staticText` returns the text or nothing. One span-aware walk does the work. `renderMessageText` decodes the literals and replaces each placeholder a caller-supplied callback resolves, so a decoded literal cannot be read as a placeholder again. `resolveStaticText` is the strict form of the same walk, with no callback.
`{'@'}` and `\@` render `@`, so a message that uses them has fixed text.
A bare `@`, `{`, `}` or `|` is syntax instead, and a value with one is not
fixed text. The preset declares both halves, so core stays library-neutral.
`refactor.inline` replaces a translate call with the display-locale text when `Project.staticText` proves it needs no runtime input, refusing a call that passes an argument, a key that is not written at the call, and a context where a plain string does not fit. The text is escaped for the place it lands in. Hover, inlay hints and completion documentation read a value through the same walk, so all of them show the decoded text, and a param only fills a placeholder outside a literal.
The LSP reference lists every code action with what it writes, then the call shapes the inline action accepts or refuses and how the text is escaped. The VS Code page turns the two refactors into tasks. The plugin plan gains the message-syntax capability.
The reference listed four actions in one wide table and then explained only inline. Each action now has its own block with an example of what it writes, and the inline rules split into offered and refused, so no column repeats the same yes or no on every row. The extract example uses a full sentence: a single word with no space is not offered by the default rules.
Member
Author
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "726c0685a4279a61d157212f510588b0a47a78d9",
"result": {
"overallSummary": "Adds a `refactor.inline` LSP code action that replaces a translate call with its text. To make that safe, the core gains a message-syntax capability: a plugin can declare how a message value decodes to fixed text, and `Project.staticText` returns that text only when nothing in the message needs runtime input. The action is deliberately conservative: no arguments, no placeholders, no plurals, no linked messages, and only contexts where a plain string fits.",
"groups": [
{
"key": "core-static-text",
"label": "Core: static text resolution",
"summary": "New `MessageSyntax` plugin capability (literals + reserved characters) and `Project.staticText`, which returns the text a message renders only when no param, plural, linked message or undecoded syntax is left. `renderMessageText` is the permissive walk used for display; `resolveStaticText` is the strict variant the inline action depends on.",
"category": "core",
"filePaths": [
"packages/core/src/static-text.ts",
"packages/core/src/index.ts",
"packages/core/src/types/plugin.ts",
"packages/core/src/types/project.ts",
"packages/core/src/project/project.ts",
"packages/core/src/plugins.ts",
"packages/core/src/library.ts"
],
"critical": true,
"fileNotes": [
{
"path": "packages/core/src/static-text.ts",
"text": "Fails closed everywhere: overlapping literal spans, a placeholder left unresolved, or a reserved character outside a literal all return `undefined`, and an empty string is refused too. Reviewers should confirm that refusing empty values is intended (an empty translation then never offers an inline)."
},
{
"path": "packages/core/src/plugins.ts",
"text": "`reserved` is the union of every plugin's characters and literals are concatenated, so a project with two libraries reserves both character sets and will refuse more values than either library alone. That is the documented fail-closed choice, but it is easy to miss."
},
{
"path": "packages/core/src/types/plugin.ts",
"text": "New public capability types; the literal `find` returns spans in value order and is expected to be side-effect free."
}
],
"lineNotes": [
{
"path": "packages/core/src/project/project.ts",
"side": "additions",
"line": 1297,
"text": "`staticText` reads the merged registry syntax, not the config's preset, so the answer matches what `renderMessageText` shows elsewhere."
}
]
},
{
"key": "builtins-vue-i18n-literals",
"label": "Builtins: vue-i18n literal syntax",
"summary": "Adds `messageLiteral`, a hand-written scanner for vue-i18n's literal interpolation (`{'@'}`, `\\@`, `\\uXXXX`/`\\UXXXXXX`) that mirrors `@intlify/core`, and registers it with `reserved: '@{}|'` on the vue-i18n preset. This is what lets a message like `hello{'@'}example.com` count as static text while a bare `@`, `{` or `|` does not.",
"category": "core",
"filePaths": [
"packages/builtins/src/placeholders/index.ts",
"packages/builtins/src/presets/vue-i18n/index.ts"
],
"fileNotes": [
{
"path": "packages/builtins/src/placeholders/index.ts",
"text": "`literalEscape` deliberately skips an unknown escape or an out-of-range `\\U` code point instead of guessing, and maps surrogates to U+FFFD the way the compiler does; a stricter or looser reading here changes which messages qualify for inlining."
},
{
"path": "packages/builtins/src/presets/vue-i18n/index.ts",
"text": "`reserved: '@{}|'` is the load-bearing line: it is what makes a bare `|` (plural list) and a bare `@` (linked message) disqualify a value."
}
]
},
{
"key": "lsp-inline-action",
"label": "LSP: inline code action",
"summary": "Registers `refactor.inline` and implements it: pick the display-locale static text, decide whether the call sits somewhere a plain string can replace it, and escape for that context (JS string, quoted attribute with HTML entities, interpolation, SFC script). `fill.ts` is refactored from a string-rewriting helper into a `paramText` callback so the same core walk decodes literals before params are filled.",
"category": "api",
"filePaths": [
"packages/lsp/src/inline.ts",
"packages/lsp/src/server.ts",
"packages/lsp/src/fill.ts"
],
"critical": true,
"fileNotes": [
{
"path": "packages/lsp/src/inline.ts",
"text": "Context detection is heuristic text scanning (`before`/`after` on non-whitespace characters), not a parser: a call is inlinable only when it is the whole expression in a `{...}`/`{{...}}` or the whole quoted attribute value. Expect edge cases with unusual formatting or nested template syntax."
},
{
"path": "packages/lsp/src/fill.ts",
"text": "Behaviour change beyond the signature: the old helper skipped overlapping spans and `reference` syntaxes locally; now both live in `renderMessageText`/`paramText`, and the returned callback is re-evaluated per placeholder, so duplicates are no longer collapsed here."
},
{
"path": "packages/lsp/src/server.ts",
"text": "`localeValueText` now runs values through `renderMessageText`, so hover tables, completion docs and inlay hints show decoded literals instead of the raw value - a user-visible change beyond the new action."
}
],
"lineNotes": [
{
"path": "packages/lsp/src/server.ts",
"side": "additions",
"line": 987,
"text": "Accepting the call shape rests on this regex over the raw source between the key and the closing paren: anything but whitespace or a comma after the quoted key refuses the action. A key with an escape or a stray comment after the key would be refused (safe direction, but it can look like a missed case)."
},
{
"path": "packages/lsp/src/server.ts",
"side": "additions",
"line": 938,
"text": "New `flush` before locating: the action now reads fresh analysis instead of possibly stale state, unlike the pre-existing paths in this handler."
},
{
"path": "packages/lsp/src/inline.ts",
"side": "additions",
"line": 138,
"text": "Escaping differs per context, and the attribute case nests two layers: JS escaping first, then HTML entities for `&` and the attribute's own quote. Worth a careful read since a wrong layer produces source that compiles but renders differently."
}
]
},
{
"key": "tests",
"label": "Tests",
"summary": "Covers the three layers: core resolution rules and rendering, the vue-i18n decoder against `@intlify/core` as an oracle, and the LSP side with a table of accepted and refused call shapes plus unit tests for context detection and escaping.",
"category": "tests",
"filePaths": [
"packages/core/test/static-text.test.ts",
"packages/builtins/test/static-text.test.ts",
"packages/lsp/test/code-actions.test.ts",
"packages/lsp/test/inline.test.ts",
"packages/lsp/test/annotations.test.ts",
"packages/lsp/test/fill.test.ts"
],
"fileNotes": [
{
"path": "packages/lsp/test/code-actions.test.ts",
"text": "The `cases` table is the specification of what is offered; note the asymmetry it encodes - a call inside a larger expression is inlined in a `.ts` file but refused inside a Vue interpolation. Add a row here when the rules change."
},
{
"path": "packages/lsp/test/fill.test.ts",
"text": "Rewritten around `renderMessageText` + `paramText`; the assertions are the old `fillParams` ones, so it doubles as a regression check for the refactor."
}
]
},
{
"key": "docs",
"label": "Docs and plans",
"summary": "Documents the new action and the vocabulary it needs (literal, placeholder, static text, message syntax), plus plan and smoke-test updates. The accepted/refused tables in the LSP protocol reference are the readable version of the test matrix.",
"category": "docs",
"filePaths": [
"docs/content/2.surfaces/2.vscode.md",
"docs/content/4.presets/02.vue-i18n.md",
"docs/content/5.plugins/3.capabilities.md",
"docs/content/6.references/4.lsp-protocol.md",
"docs/content/6.references/6.glossary.md",
"docs/scripts/generate.ts",
"packages/zed/docs/e2e-smoke.md",
"plans/02-core.md",
"plans/03-plugins.md",
"plans/05-builtins.md",
"plans/07-lsp.md",
"plans/glossary.md"
],
"fileNotes": [
{
"path": "docs/scripts/generate.ts",
"text": "The same protocol section is duplicated here as an escaped template string, so a wording change has to be made in both this file and the generated markdown; a mismatch is silent."
},
{
"path": "plans/07-lsp.md",
"text": "Describes the rules more precisely than the user-facing docs (trailing comma, whole-expression requirement); it is the reference to check the implementation against."
}
]
},
{
"key": "snapshots",
"label": "API snapshots",
"summary": "Regenerated `tsnapi` snapshots that record the new exports and types. Mechanical; read the diff only to confirm no unrelated public API moved.",
"category": "other",
"filePaths": [
"test/__snapshots__/tsnapi/@x18n/builtins/placeholders.snapshot.d.ts",
"test/__snapshots__/tsnapi/@x18n/builtins/placeholders.snapshot.js",
"test/__snapshots__/tsnapi/@x18n/core/index.snapshot.d.ts",
"test/__snapshots__/tsnapi/@x18n/core/index.snapshot.js"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-13T20:31:47.207Z",
"model": "openai-compatible/opencode-go/deepseek-v4.1-flash",
"locale": "en"
}
} |
0froq
marked this pull request as ready for review
November 13, 2026 20:39
The capabilities page listed `messageSyntax` as a field and explained nothing, so a plugin author had no way to learn what `literals` and `reserved` mean. It now sits next to the placeholder syntaxes, where a library declares its own message syntax.
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.
Description
A translate call whose text is fixed now offers
refactor.inline. Choosing it replaces the whole call with the display-locale text.Core decides whether the text is fixed.
Project.staticTextreturns it only when nothing in the message reads runtime input, and a plugin can now declare the message syntax that makes that decision possible:{'@'}and\@in vue-i18n@ { } |, so a value with one is not fixed textEscaping depends on where the call sits. A script gets a JS string literal. A quoted attribute gets the attribute's other quote, with
&as&. No action is offered when the text would close a<script>or reopen a{{ }}interpolation.Hover, inlay hints and completion documentation read a value through
renderMessageTextnow. Before, hints and decorations ranfillParamson the raw value, and hover and completion showed the stored value. Neither decoded literals, sohello{'@'}example.comappeared as written everywhere.Not offered, on purpose:
v-tdirectiveExtract and ignore keep their behavior. The docs now introduce all four code actions
Test
pnpm lint && pnpm knip && pnpm test && pnpm typecheck && pnpm build, pluspnpm -C docs run generate --checkandpnpm lint:docs.packages/lsp/test/code-actions.test.tsholds aninline casestable, one row per call shape, with the title and the text it writes.packages/core/test/static-text.test.tscovers the text resolution.packages/lsp/test/annotations.test.tschecks the hint, the hover and the completion documentation on one vue-i18n message.The same server against the same fixture, published 0.1.14 versus this branch:
t('literal')hinthello{'@'}example.comhello@example.comt('literal')actionInline "hello@example.com" (en)t('plain')actionInline "Plain" (en)t('param')actiont('param')stays without an action in both, becauseHello {name}needs runtime input.