Skip to content
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: empty implement VSCode proposed API: registerMultiDocumentHighlightProvider #4172

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

bk1012
Copy link
Member

@bk1012 bk1012 commented Nov 18, 2024

Types

  • 🎉 New Features

Background or solution

Empty implement VSCode proposed API: registerMultiDocumentHighlightProvider

这个 API 依赖 monaco > 1.85 ,因此暂时空实现

cc @Ricbet

Changelog

Summary by CodeRabbit

  • 新功能

    • 引入了 MultiDocumentHighlight 类,用于处理多个文档的高亮显示。
    • 新增 registerMultiDocumentHighlightProvider 方法,允许注册多文档高亮提供者。
    • 新增 registerDocumentDropEditProviderregisterEvaluatableExpressionProvider 方法,提供文档编辑和可评估表达式的支持。
    • 添加 onDidChangeDiagnostics 事件,监控诊断信息的变化。
    • 扩展了 getDiagnostics 方法,支持获取所有资源的诊断信息。
  • 文档

    • 更新了 TypeScript 类型定义,包含新的多文档高亮相关功能。

@opensumi opensumi bot added the 🎨 feature feature required label Nov 18, 2024
Copy link
Contributor

coderabbitai bot commented Nov 18, 2024

Walkthrough

此拉取请求引入了多个与多文档高亮相关的功能。主要更改包括在 ext-types.ts 文件中添加了 MultiDocumentHighlight 类,该类封装了文档的高亮信息。此外,在 ext.host.language.ts 文件中新增了 registerMultiDocumentHighlightProvider 方法,用于注册多文档高亮提供者。还更新了多个 TypeScript 定义文件,以支持新的高亮功能和相关的 API 扩展。

Changes

文件路径 更改摘要
packages/extension/src/common/vscode/ext-types.ts 添加了 MultiDocumentHighlight 类,包含 urihighlights 属性及其构造函数。
packages/extension/src/hosted/api/vscode/ext.host.language.ts createLanguagesApiFactory 函数中添加了 registerMultiDocumentHighlightProvider 方法,允许注册多文档高亮提供者。
packages/types/vscode.d.ts 添加了对新 TypeScript 定义文件的引用路径。
packages/types/vscode/typings/vscode.language.d.ts 添加了 registerDocumentDropEditProviderregisterEvaluatableExpressionProvider 方法,新增 onDidChangeDiagnostics 事件,更新了 getDiagnostics 方法的重载,修改了 InlayHint 类的属性。
packages/types/vscode/typings/vscode.proposed.multiDocumentHighlightProvider.d.ts 新增 MultiDocumentHighlight 类及其构造函数,添加 MultiDocumentHighlightProvider 接口及其方法,新增 registerMultiDocumentHighlightProvider 函数。

Possibly related PRs

Suggested labels

🎨 feature

Suggested reviewers

  • Ricbet
  • hacke2

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
error Couldn't find any versions for "@opensumi/ide-dev-tool" that matches "workspace:*"


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (10)
packages/extension/src/hosted/api/vscode/ext.host.language.ts (1)

364-373: 空实现符合预期,等待 Monaco 1.85.0+

当前的空实现是合理的,因为该功能依赖于尚未发布的 Monaco 编辑器 1.85.0 版本。

建议添加更详细的 TODO 注释,说明具体实现计划:

 /**
  * @monaco-todo: wait until API is available in Monaco (1.85.0+)
  */
+ // TODO: 实现完整的多文档高亮提供者功能
+ // 1. 等待 Monaco 1.85.0+ 发布
+ // 2. 参考 VSCode 提案实现对应的接口
+ // 3. 添加必要的单元测试
packages/extension/src/common/vscode/ext-types.ts (1)

1462-1483: 代码实现良好,建议完善文档注释!

类的实现遵循了 TypeScript 最佳实践,结构清晰。建议在类级别添加 JSDoc 文档,说明该类的主要用途和使用场景。

建议添加如下类级别文档:

+/**
+ * 表示单个文档中的所有高亮信息。
+ * 作为 VSCode 多文档高亮 API 的一部分,用于在多个文档间同步高亮显示相关内容。
+ */
@es5ClassCompat
export class MultiDocumentHighlight {
packages/types/vscode/typings/vscode.proposed.multiDocumentHighlightProvider.d.ts (1)

53-53: 修正文档注释中的链接格式

注释中的链接 {@link languages.match score} 格式可能不正确。建议将链接修改为 {@link languages.match},以确保在生成文档时正确解析。

建议应用以下修改:

-		 * by their {@link languages.match score} and groups sequentially asked for document highlights.
+		 * by their {@link languages.match} score and groups sequentially asked for document highlights.
packages/types/vscode/typings/vscode.language.d.ts (7)

Line range hint 386-386: 建议:为 registerDocumentDropEditProvider 添加缺失的文档注释

在第386行,新增了 registerDocumentDropEditProvider 函数,但缺少相应的文档注释。为了提高代码的可读性和维护性,建议为该函数添加详细的文档注释,说明其用途、参数和返回值。


Line range hint 388-388: 建议:为 registerEvaluatableExpressionProvider 添加缺失的文档注释

在第388行,新增了 registerEvaluatableExpressionProvider 函数,但没有提供文档注释。为了帮助开发者理解该函数的作用,建议添加详细的文档注释,包括函数的功能描述、参数说明和返回值信息。


Line range hint 419-421: 建议:完善 InlayHintKind 枚举的文档注释

在第419至421行,定义了新的枚举类型 InlayHintKind,但缺少对枚举成员 TypeParameter 的说明。建议为每个枚举成员添加文档注释,解释其含义和使用场景,以提高代码的可读性。


Line range hint 445-474: 建议:为 InlayHintLabelPart 类及其成员添加文档注释

在第445至474行,引入了新的 InlayHintLabelPart 类,但缺少对类和属性的文档注释。为了提高代码的可维护性,建议为该类和其属性添加详细的文档注释,说明其用途和使用方法。


Line range hint 451-451: 优化类型声明

在第451行,属性 tooltip 的类型声明为 string | MarkdownString | undefined。由于 tooltip 已经被声明为可选属性(使用了 ? 标记),undefined 类型可以省略。建议修改如下:

- tooltip?: string | MarkdownString | undefined;
+ tooltip?: string | MarkdownString;

Line range hint 476-547: 建议:为 InlayHint 类及其成员添加文档注释

在第476至547行,新增了 InlayHint 类,但缺少对类、属性和方法的文档注释。为提高代码的清晰度和可读性,建议为该类及其成员添加详细的文档注释,帮助开发者理解其功能和用法。


Line range hint 529-530: 代码风格建议:属性声明格式统一

在第529和530行,属性 paddingLeftpaddingRight 的声明格式不统一。建议在属性声明之间添加空行,以提高代码的可读性,或将相似的属性合并,提高代码整洁度。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dedba74 and 3b98132.

📒 Files selected for processing (5)
  • packages/extension/src/common/vscode/ext-types.ts (1 hunks)
  • packages/extension/src/hosted/api/vscode/ext.host.language.ts (1 hunks)
  • packages/types/vscode.d.ts (1 hunks)
  • packages/types/vscode/typings/vscode.language.d.ts (1 hunks)
  • packages/types/vscode/typings/vscode.proposed.multiDocumentHighlightProvider.d.ts (1 hunks)
🔇 Additional comments (2)
packages/types/vscode.d.ts (1)

46-46: 新增的类型定义引用路径位置合适!

新增的 multiDocumentHighlightProvider 类型定义引用被正确地放置在其他提议的 API 类型定义之间,保持了良好的代码组织结构。

让我们验证一下 Monaco 编辑器的版本依赖:

✅ Verification successful

类型定义引用添加正确,实现完整且符合预期!

通过验证,我们发现:

  • multiDocumentHighlightProvider 的类型定义文件已完整实现,包含了所有必要的接口和类型声明
  • 该功能作为一个提议的(proposed)API 被正确引用
  • 虽然在主 package.json 中没有直接声明 Monaco 编辑器的版本依赖,但从 CHANGELOG.md 可以看到项目使用的是 Monaco 0.45.0 版本,足以支持此功能
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:检查项目中 Monaco 编辑器的版本要求

# 搜索 package.json 中的 Monaco 编辑器版本
echo "检查 package.json 中的 Monaco 编辑器版本要求:"
fd -t f "package.json" -x grep -l "monaco-editor" {} \; -exec cat {} \; | jq '.dependencies["monaco-editor"] // .devDependencies["monaco-editor"]'

# 搜索任何与 Monaco 版本相关的配置
echo "检查其他与 Monaco 版本相关的配置:"
rg -g '!node_modules' -g '!dist' "monaco.*version|version.*monaco" .

Length of output: 1417


Script:

#!/bin/bash
# 检查 package.json 中的 Monaco 编辑器版本要求
echo "检查 package.json 中的 Monaco 编辑器版本要求:"
cat package.json | jq '.dependencies["monaco-editor"] // .devDependencies["monaco-editor"]'

# 检查 Monaco 编辑器相关的依赖配置
echo "检查 Monaco 编辑器相关的依赖配置:"
rg -g '!node_modules' -g '!dist' '"monaco-editor".*version' .

# 检查 multiDocumentHighlightProvider 的实现
echo "检查 multiDocumentHighlightProvider 的实现:"
cat packages/types/vscode/typings/vscode.proposed.multiDocumentHighlightProvider.d.ts

Length of output: 3024

packages/extension/src/common/vscode/ext-types.ts (1)

1462-1483: 集成良好,符合现有代码组织结构!

新增的 MultiDocumentHighlight 类:

  • 正确复用了现有的 UriDocumentHighlight 类型
  • 保持了与文件中其他类似实现的一致性
  • 位置放置合适,便于维护

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 16.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 54.07%. Comparing base (dedba74) to head (3b98132).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
packages/extension/src/common/vscode/ext-types.ts 25.00% 3 Missing ⚠️
...tension/src/hosted/api/vscode/ext.host.language.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4172      +/-   ##
==========================================
- Coverage   54.08%   54.07%   -0.01%     
==========================================
  Files        1611     1611              
  Lines       97846    97852       +6     
  Branches    20031    20031              
==========================================
- Hits        52917    52915       -2     
- Misses      37325    37332       +7     
- Partials     7604     7605       +1     
Flag Coverage Δ
jsdom 49.64% <16.66%> (-0.01%) ⬇️
node 15.57% <16.66%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bk1012 bk1012 merged commit 5849361 into main Nov 18, 2024
13 checks passed
@bk1012 bk1012 deleted the feat/support-registerMultiDocumentHighlightProvider branch November 18, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎨 feature feature required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants