@@ -129,6 +129,7 @@ class PhpDebugSession extends vscode.DebugSession {
129129 response . body . supportsConfigurationDoneRequest = true ;
130130 response . body . supportsEvaluateForHovers = false ;
131131 response . body . supportsConditionalBreakpoints = true ;
132+ response . body . supportsFunctionBreakpoints = true ;
132133 response . body . exceptionBreakpointFilters = [
133134 {
134135 filter : 'Notice' ,
@@ -426,6 +427,56 @@ class PhpDebugSession extends vscode.DebugSession {
426427 } ) ;
427428 }
428429
430+ protected setFunctionBreakPointsRequest ( response : VSCodeDebugProtocol . SetFunctionBreakpointsResponse , args : VSCodeDebugProtocol . SetFunctionBreakpointsArguments ) : void {
431+ const connections = Array . from ( this . _connections . values ( ) ) ;
432+ response . body = { breakpoints : [ ] } ;
433+ // this is returned to VS Code
434+ let vscodeBreakpoints : VSCodeDebugProtocol . Breakpoint [ ] ;
435+ let breakpointsSetPromise : Promise < any > ;
436+ if ( connections . length === 0 ) {
437+ // if there are no connections yet, we cannot verify any breakpoint
438+ vscodeBreakpoints = args . breakpoints . map ( breakpoint => ( { verified : false , message : 'No connection' } ) ) ;
439+ breakpointsSetPromise = Promise . resolve ( ) ;
440+ } else {
441+ vscodeBreakpoints = [ ] ;
442+ // for all connections
443+ breakpointsSetPromise = Promise . all ( connections . map ( ( connection , connectionIndex ) =>
444+ // clear breakpoints for this file
445+ connection . sendBreakpointListCommand ( )
446+ . then ( response => Promise . all (
447+ response . breakpoints
448+ . filter ( breakpoint => breakpoint instanceof xdebug . CallBreakpoint )
449+ . map ( breakpoint => breakpoint . remove ( ) )
450+ ) )
451+ . then ( ( ) => Promise . all (
452+ args . breakpoints . map ( functionBreakpoint =>
453+ connection . sendBreakpointSetCommand ( new xdebug . CallBreakpoint ( functionBreakpoint . name , functionBreakpoint . condition ) )
454+ . then ( xdebugResponse => {
455+ // only capture each breakpoint once
456+ if ( connectionIndex === 0 ) {
457+ vscodeBreakpoints . push ( { verified : true , id : xdebugResponse . breakpointId } ) ;
458+ }
459+ } )
460+ . catch ( error => {
461+ // only capture each breakpoint once
462+ if ( connectionIndex === 0 ) {
463+ vscodeBreakpoints . push ( { verified : false , message : error . message } ) ;
464+ }
465+ } )
466+ )
467+ ) )
468+ ) ) ;
469+ }
470+ breakpointsSetPromise
471+ . then ( ( ) => {
472+ response . body = { breakpoints : vscodeBreakpoints } ;
473+ this . sendResponse ( response ) ;
474+ } )
475+ . catch ( error => {
476+ this . sendErrorResponse ( response , error ) ;
477+ } ) ;
478+ }
479+
429480 /** Executed after all breakpoints have been set by VS Code */
430481 protected configurationDoneRequest ( response : VSCodeDebugProtocol . ConfigurationDoneResponse , args : VSCodeDebugProtocol . ConfigurationDoneArguments ) : void {
431482 for ( const connection of Array . from ( this . _waitingConnections ) ) {
0 commit comments