Skip to content

Commit 58f6e56

Browse files
Deprecate to use the launch.json to debug autolisp files (#55)
#### Objectives In this commit I trid to remove the support for the launchjson. #### Abstraction Now the debug settings (attach and launch for acad installation path) is in the extension "settings" page, which is a global settings. So it has no need to use the launch.json file. In fact the file has been deprecated in the version 1.3.0, and it only reads the settings (can not set the settings). In this version I tried to remove the reading setting support for launch.json, it has some issues to debug the lisp after upgrade the vscode. Some customers reported that after updating vscode, it may have issue to attach debugging autocad. #### tests performed tried to open a folder with the legacy launch.json, and do following settings: 1. attach debug 2. launch debug Then do some changes in the launch.json file, and do above tests again #### Screen Shot No new behavior introduced, not applicable
1 parent 8ff1c9e commit 58f6e56

File tree

1 file changed

+23
-57
lines changed

1 file changed

+23
-57
lines changed

extension/src/debug.ts

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ const attachCfgRequest = 'attach';
2222
export function setDefaultAcadPid(pid: number) {
2323
acadPid2Attach = pid;
2424
}
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-
3325
const LAUNCH_PROC:string = 'debug.LaunchProgram';
3426
const LAUNCH_PARM:string = 'debug.LaunchParameters';
3527
const ATTACH_PROC:string = 'debug.AttachProcess';
@@ -125,31 +117,19 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
125117
private _server?: Net.Server;
126118

127119
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';
134125

135126
if (vscode.window.activeTextEditor)
136-
config.program = vscode.window.activeTextEditor.document.fileName;
127+
newConfig.program = vscode.window.activeTextEditor.document.fileName;
137128

138-
if (config["type"] === launchCfgType) {
129+
if (newConfig["type"] === launchCfgType) {
139130
// 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);
153133

154134
if (!productPath) {
155135
let info = AutoLispExt.localize("autolispext.debug.launchjson.path",
@@ -174,6 +154,7 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
174154
rememberLaunchPath(productPath);
175155
}
176156
}
157+
177158
//3. get acad startup params
178159
if (!existsSync(productPath)) {
179160
if (!productPath || productPath.length == 0)
@@ -183,17 +164,10 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
183164
ProcessPathCache.globalProductPath = "";
184165
return undefined;
185166
} 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);
195168
ProcessPathCache.globalParameter = params;
196169
}
170+
197171
//4. get debug adapter path
198172
let lispadapterpath = calculateABSPathForDAP(productPath);
199173
if (!existsSync(lispadapterpath)) {
@@ -206,7 +180,7 @@ class LispLaunchConfigurationProvider implements vscode.DebugConfigurationProvid
206180
ProcessPathCache.globalLispAdapterPath = lispadapterpath;
207181
ProcessPathCache.globalProductPath = productPath;
208182
}
209-
return config;
183+
return newConfig;
210184
}
211185

212186
dispose() {
@@ -221,26 +195,18 @@ class LispAttachConfigurationProvider implements vscode.DebugConfigurationProvid
221195
private _server?: Net.Server;
222196

223197
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;
231202

232203
if (vscode.window.activeTextEditor)
233-
config.program = vscode.window.activeTextEditor.document.fileName;
204+
newConfig.program = vscode.window.activeTextEditor.document.fileName;
234205

235206
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;
244210

245211
ProcessPathCache.clearProductProcessPathArr();
246212
let processId = await pickProcess(false, acadPid2Attach);
@@ -258,9 +224,9 @@ class LispAttachConfigurationProvider implements vscode.DebugConfigurationProvid
258224
return undefined;
259225
}
260226
ProcessPathCache.globalLispAdapterPath = lispadapterpath;
261-
config.processId = processId;
227+
newConfig.processId = processId;
262228

263-
return config;
229+
return newConfig;
264230
}
265231

266232
dispose() {

0 commit comments

Comments
 (0)