Skip to content

Commit 2788543

Browse files
committed
Merge remote-tracking branch 'upstream/master' into statReadonly
2 parents b540581 + 5ca50f3 commit 2788543

File tree

6 files changed

+68
-19
lines changed

6 files changed

+68
-19
lines changed

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,19 @@
16091609
],
16101610
"default": "//",
16111611
"scope": "machine"
1612+
},
1613+
"objectscript.debug.stepGranularity": {
1614+
"markdownDescription": "Controls the granularity of the debugger's [step action buttons](https://code.visualstudio.com/docs/editor/debugging#_debug-actions). Changing this setting while a debugging session is active will not change the behavior of the active session. **NOTE:** Only supported on IRIS 2023.1.5, 2024.1.1+, 2024.2 and subsequent versions! On all other versions, line stepping will be used.",
1615+
"type": "string",
1616+
"enum": [
1617+
"command",
1618+
"line"
1619+
],
1620+
"enumDescriptions": [
1621+
"The step buttons execute a single command.",
1622+
"The step buttons execute an entire line."
1623+
],
1624+
"default": "command"
16121625
}
16131626
}
16141627
},

src/commands/compile.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ export async function importLocalFilesToServerSideFolder(wsFolderUri: vscode.Uri
725725
return;
726726
}
727727
// Get the name and content of the files to import
728+
const textDecoder = new TextDecoder();
728729
const docs = await Promise.allSettled<{ name: string; content: string; uri: vscode.Uri }>(
729730
uris.map((uri) =>
730731
vscode.workspace.fs
@@ -768,11 +769,12 @@ export async function importLocalFilesToServerSideFolder(wsFolderUri: vscode.Uri
768769
docs.map((e) => e.name)
769770
);
770771
// Import the files
771-
const textDecoder = new TextDecoder();
772772
return Promise.allSettled<string>(
773773
docs.map(
774774
throttleRequests((doc: { name: string; content: string; uri: vscode.Uri }) => {
775-
return importFileFromContent(doc.name, doc.content, api).then(() => {
775+
// Allow importing over deployed classes since the XML import
776+
// command and SMP, terminal, and Studio imports allow it
777+
return importFileFromContent(doc.name, doc.content, api, false, true).then(() => {
776778
outputChannel.appendLine("Imported file: " + doc.uri.path.split("/").pop());
777779
return doc.name;
778780
});

src/debug/debugSession.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
205205
await this._connection.sendFeatureSetCommand("max_children", 32);
206206
await this._connection.sendFeatureSetCommand("max_depth", 2);
207207
await this._connection.sendFeatureSetCommand("notify_ok", 1);
208+
await this._connection.sendFeatureSetCommand(
209+
"step_granularity",
210+
vscode.workspace.getConfiguration("objectscript.debug").get<string>("stepGranularity")
211+
);
208212

209213
this.sendResponse(response);
210214

@@ -599,6 +603,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
599603
const place = `${stackFrame.method}+${stackFrame.methodOffset}`;
600604
const stackFrameId = this._stackFrameIdCounter++;
601605
const fileText: string | undefined = await getFileText(fileUri).catch(() => undefined);
606+
const hasCmdLoc = typeof stackFrame.cmdBeginLine == "number";
602607
if (fileText == undefined) {
603608
// Can't get the source for the document
604609
this._stackFrames.set(stackFrameId, stackFrame);
@@ -611,7 +616,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
611616
presentationHint: "deemphasize",
612617
},
613618
line,
614-
column: 1,
619+
column: 0,
615620
};
616621
}
617622
let noSource = false;
@@ -656,12 +661,20 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
656661
} catch (ex) {
657662
noSource = true;
658663
}
664+
const lineDiff = line - stackFrame.line;
659665
return {
660666
id: stackFrameId,
661667
name: place,
662668
source: noSource ? null : source,
663669
line,
664-
column: 1,
670+
column: hasCmdLoc ? stackFrame.cmdBeginPos + 1 : 0,
671+
endLine: hasCmdLoc ? stackFrame.cmdEndLine + lineDiff : undefined,
672+
endColumn: hasCmdLoc
673+
? (stackFrame.cmdEndPos == 0
674+
? // A command that ends at position zero means "rest of this line"
675+
fileText.split(/\r?\n/)[stackFrame.cmdEndLine + lineDiff - 1].length
676+
: stackFrame.cmdEndPos) + 1
677+
: undefined,
665678
};
666679
})
667680
);

src/debug/xdebugConnection.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,14 @@ export class StackFrame {
391391
public line: number;
392392
/** The line number inside of method of class */
393393
public methodOffset: number;
394+
/** The start line number of the current command */
395+
public cmdBeginLine?: number;
396+
/** The start position of the current command within the line */
397+
public cmdBeginPos?: number;
398+
/** The end line number of the current command */
399+
public cmdEndLine?: number;
400+
/** The end position of the current command within the line */
401+
public cmdEndPos?: number;
394402
/** The level (index) inside the stack trace at which the stack frame receides */
395403
public level: number;
396404
/** The connection this stackframe belongs to */
@@ -406,6 +414,16 @@ export class StackFrame {
406414
this.line = parseInt(stackFrameNode.getAttribute("lineno"), 10);
407415
this.methodOffset = parseInt(stackFrameNode.getAttribute("methodoffset"), 10);
408416
this.level = parseInt(stackFrameNode.getAttribute("level"), 10);
417+
const cmdBegin = stackFrameNode.getAttribute("cmdbegin");
418+
const cmdEnd = stackFrameNode.getAttribute("cmdend");
419+
if (cmdBegin && cmdEnd) {
420+
const [cmdBeginLine, cmdBeginPos] = cmdBegin.split(":");
421+
const [cmdEndLine, cmdEndPos] = cmdEnd.split(":");
422+
this.cmdBeginLine = parseInt(cmdBeginLine, 10);
423+
this.cmdBeginPos = parseInt(cmdBeginPos, 10);
424+
this.cmdEndLine = parseInt(cmdEndLine, 10);
425+
this.cmdEndPos = parseInt(cmdEndPos, 10);
426+
}
409427
this.connection = connection;
410428
}
411429
/** Returns the available contexts (scopes, such as "Local" and "Superglobals") by doing a context_names command */

src/extension.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ import { FileDecorationProvider } from "./providers/FileDecorationProvider";
138138
import { RESTDebugPanel } from "./commands/restDebugPanel";
139139
import { modifyWsFolder } from "./commands/addServerNamespaceToWorkspace";
140140
import { WebSocketTerminalProfileProvider, launchWebSocketTerminal } from "./commands/webSocketTerminal";
141-
import { getCSPToken } from "./utils/getCSPToken";
142141
import { setUpTestController } from "./commands/unitTest";
143142

144143
const packageJson = vscode.extensions.getExtension(extensionId).packageJSON;
@@ -1384,20 +1383,24 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
13841383
vscode.commands.registerCommand(
13851384
"vscode-objectscript.openPathInBrowser",
13861385
async (path: string, docUri: vscode.Uri) => {
1387-
if (typeof path == "string" && docUri && docUri instanceof vscode.Uri) {
1386+
if (typeof path == "string" && docUri instanceof vscode.Uri) {
13881387
const api = new AtelierAPI(docUri);
1389-
let uri = vscode.Uri.parse(
1390-
`${api.config.https ? "https" : "http"}://${api.config.host}:${api.config.port}${
1391-
api.config.pathPrefix
1392-
}${path}`
1388+
// Get the default web application for this namespace.
1389+
// If it can't be determined, fall back to the /csp/<namespace> web application.
1390+
const app: string =
1391+
(await api
1392+
.getCSPApps(true)
1393+
.then((data) => data.result.content.find((a) => a.default)?.name)
1394+
.catch(() => {
1395+
// Swallow errors
1396+
})) ?? `/csp/${api.ns}`;
1397+
vscode.env.openExternal(
1398+
vscode.Uri.parse(
1399+
`${api.config.https ? "https" : "http"}://${api.config.host}:${api.config.port}${
1400+
api.config.pathPrefix
1401+
}${app}${path}`
1402+
)
13931403
);
1394-
const token = await getCSPToken(api, path.split("?")[0]).catch(() => "");
1395-
if (token.length > 0) {
1396-
uri = uri.with({
1397-
query: uri.query.length ? `${uri.query}&CSPCHD=${token}` : `CSPCHD=${token}`,
1398-
});
1399-
}
1400-
vscode.env.openExternal(uri);
14011404
}
14021405
}
14031406
),

src/providers/ObjectScriptCodeLensProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
7070
command: "vscode-objectscript.openPathInBrowser",
7171
tooltip: "Open graphical editor in an external browser",
7272
arguments: [
73-
`/csp/${api.config.ns.toLowerCase()}/EnsPortal.${
73+
`/EnsPortal.${
7474
xdataName == "BPL" ? `BPLEditor.zen?BP=${className}.BPL` : `DTLEditor.zen?DT=${className}.DTL`
7575
}`,
7676
document.uri,
@@ -87,7 +87,7 @@ export class ObjectScriptCodeLensProvider implements vscode.CodeLensProvider {
8787
title: "Test KPI",
8888
command: "vscode-objectscript.openPathInBrowser",
8989
tooltip: "Open testing page in an external browser",
90-
arguments: [`/csp/${api.config.ns.toLowerCase()}/${className}.cls`, document.uri],
90+
arguments: [`/${className}.cls`, document.uri],
9191
};
9292
}
9393
if (cmd) result.push(new vscode.CodeLens(new vscode.Range(i, 0, i, 80), cmd));

0 commit comments

Comments
 (0)