繁体   English   中英

将jar添加到vscode调试扩展

[英]Adding jar to vscode debug extension

我们正在为ABL语言的DAP(调试器Adapater协议)提供一个可运行的jar,并且我们计划为该ABL DAP添加vscode扩展。

您能给我们提供一些文档还是给我们一些想法呢?

基本上,有两种方法可以使VS Code运行* .jar:

声明性的 :在扩展的package.json中,您可以将可执行文件注册为debuggers扩展点的一部分。 这是文档: https : //code.visualstudio.com/api/extension-guides/debugger-extension#anatomy-of-the-package.json-of-a-debugger-extension
这是来自node.js调试器的示例。 基本上可以使用以下属性:

  "runtime": "node",
  "runtimeArgs": [ "--arguments_passed_to_runtime" ],
  "program": "./dist/dap.js",
  "args": [ "--arguments_passed_to_program" ],

VS Code将调用的结果命令是这样的:

  node --arguments_passed_to_runtime ./dist/dap.js --arguments_passed_to_program

您不必在运行时和程序之间进行区分。 您可以使用“运行时”或“程序”,而忽略其他。

非声明性 :或者,您可以使用扩展代码来“计算”启动调试适配器时VS Code应该执行的命令。 请参阅此API: https : //github.com/microsoft/vscode/blob/4c3769071459718f89bd48fa3b6e806c83cf3336/src/vs/vscode.d.ts#L8797-L8816基于此API的以下代码片段展示了如何为abl创建DebugAdapterDescriptor调试器:

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: ExtensionContext) {

  vscode.debug.registerDebugAdapterDescriptorFactory('abl', {
      createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable | undefined): ProviderResult<DebugAdapterDescriptor> {
          return new vscode.DebugAdapterExecutable(
              "/usr/bin/java",
              [
                  join(context.extensionPath, "bin", "abl.jar")
              ],
              {
                  "cwd": "some current working directory path",
                  "env": {
                      "key": "value"
                  }
              }
          );
      }
  });
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM