@@ -7,6 +7,8 @@ import * as nls from 'vscode-nls';
77import { Cdp } from '../cdp/api' ;
88import { DisposableList , IDisposable } from '../common/disposable' ;
99import { ILogger , LogTag } from '../common/logging' ;
10+ import { posInt32Counter , truthy } from '../common/objUtils' ;
11+ import { Base1Position } from '../common/positions' ;
1012import { getDeferred , IDeferred } from '../common/promiseUtil' ;
1113import { IRenameProvider } from '../common/sourceMaps/renameProvider' ;
1214import * as sourceUtils from '../common/sourceUtils' ;
@@ -50,7 +52,7 @@ export class DebugAdapter implements IDisposable {
5052 private _thread : Thread | undefined ;
5153 private _threadDeferred = getDeferred < Thread > ( ) ;
5254 private _configurationDoneDeferred : IDeferred < void > ;
53- private lastBreakpointId = 0 ;
55+ private breakpointIdCounter = posInt32Counter ( ) ;
5456 private readonly _cdpProxyProvider = this . _services . get < ICdpProxyProvider > ( ICdpProxyProvider ) ;
5557
5658 constructor (
@@ -92,7 +94,7 @@ export class DebugAdapter implements IDisposable {
9294 this . dap . on ( 'continue' , ( ) => this . _withThread ( thread => thread . resume ( ) ) ) ;
9395 this . dap . on ( 'pause' , ( ) => this . _withThread ( thread => thread . pause ( ) ) ) ;
9496 this . dap . on ( 'next' , ( ) => this . _withThread ( thread => thread . stepOver ( ) ) ) ;
95- this . dap . on ( 'stepIn' , ( ) => this . _withThread ( thread => thread . stepInto ( ) ) ) ;
97+ this . dap . on ( 'stepIn' , params => this . _withThread ( thread => thread . stepInto ( params . targetId ) ) ) ;
9698 this . dap . on ( 'stepOut' , ( ) => this . _withThread ( thread => thread . stepOut ( ) ) ) ;
9799 this . dap . on ( 'restartFrame' , params => this . _withThread ( thread => thread . restartFrame ( params ) ) ) ;
98100 this . dap . on ( 'scopes' , params => this . _withThread ( thread => thread . scopes ( params ) ) ) ;
@@ -107,16 +109,47 @@ export class DebugAdapter implements IDisposable {
107109 this . dap . on ( 'getPerformance' , ( ) =>
108110 this . _withThread ( thread => performanceProvider . retrieve ( thread . cdp ( ) ) ) ,
109111 ) ;
110- this . dap . on ( 'breakpointLocations' , params =>
111- this . _withThread ( async thread => ( {
112- breakpoints : await this . breakpointManager . getBreakpointLocations ( thread , params ) ,
113- } ) ) ,
114- ) ;
112+ this . dap . on ( 'breakpointLocations' , params => this . _breakpointLocations ( params ) ) ;
115113 this . dap . on ( 'createDiagnostics' , params => this . _dumpDiagnostics ( params ) ) ;
116114 this . dap . on ( 'requestCDPProxy' , ( ) => this . _requestCDPProxy ( ) ) ;
117115 this . dap . on ( 'setExcludedCallers' , params => this . _onSetExcludedCallers ( params ) ) ;
118116 this . dap . on ( 'saveDiagnosticLogs' , ( { toFile } ) => this . _saveDiagnosticLogs ( toFile ) ) ;
119117 this . dap . on ( 'setSourceMapStepping' , params => this . _setSourceMapStepping ( params ) ) ;
118+ this . dap . on ( 'stepInTargets' , params => this . _stepInTargets ( params ) ) ;
119+ }
120+
121+ private _breakpointLocations (
122+ params : Dap . BreakpointLocationsParams ,
123+ ) : Promise < Dap . BreakpointLocationsResult > {
124+ return this . _withThread ( async thread => {
125+ const source = this . sourceContainer . source ( params . source ) ;
126+ if ( ! source ) {
127+ return { breakpoints : [ ] } ;
128+ }
129+
130+ const possibleBps = await this . breakpointManager . getBreakpointLocations (
131+ thread ,
132+ source ,
133+ new Base1Position ( params . line , params . column || 1 ) ,
134+ new Base1Position (
135+ params . endLine || params . line + 1 ,
136+ params . endColumn || params . column || 1 ,
137+ ) ,
138+ ) ;
139+
140+ return {
141+ breakpoints : possibleBps
142+ . map ( bp => bp . uiLocations . find ( l => l . source === source ) )
143+ . filter ( truthy )
144+ . map ( bp => ( { line : bp . lineNumber , column : bp . columnNumber } ) ) ,
145+ } ;
146+ } ) ;
147+ }
148+
149+ private _stepInTargets ( params : Dap . StepInTargetsParams ) : Promise < Dap . StepInTargetsResult > {
150+ return this . _withThread ( async thread => ( {
151+ targets : await thread . getStepInTargets ( params . frameId ) ,
152+ } ) ) ;
120153 }
121154
122155 private _setSourceMapStepping ( {
@@ -194,7 +227,7 @@ export class DebugAdapter implements IDisposable {
194227 supportsSetVariable : true ,
195228 supportsRestartFrame : true ,
196229 supportsGotoTargetsRequest : false ,
197- supportsStepInTargetsRequest : false ,
230+ supportsStepInTargetsRequest : true ,
198231 supportsCompletionsRequest : true ,
199232 supportsModulesRequest : false ,
200233 additionalModuleColumns : [ ] ,
@@ -224,7 +257,7 @@ export class DebugAdapter implements IDisposable {
224257 ) : Promise < Dap . SetBreakpointsResult | Dap . Error > {
225258 return this . breakpointManager . setBreakpoints (
226259 params ,
227- params . breakpoints ?. map ( ( ) => ++ this . lastBreakpointId ) ?? [ ] ,
260+ params . breakpoints ?. map ( ( ) => this . breakpointIdCounter ( ) ) ?? [ ] ,
228261 ) ;
229262 }
230263
0 commit comments