Skip to content

Commit

Permalink
add commands in the extension.js for printing logging messages to tra…
Browse files Browse the repository at this point in the history
…ck the status of the extension attaching
  • Loading branch information
Basant-khalil committed Jul 22, 2023
1 parent e8974fc commit dddb775
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "cider-dap",
"request": "launch",
"name": "Launch Program (Single Session)",
"program": "/AskForProgramName",
"stopOnEntry": true
},
{
"type": "cider-dap",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/Program"
},
{
"name": "Python: Current File",
"type": "python",
Expand Down
65 changes: 65 additions & 0 deletions cider-dap/calyxDebug/extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const vscode = require('vscode');
const cp = require('child_process');

let outputChannel;

function startDebugging() {
// After attaching and starting debugging, call the panel printing function
logToPanel('Debugger attached and debugging started.');
logToPanel('Some additional information...');
}

function logToPanel(message) {
// Create an output channel
if (!outputChannel) {
outputChannel = vscode.window.createOutputChannel('Cider DAP');
}

// Log the message to the output channel
outputChannel.appendLine(message);

// Show the message in the panel as well
vscode.window.showInformationMessage(message);
}

function activate(context) {
// Create the outputChannel only once when the extension activates
outputChannel = vscode.window.createOutputChannel('Cider DAP');

// Register a command to start debugging
const disposableStartDebugging = vscode.commands.registerCommand('extension.cider-dap.startDebugging', startDebugging);
context.subscriptions.push(disposableStartDebugging);

// Register a command for testing purposes
const disposableTest = vscode.commands.registerCommand('extension.cider-dap.test', function () {
// The code you want to run when the command is executed

// Log to the output channel
logToPanel('Executing extension.cider-dap.test');

// Listen for stdout data
const proc = cp.spawn('your_command_here', ['arg1', 'arg2']); // Replace 'your_command_here' with the actual command to be executed
proc.stdout.on('data', (data) => {
logToPanel(`stdout: ${data}`);
});

// Listen for stderr data
proc.stderr.on('data', (data) => {
logToPanel(`stderr: ${data}`);
});

// Listen for close event
proc.on('close', (code) => {
logToPanel(`child process exited with code ${code}`);
});
});

context.subscriptions.push(disposableTest);
}

function deactivate() { }

module.exports = {
activate,
deactivate
};

0 comments on commit dddb775

Please sign in to comment.