feat: #222 support sql run feature#224
Open
Cythia828 wants to merge 1 commit into
Open
Conversation
d720e6f to
8c98355
Compare
8c98355 to
871feae
Compare
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.
功能
#222 在
monaco-sql-languages中新增可插拔的 SQL 语句级 gutter 运行按钮,含语句拆分、主题样式、只读/dispose 处理验证截图
变更描述
功能概述
为 Monaco SQL 编辑器新增 「按语句运行」 能力:在每条 SQL 语句的首个可执行行前显示 gutter 运行图标(绿色三角),点击后通过回调把该语句交给业务侧执行。
核心新增模块
src/runStatementButton/1.
createRunStatementButton()(index.ts)主入口,负责:
readOnly配置变化并刷新图标onRun(context){ refresh, dispose }控制器可配置项包括:
languageId、onRun、自定义getStatementRanges、shouldShowRunButton、preprocessCode、主题色、hover 文案等。健壮性处理:
refreshRequestId+disposed防异步竞态onRun异步错误 catch 并打日志console.warndispose()时取消 debounce、清理 decoration 和事件2. SQL 语句拆分(
statementRanges.ts)拆分策略:
dt-sql-parser的splitSQLByStatement(按languageId选 parser)executableLineNumber:跳过 leading 空白、--行注释、多行/行内/* */块注释导出工具:
getStatementRangesByLanguage()— 内置拆分normalizeStatementRange(s)— custom resolver 结果归一化findFirstExecutableLine()— 找首个可执行行3. 类型定义(
types.ts)StatementRange:executableLineNumber(图标行)、text、startLineNumber等RunStatementContext:点击回调上下文(statement + editor + model)RunStatementButtonOptions/RunStatementButtonController4. 样式(
styles.ts)::before)vs-dark/vs/hc-black/hc-lightinjectRunStatementButtonStyles()按 className 注入/更新 style 标签其它改动
src/main.tsrunStatementButton模块src/common/utils.tsdebounce增加.cancel(),供 dispose 取消 pending refreshtest/all.jsrunStatementButton/*.test.jswebsite/src/App.tsxMap管理 controller;app unmount 时 disposeREADME.md/README-zh_CN.md预览地址
https://cythia828.github.io/monaco-sql-languages/