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

Honor debug stop from configuration providers #10999

Merged
merged 1 commit into from
Apr 18, 2022

Conversation

alvsan09
Copy link
Contributor

@alvsan09 alvsan09 commented Apr 6, 2022

What it does

Fixes: #10998

Debug configuration providers can indicate to stop debugging by
returning undefined or null on either of the functions

  • resolveDebugConfiguration or
  • resolveDebugConfigurationWithSubstitutedVariables

The vscode API
https://code.visualstudio.com/api/references/vscode-api#DebugConfigurationProvider
specifies different handling for undefined and null as follows:

"Returning the value 'undefined' prevents the debug session from
starting. Returning the value 'null' prevents the debug session from
starting and opens the underlying debug configuration instead."

This implementation focuses on passing the undefined or null
response from the extension to the debug session manager where the
indication from the extension is handled.

Signed-off-by: Alvaro Sanchez-Leon alvaro.sanchez-leon@ericsson.com

How to test

  1. Download the following extension and place it under your theia/plugins folder
    https://github.com/alvsan09/debug-activation-events/blob/master/on-debug-resolve-null.vsix
  2. Start theia
  3. Testing behavior for an extension returning undefined:
    From the command palette (Ctrl + shft + P) , type debug , note trailing space is needed.
    Select configuration named Create JavaScript Debug Terminal
    Verify that no debug session is started and that a single JavaScript Debug Terminal instance is created.
    This verifies the fix for issue: resolveDebugConfiguration returning 'undefined' or 'null' does not comply to vscode API #10998
  4. Testing behavior for an extension returning null:
    From the command palette (Ctrl + shft + P) , type debug , note trailing space is needed.
    Select configuration named Resolve config to null (this configuration is provided by the test extension loaded in step 1)
    Verify that no debug session is started and that the launch.json file is opened.

config_resolve_undefined_null

Review checklist

Reminder for reviewers

@alvsan09 alvsan09 force-pushed the asl/stop_from_debug_providers branch from e085336 to 917d913 Compare April 6, 2022 21:32
@alvsan09 alvsan09 added vscode issues related to VSCode compatibility debug issues that related to debug functionality labels Apr 6, 2022
packages/plugin/src/theia.d.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/plugin/node/debug/debug.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/plugin/node/debug/debug.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

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

The code looks good and the provided tests work. @vince-fugnitto mentioned VSCode's ProviderResult type, and I think it might make sense to introduce something similar in our packages/core/src/common/types.ts file to reduce the number of times we have to write | undefined | null?

@alvsan09 alvsan09 force-pushed the asl/stop_from_debug_providers branch from 1f29607 to 6eab3ff Compare April 12, 2022 20:41
@alvsan09
Copy link
Contributor Author

alvsan09 commented Apr 12, 2022

I think it might make sense to introduce something similar in our packages/core/src/common/types.ts file to reduce the number of times we have to write | undefined | null?]

Hi @colin-grant-work,
I introduced a new type under common so the result can be passed across all the way to the browser,

The new type is under a new commit so we can discuss this particular update separately!

I have updated all the related returns accordingly, let me know what you think !

@@ -130,3 +130,5 @@ export namespace ArrayUtils {
export function unreachable(_never: never, message: string = 'unhandled case'): never {
throw new Error(message);
}

export type ResultPromise<T> = Promise<T | undefined | null>;
Copy link
Member

Choose a reason for hiding this comment

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

@alvsan09 I would probably keep the same name ProviderResult unless you have a strong reason to deviate? I don't think ResultPromise would be a good name for this type.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we benefit from this type at all at them moment, I would remove it.

Copy link
Member

Choose a reason for hiding this comment

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

Specifically I don't think it's super useful to use for implementations, which is its main use right now.

Looking at VS Code they have a ProviderResult used in definitions, but they never mention it in implementations.

@@ -130,3 +130,5 @@ export namespace ArrayUtils {
export function unreachable(_never: never, message: string = 'unhandled case'): never {
throw new Error(message);
}

export type ResultPromise<T> = Promise<T | undefined | null>;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we benefit from this type at all at them moment, I would remove it.

packages/debug/src/browser/debug-session-manager.ts Outdated Show resolved Hide resolved
@alvsan09 alvsan09 force-pushed the asl/stop_from_debug_providers branch from 6eab3ff to 5b1e75b Compare April 13, 2022 21:51
@alvsan09
Copy link
Contributor Author

@colin-grant-work, @paul-marechal, @vince-fugnitto,
After offline discussions with Paul and Vince, there seems to be a preference to not introduce the new type,
so I have reset the tip of the branch to the previous commit (before the introduction of the new type),

Colin had already approved that commit, @vince-fugnitto and @paul-marechal any pending items before approving this PR?

Debug configuration providers can indicate to stop debugging by
returning `undefined` or `null` on either of the functions
- `resolveDebugConfiguration` or
- `resolveDebugConfigurationWithSubstitutedVariables`

The vscode API
https://code.visualstudio.com/api/references/vscode-api#DebugConfigurationProvider
specifies different handling for `undefined` and `null` as follows:

"Returning the value 'undefined' prevents the debug session from
starting. Returning the value 'null' prevents the debug session from
starting and opens the underlying debug configuration instead."

This implementation focuses on passing the `undefined` or `null`
response from the extension to the debug session manager where the
indication from the extension is handled.

Signed-off-by: Alvaro Sanchez-Leon <alvaro.sanchez-leon@ericsson.com>
@alvsan09 alvsan09 force-pushed the asl/stop_from_debug_providers branch from 5b1e75b to 4214de2 Compare April 13, 2022 22:09
@alvsan09
Copy link
Contributor Author

Re-based to latest master

@colin-grant-work
Copy link
Contributor

My approval stands, with or without the additional type. 👍

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

LGTM!

@alvsan09 alvsan09 merged commit e6b57ba into master Apr 18, 2022
@alvsan09 alvsan09 deleted the asl/stop_from_debug_providers branch April 18, 2022 14:37
@github-actions github-actions bot added this to the 1.25.0 milestone Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug issues that related to debug functionality vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resolveDebugConfiguration returning 'undefined' or 'null' does not comply to vscode API
4 participants