vscode-java-debug
vscode-java-debug copied to clipboard
Allow 3rd-party extensions to contribute in-memory launch config
Currently, vscode-java-debug searches the .vscode/launch.json file for a launch config matching the classname+project name.
https://github.com/microsoft/vscode-java-debug/blob/415ae57296c10e9ffd2204ab66e22cb9d929259c/src/extension.ts#L450-L459
If none is found, a default config is built in memory:
https://github.com/microsoft/vscode-java-debug/blob/415ae57296c10e9ffd2204ab66e22cb9d929259c/src/extension.ts#L427-L433
I'd like the JBang extension to provide a custom in-memory config, where we can dynamically set the add-opens args for instance, to be able to keep in synch' with the JBang directives in the java file, rather than having to create/update .vscode/launch.json at some point.
Would be nice if vscode-java-debug allowed 3rd-party extension to contribue launch config participants, that, if they match, would then provide a custom in-memory config, if none was found on disk.
See the video at the 4'37" mark and https://twitter.com/fbricon/status/1698735665259626996 for context
cc @maxandersen
Just like what the editor "Run Java"/"Debug Java" button does, you can construct the config in memory and then use vscode.debug.startDebugging(...) API to invoke Java debugger.
https://github.com/microsoft/vscode-java-debug/blob/415ae57296c10e9ffd2204ab66e22cb9d929259c/src/extension.ts#L425-L439
I already have a "Run JBang" codelens, what I want is to make sure everything works with the "standard" Run button
Then you can use the vscode.debug.registerDebugConfigurationProvider("java", new JavaDebugConfigurationProvider()) API to register a debug configuration provider for the java id. This will enable you to implement the resolveDebugConfiguration(...) or resolveDebugConfigurationWithSubstitutedVariables(...) method, which can change the launch configuration dynamically. When VS Code launches a java debug session, it will invoke all the registered java debug configuration providers sequentially to resolve the launch configuration. However, the order of invocation may depend on the activation order of the extensions. To ensure that the Java debugger configuration provider is called first, you can register your configuration provider after the Java debugger is activated.
https://github.com/microsoft/vscode-java-debug/blob/415ae57296c10e9ffd2204ab66e22cb9d929259c/src/configurationProvider.ts#L72-L85
mm I'll have to look into it. Thanks