How to call other extensions in a extension on vscode

这一生的挚爱 提交于 2021-02-08 04:48:51

问题


Here is my demand, I want to startup a debug session with some dynamic arguments. So I need to develop a extension that collect the arguments at first and register a debugger wrapper to vscode, after that I have to find a way to call the target extension's debugger with my arguments.

vscode.extensions.getExtension can get extension's informations and be able to active it only.

I found a command named "debug.startFromConfig" in vscode's sources, so I can use vscode.commands.executeCommand to execute it with my own configuration. But unfortunately I can't use vscode's api on a debug adapter, since it's not a extension host which just a single node programe.

The follow is what I expected, I have a debugger wrapper named asd

And I'm going to override some configurations of python debugger by my own debugger.(These codes following can't work, I explained that on above)

After that I can run my custom debugger to call the python debugger


回答1:


Why are you not using the official startDebugging extension API? Please see https://github.com/microsoft/vscode/blob/31221e62995c7040400051c2353c3c7c8b303c16/src/vs/vscode.d.ts#L8874.

Alternatively you could register a DebugConfigurationProvider for the debug types you are interested in and intercept the "resolveDebugConfiguration" method in order to adapt the launch configuration dynamically. Please see https://github.com/microsoft/vscode/blob/31221e62995c7040400051c2353c3c7c8b303c16/src/vs/vscode.d.ts#L8544.

Yes, vscode.d.ts is your friend...



来源:https://stackoverflow.com/questions/56441851/how-to-call-other-extensions-in-a-extension-on-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!