Bazel plugin for Visual Studio Code

语法突出显示

  • Bazel Build Targets 树显示工作区中的构建包/目标
  • BUILD 文件中的 CodeLens 链接可通过单击目标直接启动构建或测试
  • Buildifier 集成以检查和格式化您的 Bazel 文件(需要安装 Buildifier)
  • tasks.json 的 Bazel Task 定义
  • 在构建期间调试 .bzl 文件中的 Starlark 代码(设置断点、逐步执行代码、检查变量等)在这里插入图片描述

配置扩展

此扩展将 Bazel 部分添加到 Visual Studio Code 中的扩展设置。如果您将 Bazel 安装在系统路径之外的位置,或者您希望在 IDE 中使用其他版本,则应将 Bazel:可执行文件设置设置为 Bazel 可执行文件的位置。

同样,如果您将 Buildifier 安装在系统路径之外的位置,则可以配置 Bazel:Buildifier 可执行文件设置。

安装 Buildifier 后,Visual Studio 代码中的“格式化文档”命令将使用该工具重新格式化 BUILD、WORKSPACE、.bzl 和 .sky 文件,并在您键入时显示来自这些文件的 lint 警告。默认情况下,此扩展不会在格式化期间自动修复 lint 警告(lint可用于描述在任何一种电脑程式语言中,用来标记原始码中有疑义段落的工具),但您可以通过启用 Bazel:Buildifier Fix on Format 设置来选择此功能。

使用单独的输出库

默认情况下,此扩展将使用默认输出库来运行查询。这将导致构建阻止查询,从而可能导致性能下降。在 Bazel 7.1 版之后,可以通过将 bazel.queriesShareServer 设置更改为 false 来安全地禁用此功能。在早期版本中,可以在将便利符号链接添加到 .bazelignore 后安全地禁用它,例如:
在这里插入图片描述

bazel-myreponame
bazel-bin
bazel-testlogs

使用 Starlark 调试器

目前,可以通过右键单击 Bazel 构建目标视图中的构建目标并选择“使用 Starlark 调试器构建目标”来使用 Starlark 调试器。这将在 Visual Studio Code 调试器内启动构建(输出将重定向到调试控制台窗格),并且它将在执行期间遇到任何断点时暂停。

当 Bazel 线程暂停时,您可以逐步执行 Starlark 代码、添加监视表达式,并通过在调试控制台的输入区域中键入任意语句来执行它们。

单击调试器中的“停止”按钮将终止正在调试的 Bazel 进程,从而允许您停止当前构建。但是,Bazel 服务器将继续运行。
在这里插入图片描述

Bazel tasks

Bazel tasks can be configured from the tasks.json using the following structure:

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Check for flakyness",
      "type": "bazel",
      "command": "test",
      "targets": ["${input:pickFlakyTest}"],
      "options": ["--runs_per_test=9"]
    }
  ],
  "inputs": [
    {
      "id": "pickFlakyTest",
      "type": "command",
      "command": "bazel.pickTarget",
      "args": {
        "query": "kind('.*_test', //...:*)",
        "placeHolder": "Which test to check for flakyness?"
      }
    }
  ]
}
Java Platform Extension (JPE) for Visual Studio Code is a plugin designed specifically to enhance the development experience with Java in the popular code editor, Visual Studio Code (VSCode). This extension provides various features and tools to streamline the process of writing, debugging, and testing Java code within the VSCode environment. Some key features of JPE for VSCode include: 1. **Syntax highlighting and code completion**: The extension ensures that your Java code is correctly formatted with syntax highlighting and provides intelligent code suggestions to save time. 2. **Integrated debugging**: It enables you to set breakpoints, step through code, inspect variables, and analyze exceptions, making it easier to debug Java applications. 3. **Project management**: JPE supports importing and managing Maven or Gradle projects, allowing developers to work with multi-module projects efficiently. 4. **Code refactoring**: Tools to refactor code automatically or manually, helping maintain clean and well-structured code. 5. **Code navigation**: Quick access to methods, classes, and package structures, facilitating efficient code exploration. 6. **JavaDoc support**: The extension facilitates generating and browsing JavaDoc documentation right from the editor. 7. **Extension Marketplace integration**: You can discover and install other related Java extensions, further customizing your development setup. To get started with JPE for VSCode, you would typically download and install the extension from the VSCode marketplace, then configure your project settings and dependencies if using a build tool like Maven or Gradle.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果Autosar

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值