-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support VSCode API: SnippetTextEdit #4154
Conversation
Walkthrough此拉取请求引入了对 Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (3)
packages/types/vscode/typings/vscode.editor.d.ts (1)
703-749
: 建议:考虑添加使用示例为了帮助开发者更好地理解如何使用 SnippetTextEdit,建议在类的文档注释中添加一个简单的使用示例。
建议在类注释中添加如下示例:
/** * Example usage: * ```typescript * const snippet = new SnippetString('console.log(${1:value});'); * const edit = SnippetTextEdit.insert(position, snippet); * ``` */packages/types/vscode/typings/vscode.d.ts (2)
Line range hint
90-107
: 重复定义了 WorkspaceFolder 接口
WorkspaceFolder
接口在代码中被定义了两次(行 90-107 和行 1448-1465),这可能导致类型冲突或编译错误。建议删除一个重复的定义以避免潜在的问题。Also applies to: 1448-1465
Line range hint
1181-1189
: 构造函数文档中的参数名称不匹配在
CustomExecution
类的构造函数文档中,@param
注释标记了错误的参数名称。当前文档注释为:@param process The [Pseudoterminal](#Pseudoterminal) to be used by the task to display output.实际上,构造函数的参数是
callback
,而非process
。请修正文档中的参数名称以保持一致。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
packages/extension/src/common/vscode/converter.ts
(2 hunks)packages/extension/src/common/vscode/ext-types.ts
(4 hunks)packages/types/vscode/typings/vscode.d.ts
(1 hunks)packages/types/vscode/typings/vscode.editor.d.ts
(1 hunks)
🧰 Additional context used
🪛 Biome
packages/extension/src/common/vscode/ext-types.ts
[error] 1300-1306: The enum declaration should not be const
Const enums are not supported by bundlers and are incompatible with the 'isolatedModules' mode. Their use can lead to import inexistent values.
See TypeScript Docs for more details.
Safe fix: Turn the const enum into a regular enum.
(lint/suspicious/noConstEnum)
🔇 Additional comments (10)
packages/types/vscode/typings/vscode.editor.d.ts (5)
703-711
: 文档注释清晰地说明了 SnippetTextEdit 的用途和行为
注释很好地解释了片段编辑可以作为普通文本编辑执行的情况,以及在多文件工作区编辑中的行为。
714-721
: 静态方法 replace 的实现符合预期
方法签名和文档注释都符合 VSCode API 的标准设计模式。
723-730
: 静态方法 insert 的实现符合预期
方法签名和文档注释都符合 VSCode API 的标准设计模式。
732-740
: 类属性定义清晰且文档完整
range 和 snippet 属性的类型定义和文档注释都很完整。
742-749
: 构造函数实现简洁明了
构造函数的参数类型和文档注释符合预期。
packages/extension/src/common/vscode/converter.ts (2)
419-427
: 代码实现清晰简洁
命名空间 SnippetTextEdit
的实现符合转换器模式,将 VSCode 的片段编辑类型正确转换为内部模型。
854-863
: 工作区编辑处理逻辑完善
代码正确处理了片段编辑类型,与其他编辑类型保持一致的处理模式,并妥善处理了文档版本。
packages/extension/src/common/vscode/ext-types.ts (3)
1306-1330
: 'SnippetTextEdit' 类的实现看起来正确。
新增的 'SnippetTextEdit' 类及其方法实现正确,符合预期功能。
1289-1295
: 'FileSnippetTextEdit' 接口定义合理。
新增的 'FileSnippetTextEdit' 接口定义正确,符合类型扩展的需求。
1383-1418
: 'WorkspaceEdit' 类的 'set' 方法成功支持了新的 'SnippetTextEdit' 类型。
'WorkspaceEdit' 类中的 'set' 方法已更新,能够正确处理 'SnippetTextEdit' 类型的编辑,增强了编辑操作的灵活性。
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4154 +/- ##
==========================================
- Coverage 54.12% 54.11% -0.02%
==========================================
Files 1598 1598
Lines 97740 97776 +36
Branches 20001 20024 +23
==========================================
+ Hits 52901 52907 +6
- Misses 37244 37271 +27
- Partials 7595 7598 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
packages/extension/src/common/vscode/ext-types.ts (1)
1299-1304
: 请说明为什么选择值 6 作为 Snippet 类型的枚举值建议添加注释说明为什么跳过了 4 和 5,直接使用 6 作为 Snippet 的枚举值。这有助于其他开发者理解这个设计决策。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/extension/src/common/vscode/ext-types.ts
(4 hunks)
🔇 Additional comments (4)
packages/extension/src/common/vscode/ext-types.ts (4)
1289-1295
: 代码结构清晰且符合规范!
FileSnippetTextEdit
接口定义完整,使用 readonly
修饰符确保了不可变性,属性类型定义准确。
1306-1330
: 实现完整且符合最佳实践!
SnippetTextEdit
类的实现:
- 包含了必要的类型检查方法
- 提供了便捷的工厂方法
- 构造函数参数验证合理
1383-1389
: 方法签名设计合理!
set
方法的重载签名设计:
- 支持了新的 SnippetTextEdit 类型
- 保持了与现有 TextEdit 用法的兼容性
- ESLint 规则处理得当
1394-1418
: 实现逻辑完善且健壮!
set
方法的实现:
- 正确处理了 TextEdit 和 SnippetTextEdit 两种类型
- 元数据处理保持一致性
- 类型检查严谨
41ef042
to
6ddde61
Compare
Types
Background or solution
Support VSCode API: SnippetTextEdit
Changelog
Summary by CodeRabbit
新功能
SnippetTextEdit
类,支持在编辑器中进行交互式的代码片段编辑。WorkspaceEdit
类,支持同时处理文本编辑和代码片段编辑,并允许关联元数据。文档
SnippetTextEdit
类的文档,明确了代码片段编辑的使用场景。