@@ -21,79 +21,97 @@ async function isServerModeSupported(exe: string): Promise<boolean> {
21
21
}
22
22
23
23
interface BoolConfig {
24
- type : ' boolean' ;
24
+ type : " boolean" ;
25
25
default : boolean ;
26
26
}
27
27
interface StringConfig {
28
- type : ' string' ;
28
+ type : " string" ;
29
29
default : string ;
30
30
}
31
31
interface NumberConfig {
32
- type : ' number' ;
32
+ type : " number" ;
33
33
default : number ;
34
34
}
35
35
interface StringArrayConfig {
36
- type : ' stringArray' ;
36
+ type : " stringArray" ;
37
37
default : string [ ] ;
38
38
}
39
- type DefaultConfig = BoolConfig | NumberConfig | StringConfig | StringArrayConfig ;
39
+ type DefaultConfig =
40
+ | BoolConfig
41
+ | NumberConfig
42
+ | StringConfig
43
+ | StringArrayConfig ;
40
44
41
45
const configurations : Record < string , DefaultConfig > = {
42
46
// Keys for debugger configurations.
43
- " commandEscapePrefix" : { type : "string" , default : "`" } ,
44
- " customFrameFormat" : { type : "string" , default : "" } ,
45
- " customThreadFormat" : { type : "string" , default : "" } ,
46
- " detachOnError" : { type : "boolean" , default : false } ,
47
- " disableASLR" : { type : "boolean" , default : true } ,
48
- " disableSTDIO" : { type : "boolean" , default : false } ,
49
- " displayExtendedBacktrace" : { type : "boolean" , default : false } ,
50
- " enableAutoVariableSummaries" : { type : "boolean" , default : false } ,
51
- " enableSyntheticChildDebugging" : { type : "boolean" , default : false } ,
52
- " timeout" : { type : "number" , default : 30 } ,
47
+ commandEscapePrefix : { type : "string" , default : "`" } ,
48
+ customFrameFormat : { type : "string" , default : "" } ,
49
+ customThreadFormat : { type : "string" , default : "" } ,
50
+ detachOnError : { type : "boolean" , default : false } ,
51
+ disableASLR : { type : "boolean" , default : true } ,
52
+ disableSTDIO : { type : "boolean" , default : false } ,
53
+ displayExtendedBacktrace : { type : "boolean" , default : false } ,
54
+ enableAutoVariableSummaries : { type : "boolean" , default : false } ,
55
+ enableSyntheticChildDebugging : { type : "boolean" , default : false } ,
56
+ timeout : { type : "number" , default : 30 } ,
53
57
54
58
// Keys for platform / target configuration.
55
- " platformName" : { type : "string" , default : "" } ,
56
- " targetTriple" : { type : "string" , default : "" } ,
59
+ platformName : { type : "string" , default : "" } ,
60
+ targetTriple : { type : "string" , default : "" } ,
57
61
58
62
// Keys for debugger command hooks.
59
- " initCommands" : { type : "stringArray" , default : [ ] } ,
60
- " preRunCommands" : { type : "stringArray" , default : [ ] } ,
61
- " postRunCommands" : { type : "stringArray" , default : [ ] } ,
62
- " stopCommands" : { type : "stringArray" , default : [ ] } ,
63
- " exitCommands" : { type : "stringArray" , default : [ ] } ,
64
- " terminateCommands" : { type : "stringArray" , default : [ ] } ,
63
+ initCommands : { type : "stringArray" , default : [ ] } ,
64
+ preRunCommands : { type : "stringArray" , default : [ ] } ,
65
+ postRunCommands : { type : "stringArray" , default : [ ] } ,
66
+ stopCommands : { type : "stringArray" , default : [ ] } ,
67
+ exitCommands : { type : "stringArray" , default : [ ] } ,
68
+ terminateCommands : { type : "stringArray" , default : [ ] } ,
65
69
} ;
66
70
67
71
export class LLDBDapConfigurationProvider
68
- implements vscode . DebugConfigurationProvider {
69
- constructor ( private readonly server : LLDBDapServer ) { }
72
+ implements vscode . DebugConfigurationProvider
73
+ {
74
+ constructor ( private readonly server : LLDBDapServer ) { }
70
75
71
76
async resolveDebugConfiguration (
72
77
folder : vscode . WorkspaceFolder | undefined ,
73
78
debugConfiguration : vscode . DebugConfiguration ,
74
- token ?: vscode . CancellationToken ) : Promise < vscode . DebugConfiguration > {
75
- let config = vscode . workspace . getConfiguration ( 'lldb-dap.defaults' ) ;
79
+ token ?: vscode . CancellationToken ,
80
+ ) : Promise < vscode . DebugConfiguration > {
81
+ let config = vscode . workspace . getConfiguration ( "lldb-dap.defaults" ) ;
76
82
for ( const [ key , cfg ] of Object . entries ( configurations ) ) {
77
- if ( Reflect . has ( debugConfiguration , key ) ) continue ;
83
+ if ( Reflect . has ( debugConfiguration , key ) ) {
84
+ continue ;
85
+ }
78
86
const value = config . get ( key ) ;
79
- if ( value === cfg . default ) continue ;
87
+ if ( ! value || value === cfg . default ) {
88
+ continue ;
89
+ }
80
90
switch ( cfg . type ) {
81
- case ' string' :
82
- if ( typeof value !== ' string' )
91
+ case " string" :
92
+ if ( typeof value !== " string" ) {
83
93
throw new Error ( `Expected ${ key } to be a string, got ${ value } ` ) ;
94
+ }
84
95
break ;
85
- case ' number' :
86
- if ( typeof value !== ' number' )
96
+ case " number" :
97
+ if ( typeof value !== " number" ) {
87
98
throw new Error ( `Expected ${ key } to be a number, got ${ value } ` ) ;
99
+ }
88
100
break ;
89
- case ' boolean' :
90
- if ( typeof value !== ' boolean' )
101
+ case " boolean" :
102
+ if ( typeof value !== " boolean" ) {
91
103
throw new Error ( `Expected ${ key } to be a boolean, got ${ value } ` ) ;
104
+ }
92
105
break ;
93
- case 'stringArray' :
94
- if ( typeof value !== 'object' && Array . isArray ( value ) )
95
- throw new Error ( `Expected ${ key } to be a array of strings, got ${ value } ` ) ;
96
- if ( ( value as string [ ] ) . length === 0 ) continue ;
106
+ case "stringArray" :
107
+ if ( typeof value !== "object" && Array . isArray ( value ) ) {
108
+ throw new Error (
109
+ `Expected ${ key } to be a array of strings, got ${ value } ` ,
110
+ ) ;
111
+ }
112
+ if ( ( value as string [ ] ) . length === 0 ) {
113
+ continue ;
114
+ }
97
115
break ;
98
116
}
99
117
0 commit comments