@@ -22,14 +22,6 @@ const attachCfgRequest = 'attach';
22
22
export function setDefaultAcadPid ( pid : number ) {
23
23
acadPid2Attach = pid ;
24
24
}
25
- function need2AddDefaultConfig ( config : vscode . DebugConfiguration ) : Boolean {
26
- if ( config . type ) return false ;
27
- if ( config . request ) return false ;
28
- if ( config . name ) return false ;
29
-
30
- return true ;
31
- }
32
-
33
25
const LAUNCH_PROC :string = 'debug.LaunchProgram' ;
34
26
const LAUNCH_PARM :string = 'debug.LaunchParameters' ;
35
27
const ATTACH_PROC :string = 'debug.AttachProcess' ;
@@ -125,31 +117,19 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
125
117
private _server ?: Net . Server ;
126
118
127
119
async resolveDebugConfiguration ( folder : vscode . WorkspaceFolder | undefined , config : vscode . DebugConfiguration , token ?: vscode . CancellationToken ) : Promise < vscode . DebugConfiguration > {
128
- // if launch.json is missing or empty
129
- if ( need2AddDefaultConfig ( config ) ) {
130
- config . type = launchCfgType ;
131
- config . name = launchCfgName ;
132
- config . request = 'launch' ;
133
- }
120
+
121
+ var newConfig = { } as vscode . DebugConfiguration ;
122
+ newConfig . type = launchCfgType ;
123
+ newConfig . name = launchCfgName ;
124
+ newConfig . request = 'launch' ;
134
125
135
126
if ( vscode . window . activeTextEditor )
136
- config . program = vscode . window . activeTextEditor . document . fileName ;
127
+ newConfig . program = vscode . window . activeTextEditor . document . fileName ;
137
128
138
- if ( config [ "type" ] === launchCfgType ) {
129
+ if ( newConfig [ "type" ] === launchCfgType ) {
139
130
// 1. get acad and adapter path
140
- //2. get acadRoot path
141
- //2.1 get acadRoot path from launch.json
142
-
143
- let productPath = "" ;
144
- if ( config [ "attributes" ] ) {
145
- productPath = config [ "attributes" ] [ "path" ] ? config [ "attributes" ] [ "path" ] : "" ;
146
- }
147
-
148
- if ( ! productPath ) {
149
- let path = getExtensionSettingString ( LAUNCH_PROC ) ;
150
- if ( path )
151
- productPath = path ;
152
- }
131
+ // 2. get acadRoot path
132
+ let productPath = getExtensionSettingString ( LAUNCH_PROC ) ;
153
133
154
134
if ( ! productPath ) {
155
135
let info = AutoLispExt . localize ( "autolispext.debug.launchjson.path" ,
@@ -174,6 +154,7 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
174
154
rememberLaunchPath ( productPath ) ;
175
155
}
176
156
}
157
+
177
158
//3. get acad startup params
178
159
if ( ! existsSync ( productPath ) ) {
179
160
if ( ! productPath || productPath . length == 0 )
@@ -183,17 +164,10 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
183
164
ProcessPathCache . globalProductPath = "" ;
184
165
return undefined ;
185
166
} else {
186
- let params = "" ;
187
- if ( config [ "attributes" ] ) {
188
- params = config [ "attributes" ] [ "params" ] ? config [ "attributes" ] [ "params" ] : "" ;
189
- }
190
- else {
191
- let text = getExtensionSettingString ( LAUNCH_PARM ) ;
192
- if ( text )
193
- params = text ;
194
- }
167
+ let params = getExtensionSettingString ( LAUNCH_PARM ) ;
195
168
ProcessPathCache . globalParameter = params ;
196
169
}
170
+
197
171
//4. get debug adapter path
198
172
let lispadapterpath = calculateABSPathForDAP ( productPath ) ;
199
173
if ( ! existsSync ( lispadapterpath ) ) {
@@ -206,7 +180,7 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
206
180
ProcessPathCache . globalLispAdapterPath = lispadapterpath ;
207
181
ProcessPathCache . globalProductPath = productPath ;
208
182
}
209
- return config ;
183
+ return newConfig ;
210
184
}
211
185
212
186
dispose ( ) {
@@ -221,26 +195,18 @@ class LispAttachConfigurationProvider implements vscode.DebugConfigurationProvid
221
195
private _server ?: Net . Server ;
222
196
223
197
async resolveDebugConfiguration ( folder : vscode . WorkspaceFolder | undefined , config : vscode . DebugConfiguration , token ?: vscode . CancellationToken ) : Promise < vscode . DebugConfiguration > {
224
-
225
- // if launch.json is missing or empty
226
- if ( need2AddDefaultConfig ( config ) ) {
227
- config . type = attachCfgType ;
228
- config . name = attachCfgName ;
229
- config . request = attachCfgRequest ;
230
- }
198
+ var newConfig = { } as vscode . DebugConfiguration ;
199
+ newConfig . type = attachCfgType ;
200
+ newConfig . name = attachCfgName ;
201
+ newConfig . request = attachCfgRequest ;
231
202
232
203
if ( vscode . window . activeTextEditor )
233
- config . program = vscode . window . activeTextEditor . document . fileName ;
204
+ newConfig . program = vscode . window . activeTextEditor . document . fileName ;
234
205
235
206
ProcessPathCache . globalAcadNameInUserAttachConfig = '' ;
236
- if ( config && config . attributes && config . attributes . process ) {
237
- ProcessPathCache . globalAcadNameInUserAttachConfig = config . attributes . process ;
238
- }
239
- else {
240
- let name = getExtensionSettingString ( ATTACH_PROC ) ;
241
- if ( name )
242
- ProcessPathCache . globalAcadNameInUserAttachConfig = name ;
243
- }
207
+ let name = getExtensionSettingString ( ATTACH_PROC ) ;
208
+ if ( name )
209
+ ProcessPathCache . globalAcadNameInUserAttachConfig = name ;
244
210
245
211
ProcessPathCache . clearProductProcessPathArr ( ) ;
246
212
let processId = await pickProcess ( false , acadPid2Attach ) ;
@@ -258,9 +224,9 @@ class LispAttachConfigurationProvider implements vscode.DebugConfigurationProvid
258
224
return undefined ;
259
225
}
260
226
ProcessPathCache . globalLispAdapterPath = lispadapterpath ;
261
- config . processId = processId ;
227
+ newConfig . processId = processId ;
262
228
263
- return config ;
229
+ return newConfig ;
264
230
}
265
231
266
232
dispose ( ) {
0 commit comments