Repository navigation
feat(plugin-grammar): 校验 TextMate 语法的 injections - #83
Merged
Merged
Conversation
编辑器的 TextMate 引擎开始运行语法自己的 injections(1lck/Lithe-IDEA#2112, PHP 的 text.html.php 靠它在 HTML 标签、脚本和样式里识别 <?php),所以 Core 按“接受的语法都能在编辑器里加载”的规则校验它们:injections 是以 scope 选择器为键的规则对象,最多 64 项,选择器 1–1024 字节,每条规则和其他规则 一样检查并计入 16384 条上限。injectionSelector 仍不运行、不检查。
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.
关联 Issue
类型
feat:
languages0 内的补充,Core 校验 TextMate 语法的injections改动
桌面端编辑器的 TextMate 引擎开始运行
injections,规则照搬 vscode-textmate 9.3.2。PHP 需要它:VS Code 的text.html.php把 HTML 包含进来,再用 injections 在 HTML 的标签、脚本和样式里识别<?php。Core 的规则是“接受的语法都能在编辑器里加载,且不会让它无限分配”。编辑器读
injections之后,Core 也要校验它(rust/crates/plugin-grammar/src/lib.rs):injections是对象grammar.injectionsMAX_INJECTIONS):编辑器每个扫描位置都要测试每个选择器,项数限定了每个位置多出的工作grammar.injectionsMAX_SELECTOR_BYTES);PHP 的选择器有 262 字节,超出include的 256 字节上限,所以单独设上限grammar.injections.<选择器>grammar.injections.<选择器>…injectionSelector仍不运行、不检查:编辑器没有把一个语法注入另一个语法的机制(VS Code 的injectTo)。运行语义写进契约:只有给文档分词的那个语法应用自己的
injections,被它包含的语法的不生效;起点更靠前的匹配胜出,起点相同时当前规则胜出,除非选择器带L:前缀。文档:
shared/plugins/contract/v1/README.md:语法可选字段加上injections,上限一条加上 64 项和 1024 字节,新增injections一条说明运行方式。shared/plugins/reference/domains/languages.md:中英两节同步。shared/plugins/reference/protocol-changelog.md:时间线 2026-11-17 加一行。没有新能力版本、没有新增宿主方法或通知,不需要宿主方法表。兼容:清单格式和能力版本不变。已发布的桌面端不运行
injections、忽略这个字段,带 injections 的插件语法照常加载,只是少了注入的着色。以前 Core 不检查的错误injections(如值不是对象)现在会被拒绝,这类语法在 VS Code 里也加载不了。验证
cargo test -p lithe-core --lib plugin_editor_resourcesinjections_are_checked_like_the_rules_they_add)cargo test -p lithe-plugin-grammar -p lithe-plugin-manifestcargo clippy -p lithe-plugin-grammar -p lithe-core --all-targets -- -D warnings、cargo fmt --all -- --checkscripts/rust-core/verify-rust-core-comments.shnode shared/plugins/scripts/verify-docs.mjs