如果您实施resolveDebugConfiguration
,您可以将其他字段附加到args
传递给launchRequest
/的字段attachRequest
。我们在 Dart 扩展中使用它来传递设置和事物:
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
字段中读取(您可以使用接口来确保字段在两侧匹配):
protected launchRequest(response: DebugProtocol.LaunchResponse, args: DartLaunchRequestArguments): void {
if (!args || !args.dartPath || (this.requiresProgram && !args.program)) {