Skip to content

feat: 12-dialect TextMate syntax highlighting - #17

Merged
BryceQin merged 2 commits into
mainfrom
feat/syntax-highlighting
Oct 19, 2026
Merged

BryceQin merged 2 commits into
mainfrom
feat/syntax-highlighting

Conversation

@BryceQin

Copy link
Copy Markdown
Owner

Summary

  • 为全部 12 个已注册语言 ID(sql/hive/mysql/spark/flinksql/postgresql/bigquery/sqlite/starrocks/sqlserver/plsql/dameng)生成方言感知的 TextMate 语法高亮,打开文件即生效(渲染进程 tokenize,无新增 activationEvents)
  • 新增 src/grammar/(grammarBuilder + dialectGrammarConfigs)与 scripts/generate-grammars.ts:直接消费各方言 formatter 的 tokenizerOptions(关键字分类、引号规则、注释配置),零手工清单、零数据漂移(golden 测试保证)
  • 生成物 syntaxes/*.tmLanguage.json × 12 入库(192K),contributes.grammars 注册,generate-grammars 接入 vscode:prepublish / esbuild 脚本链
  • PRD:docs/prd/023-语法高亮功能.md(对应 017 规划 F-12,目标 v2.35.0)

Test plan

  • npx tsc --noEmit 通过
  • npx oxlint src 无告警
  • 新增 src/test/grammar.test.ts 19 用例全通过(结构/一致性/golden + vscode-textmate + vscode-oniguruma 真实 tokenize 冒烟:规则顺序、词边界、跨行注释/字符串、方言特有引号与占位符)
  • 相关测试子集(grammar/languages/dialectConsistency/lexer/configConsistency)367 用例通过
  • 生成幂等性验证:npm run generate-grammars 后 git diff 为空
  • npx vsce ls:12 份语法进包,textmate 测试引擎 devDeps 确认不进包
  • .sql 覆盖内置语法后的人工目检(明/暗主题,Developer: Inspect Editor Tokens and Scopes)——如不满意可删除 contributes.grammars 中 sql 条目回滚

🤖 Generated with Claude Code

BryceQin and others added 2 commits October 19, 2026 13:53
Generate dialect-aware TextMate grammars for all 12 registered language
IDs (sql/hive/mysql/spark/flinksql/postgresql/bigquery/sqlite/starrocks/
sqlserver/plsql/dameng). Highlighting activates on file open via the
renderer process - no extension activation, no new activationEvents.

- src/grammar/: grammarBuilder consumes each dialect formatter's
  tokenizerOptions directly (keyword classes, quote rules, comment
  config) - single source of truth, no hand-maintained keyword lists.
  Rule order faithfully mirrors Tokenizer.ts's battle-tested priority
  sequence (TextMate first-match-wins is isomorphic to it).
- scripts/generate-grammars.ts: CLI generator with oniguruma
  compatibility + regex validity validation; fails non-zero on bad data.
- syntaxes/*.tmLanguage.json x12: committed build artifacts (192K).
- Covers keywords (multi-word phrases first), data types, built-in
  functions (colored only when followed by "(" to avoid column-name
  false positives), TRUE/FALSE/NULL, numbers (hex/sci-notation),
  comments, strings incl. dialect forms (PG dollar-quoting, BigQuery
  triple quotes, Oracle q'' as cross-line begin/end structures),
  variables (@var, ${var}, :bind, &sub), parameter placeholders
  (?, :name, @PARAM, :1), operators (incl. <=>, ::, ->), delimiters.
- Adds a uniform AS-alias rule (PG/StarRocks keyword lists omit AS
  because the formatter handles aliases via identAlias post-processing).
- .sql now colored by our dialect grammar instead of the VSCode built-in
  (rollback = delete the sql entry in contributes.grammars).
- Tests: grammar.test.ts - 19 cases incl. real tokenization smoke tests
  via vscode-textmate + vscode-oniguruma (VSCode's own engine,
  devDependencies only, excluded from VSIX).
- generate-grammars wired into vscode:prepublish/esbuild chains;
  out/grammar/** added to .vscodeignore dead-code exclusions.

Co-Authored-By: Claude Code <noreply@anthropic.com>
- Add .npmrc with legacy-peer-deps: typescript@7 vs typescript-eslint
  peer range (>=4.8.4 <6.1.0) has been failing npm ci in CI since
  v2.32.1 - every CI run on main since then failed at the install step
  (releases were cut with red CI). This matches how the local
  node_modules was installed.
- Declare oxlint/oxfmt/tsx in devDependencies: scripts.lint,
  scripts.format:check, and the generate-* / esbuild chains invoke them,
  but they were never declared - the lint step could not run from a
  clean install. All are excluded from the VSIX via .vscodeignore
  (verified: 0 devDep files in vsce ls output).
- Apply oxfmt to package.json and the two PRD docs (the remaining 19
  format issues are pre-existing on main and untouched).

Co-Authored-By: Claude Code <noreply@anthropic.com>
@BryceQin
BryceQin merged commit 513b3f5 into main Oct 19, 2026
1 check passed
@BryceQin
BryceQin deleted the feat/syntax-highlighting branch October 20, 2026 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant