Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vscode's selected launch config for project launch and codelens run/debug #6813

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Dec 7, 2023

The issue solved here is that when the Project > Run|Debug (from project's context menu) or from main class' Code lenses is used, the extension does not use the vscode's selected Laucnh configuration properly.

The original code went throug all defined java+ launch configurations and extract settings from the first java+ config found. So if the user intentionally selected 2nd and later config in the UI selector, Project > Run or Run codelen didn't use the parameters in there, instead of parameters from the 1st (texually) config were passed to NBLS.

Sadly, vscode does not support reading the configuration selector, so it is read using a hack: a temporary DebugConfigurationProvider is registered, which captures the debugConfiguration passed to it by vscode platform - and then aborts the exetion by returning undefined (this is permitted by API documentation). Then it uses the configuration object and overrides values with data passed to the runDebug function.

When no java+ launch configurations are present in launch.json, vscode would display a QuickPick for the user - that's why the situation is tested at the start. In that case, a simple configuration is created and used as in the original code.

Since Run codelen is generated for all project configurations, the codelen needs to either

  • specify the configuration (= configuration name)
  • specify the default configuration (= '')
  • leave the config unspecified (the value in launch config is used)
    I've changed both the codelen and runDebug to handle that.

@sdedic sdedic added the VSCode Extension [ci] enable VSCode Extension tests label Dec 7, 2023
@sdedic sdedic added this to the NB21 milestone Dec 7, 2023
@sdedic sdedic self-assigned this Dec 7, 2023
@sdedic sdedic marked this pull request as ready for review December 8, 2023 06:27
Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To the degree I understand this code, makes sense. Some minor comments inline.

java/java.lsp.server/vscode/src/extension.ts Outdated Show resolved Hide resolved
java/java.lsp.server/vscode/src/extension.ts Outdated Show resolved Hide resolved
@sdedic sdedic force-pushed the vscode/select-run-config branch from b98b850 to d29a5ae Compare December 11, 2023 17:22
@sdedic
Copy link
Member Author

sdedic commented Dec 11, 2023

Squashed before merge.

@sdedic sdedic merged commit 409ff48 into apache:master Dec 12, 2023
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants