Skip to content

Commit

Permalink
Revert "Removed the debug command from package.json and updated logic…
Browse files Browse the repository at this point in the history
… correspondingly"

This reverts commit 3a41a23.
  • Loading branch information
rodinaarssen committed Jan 30, 2025
1 parent 603a52d commit 2580d9f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
20 changes: 20 additions & 0 deletions rascal-vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,28 @@
{
"command": "rascalmpl.importModule",
"title": "Start Rascal Terminal and Import this module"
},
{
"command": "rascalmpl.startDebuggerForRepl",
"title": "Start Rascal debugger for REPL",
"icon": "$(debug)"
}
],
"menus": {
"commandPalette": [
{
"command": "rascalmpl.startDebuggerForRepl",
"when": "false"
}
],
"view/item/context": [
{
"command": "rascalmpl.startDebuggerForRepl",
"when": "view == rascalmpl-debugger-view && viewItem == 'canStartDebugging'",
"group": "inline"
}
]
},
"languages": [
{
"id": "rascalmpl",
Expand Down
15 changes: 7 additions & 8 deletions rascal-vscode-extension/src/dap/RascalDebugView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*/
import * as vscode from 'vscode';
import { RascalDebugClient } from './RascalDebugClient';
import { Command } from 'vscode-languageclient';

export class RascalDebugViewProvider implements vscode.TreeDataProvider<RascalReplNode> {
private changeEmitter = new vscode.EventEmitter<RascalReplNode | undefined>();
Expand Down Expand Up @@ -88,7 +87,7 @@ export class RascalDebugViewProvider implements vscode.TreeDataProvider<RascalRe
return label;
}

async updateRascalDebugView() : Promise<RascalReplNode[]> {
async updateRascalDebugView() : Promise<vscode.TreeItem[]> {
const result : RascalReplNode[] = [];
for (const terminal of vscode.window.terminals) {
const processId = await terminal.processId;
Expand All @@ -99,8 +98,10 @@ export class RascalDebugViewProvider implements vscode.TreeDataProvider<RascalRe
const label = await this.makeLabel(terminal.name, processId);
const serverPort = this.rascalDebugClient.getServerPort(processId);
const isDebugging = serverPort !== undefined && this.rascalDebugClient.isConnectedToDebugServer(serverPort);
const canStartDebugging = serverPort !== undefined && !isDebugging;
const replNode = new RascalReplNode(label, serverPort, isDebugging, canStartDebugging);
const replNode = new RascalReplNode(label, serverPort, isDebugging);
if (serverPort !== undefined && !isDebugging) {
replNode.contextValue = "canStartDebugging";
}
result.push(replNode);
}
}
Expand All @@ -118,11 +119,9 @@ export class RascalDebugViewProvider implements vscode.TreeDataProvider<RascalRe
}

export class RascalReplNode extends vscode.TreeItem {
constructor(label : string | vscode.TreeItemLabel, readonly serverPort : number | undefined, isDebugging : boolean, canStartDebugging : boolean) {
constructor(label : string | vscode.TreeItemLabel, readonly serverPort : number | undefined, isDebugging : boolean) {
super(label, vscode.TreeItemCollapsibleState.None);
this.serverPort = serverPort;
this.iconPath = new vscode.ThemeIcon(isDebugging ? "debug" : "terminal");
if (canStartDebugging) {
this.command = Command.create("Debug Rascal REPL", "rascalmpl.startDebuggerForRepl", this, {"icon":"$(debug)"});
}
}
}

0 comments on commit 2580d9f

Please sign in to comment.