1
1
import { existsSync , readFileSync } from 'fs' ;
2
+ import * as _ from 'lodash' ;
2
3
import { join } from 'path' ;
3
- import { ChromeDebugAdapter , IRestartRequestArgs } from 'vscode-chrome-debug-core' ;
4
+ import {
5
+ ChromeDebugAdapter ,
6
+ IRestartRequestArgs ,
7
+ ISetBreakpointsArgs ,
8
+ ISetBreakpointsResponseBody ,
9
+ ITelemetryPropertyCollector ,
10
+ } from 'vscode-chrome-debug-core' ;
4
11
import { Event , TerminatedEvent } from 'vscode-debugadapter' ;
5
12
import { DebugProtocol } from 'vscode-debugprotocol' ;
6
13
import * as extProtocol from '../common/extensionProtocol' ;
14
+ import { NativeScriptSourceMapTransformer } from './nativeScriptSourceMapTransformer' ;
7
15
8
16
const reconnectAfterLiveSyncTimeout = 10 * 1000 ;
9
17
@@ -14,6 +22,7 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
14
22
private portWaitingResolve : any ;
15
23
private isDisconnecting : boolean = false ;
16
24
private isLiveSyncRestart : boolean = false ;
25
+ private breakPointsCache : { [ file : string ] : { args : ISetBreakpointsArgs , requestSeq : number , ids : number [ ] } } = { } ;
17
26
18
27
public attach ( args : any ) : Promise < void > {
19
28
return this . processRequestAndAttach ( args ) ;
@@ -41,6 +50,27 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
41
50
super . disconnect ( args ) ;
42
51
}
43
52
53
+ public async setCachedBreakpointsForScript ( script : string ) : Promise < void > {
54
+ const breakPointData = this . breakPointsCache [ script ] ;
55
+
56
+ if ( breakPointData ) {
57
+ await this . setBreakpoints ( breakPointData . args , null , breakPointData . requestSeq , breakPointData . ids ) ;
58
+ }
59
+ }
60
+
61
+ public async setBreakpoints (
62
+ args : ISetBreakpointsArgs ,
63
+ telemetryPropertyCollector : ITelemetryPropertyCollector ,
64
+ requestSeq : number ,
65
+ ids ?: number [ ] ) : Promise < ISetBreakpointsResponseBody > {
66
+
67
+ if ( args && args . source && args . source . path ) {
68
+ this . breakPointsCache [ args . source . path ] = { args : _ . cloneDeep ( args ) , requestSeq, ids } ;
69
+ }
70
+
71
+ return super . setBreakpoints ( args , telemetryPropertyCollector , requestSeq , ids ) ;
72
+ }
73
+
44
74
protected async terminateSession ( reason : string , disconnectArgs ?: DebugProtocol . DisconnectArguments , restart ?: IRestartRequestArgs ) : Promise < void > {
45
75
let restartRequestArgs = restart ;
46
76
let timeoutId ;
@@ -113,6 +143,7 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
113
143
const appDirPath = this . getAppDirPath ( transformedArgs . webRoot ) ;
114
144
115
145
( this . pathTransformer as any ) . setTransformOptions ( args . platform , appDirPath , transformedArgs . webRoot ) ;
146
+ ( this . sourceMapTransformer as NativeScriptSourceMapTransformer ) . setDebugAdapter ( this ) ;
116
147
( ChromeDebugAdapter as any ) . SET_BREAKPOINTS_TIMEOUT = 20000 ;
117
148
118
149
this . isLiveSync = args . watch ;
@@ -145,7 +176,7 @@ export class NativeScriptDebugAdapter extends ChromeDebugAdapter {
145
176
}
146
177
147
178
if ( ! args . sourceMapPathOverrides ) {
148
- args . sourceMapPathOverrides = { } ;
179
+ args . sourceMapPathOverrides = { } ;
149
180
}
150
181
151
182
if ( ! args . sourceMapPathOverrides [ 'webpack:///*' ] ) {
0 commit comments