【问题标题】:How can I pass user settings to Debug adapter?如何将用户设置传递给调试适配器?
【发布时间】:2016-08-05 02:36:59
【问题描述】:

我正在为我的编程语言编写一个 vscode 调试适配器,但还没有弄清楚如何将配置选项传递给调试适配器。

帮助我。你能解释一下如何做下面这个荒谬的例子吗?我只是说清楚我要达到的目标。

应该怎么做才能传递“css.lint.zeroUnits”、“explorer.openEditors.visible”、“workbench.editor.showTabs”等变量

到一个调试适配器,以便它可以在启动时读取它们,一个调试适配器,比如这个:https://github.com/Microsoft/vscode-mock-debug/blob/master/src/mockDebug.ts

我想传递少量的配置变量,它们都是由我的扩展包定义的,沿着调试适配器。

【问题讨论】:

  • 我猜你想出了如何将简单类型传递给调试适配器(通过自定义 DebugConfigurationProvider 实例),这些类型出现在调试中 launchRequestattachRequestargs 参数中适配器。不幸的是,这不适用于对象或函数。

标签: visual-studio-code vscode-extensions


【解决方案1】:

如果您实现resolveDebugConfiguration,您可以将附加字段附加到传递给launchRequest/attachRequestargs 字段。我们在很多事情上都使用它in the Dart extension 来传递设置和事情:

    debugConfig.type = debugConfig.type || "dart";
    debugConfig.request = debugConfig.request || "launch";
    debugConfig.cwd = debugConfig.cwd || (folder && fsPath(folder.uri));
    debugConfig.args = debugConfig.args || [];
    debugConfig.vmAdditionalArgs = debugConfig.vmAdditionalArgs || conf.vmAdditionalArgs;
    debugConfig.vmServicePort = debugConfig.vmServicePort || (isChromeOS && config.useKnownChromeOSPorts ? CHROME_OS_VM_SERVICE_PORT : 0);
    debugConfig.dartPath = debugConfig.dartPath || path.join(this.sdks.dart!, dartVMPath);

这些来自args 字段的can be read(您可以使用接口来确保双方的字段匹配):

protected launchRequest(response: DebugProtocol.LaunchResponse, args: DartLaunchRequestArguments): void {
    if (!args || !args.dartPath || (this.requiresProgram && !args.program)) {

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-30
    • 1970-01-01
    • 2016-10-11
    • 1970-01-01
    相关资源
    最近更新 更多