-
Notifications
You must be signed in to change notification settings - Fork 405
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
Exception breakpoints #218
Conversation
@@ -977,10 +987,56 @@ export class ApexDebug extends LoggingDebugSession { | |||
this.myRequestService.connectionTimeoutMs = | |||
workspaceSettings.connectionTimeoutMs; | |||
break; | |||
case EXCEPTION_BREAKPOINT_REQUEST: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a request from the extension to the adapter for configuring an exception breakpoint.
} | ||
} | ||
break; | ||
case LIST_EXCEPTION_BREAKPOINTS_REQUEST: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a request from the extension to the adapter for a list of enabled exception breakpoints.
.withArg('--json') | ||
.build(), | ||
{ cwd: projectPath, env: RequestService.getEnvVars() } | ||
).execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLI command to create an ApexDebuggerBreakpoint object with for an exception type.
info: ExceptionBreakpointInfo | ||
): Promise<void> { | ||
const knownBreakpointId = this.exceptionBreakpointCache.get(info.typeref); | ||
if (knownBreakpointId && info.breakMode === 'never') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breakpoint service will delete a breakpoint if it exists in the cache and the user choses Never break
for the exception type.
if (knownBreakpointId && info.breakMode === 'never') { | ||
await this.deleteBreakpoint(projectPath, knownBreakpointId); | ||
this.exceptionBreakpointCache.delete(info.typeref); | ||
} else if (!knownBreakpointId && info.breakMode === 'always') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Breakpoint service will add a breakpoint if it doesn't exist in the cache and the user choses Always break
for the exception type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this logic a result of limitations with the CLI and updating the IsEnabled
attribute of an exception breakpoint? It seems that VS Code is becoming the system or record then. On the other hand, we are dealing with "short" lived debugging sessions anyway. Thus, a sync issue may just be worked around by killing and starting a new debug session.
"You can't modify Apex classes or triggers during an Apex Debugger session. Save your changes after you're done debugging." | ||
"You can't modify Apex classes or triggers during an Apex Debugger session. Save your changes after you're done debugging.", | ||
created_exception_breakpoint_text: 'Created exception breakpoint for %s.', | ||
removed_exception_breakpoint_text: 'Removed exception breakpoint for %s.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These messages appear in the Debug Console when there's an active debugger session and an exception breakpoint is added/removed.
@@ -14,5 +14,6 @@ | |||
"Produce diagnostic output. Instead of setting this to true you can list one or more selectors separated with commas. The 'all' selector enables very detailed output. Other selectors are 'protocol', 'variables', 'launch'", | |||
"configuration_title": "Salesforce Apex Debugger Configuration", | |||
"connection_timeout_ms_description": | |||
"Connection timeout for Apex Debugger API requests (in milliseconds)." | |||
"Connection timeout for Apex Debugger API requests (in milliseconds).", | |||
"exception_breakpoint_command_text": "Apex Debug: Configure Exceptions" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label for the command.
'salesforce.salesforcedx-vscode-apex' | ||
); | ||
if (sfdxApex && sfdxApex.exports) { | ||
const exceptionBreakpointInfos: ExceptionBreakpointItem[] = await sfdxApex.exports.getExceptionBreakpointInfo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extension gets a list of System and user-defined exception types from Apex language server.
const args: SetExceptionBreakpointsArguments = { | ||
exceptionInfo: breakpoint | ||
}; | ||
session.customRequest(EXCEPTION_BREAKPOINT_REQUEST, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a debugger session starts, add all exception breakpoints that were selected while without a debugger session.
cachedExceptionBreakpoints.keys() | ||
); | ||
} | ||
const processedBreakpointInfos = mergeExceptionBreakpointInfos( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create the quick pick list of exception types. Enabled breakpoints are listed first.
for (let i = breakpointInfos.length - 1; i >= 0; i--) { | ||
if (enabledBreakpointTyperefs.indexOf(breakpointInfos[i].typeref) >= 0) { | ||
breakpointInfos[i].breakMode = EXCEPTION_BREAKPOINT_BREAK_MODE_ALWAYS; | ||
breakpointInfos[i].description = `$(stop) ${nls.localize( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description will show an icon from https://octicons.github.com/icon/stop/ and Always break
if it's an enabled breakpoint.
@@ -31,5 +35,13 @@ async function getLineBreakpointInfo(): Promise<{}> { | |||
return Promise.resolve(response); | |||
} | |||
|
|||
async function getExceptionBreakpointInfo(): Promise<{}> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exposed API in salesforcedx-vscode-apex to retrieve a list of System and user-defined exception types.
@guw , this is a huge changelist. Take your time reviewing it. There's no scheduled release next week, so the latest we want to get this merged in is November 27th EOD. The release will be November 30th. @ruthemmanuelle , there's some UX text you can review in files named i18n.ts. Also a heads up to set aside some time to update https://github.com/forcedotcom/salesforcedx-vscode/tree/develop/packages/salesforcedx-vscode-apex-debugger. |
* | ||
* If ommitted, we will assume _message. | ||
*/ | ||
export const messages = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are labels shown in the command palette when selecting an exception. See .gif for an example.
Codecov Report
@@ Coverage Diff @@
## develop #218 +/- ##
===========================================
+ Coverage 80.31% 80.93% +0.61%
===========================================
Files 111 113 +2
Lines 4527 4637 +110
Branches 745 770 +25
===========================================
+ Hits 3636 3753 +117
+ Misses 735 725 -10
- Partials 156 159 +3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The messages look fine. I didn't review anything else.
What does this PR do?
This change allows a debugging user to add/remove exception breakpoints for System and user-defined exception types. The list of exception types are acquired from Apex language server. Configuring an exception breakpoint is done through the command palette.
Typical UX Flow
Apex Debug: Configure Exceptions
Notes
Apex Debug: Configure Exceptions
command is also available without an active debugger session. If the user tries to add an exception breakpoint without an active session, we automatically mark it as enabled and save it to be added when we detect a new debugger session.What issues does this PR fix or reference?
@W-4179085@