Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
Adding a debugging configuration (#53)
Browse files Browse the repository at this point in the history
[PBI:30914 - Task:31107]

* Adding a debug configuration to the extension

* Moving debugger configuration to a class and utilitary methods to utils.ts

* Moving strings constants to constants.ts and localization + using 'endQith()' to check the file name

* Adding preserveFocus when opening the webview and the output panel :
Prevents the debugger to fail trying to find the file on first run + prevent having to click on the code file after clicking on open

* Modifying the error message when the file selected to debug isn't properly named
  • Loading branch information
Christellah authored Jul 16, 2019
1 parent 19b34d2 commit 6e054ca
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 58 deletions.
4 changes: 2 additions & 2 deletions locales/en/out/constants.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dialogResponses.help": "I need help",
"dialogResponses.tutorials": "Tutorials on Adafruit",
"error.noDevice": "No plugged in boards detected. Please double check if your board is connected and/or properly formatted",
"error.noFileToRun": "\n[ERROR] We can't find the .py file to run on simulator. Open up a new .py file, or browse through some examples",
"error.noFileToRun": "\n[ERROR] We can't find the .py file to run on simulator. Open up a new .py file, or browse through some examples\n",
"error.stderr": "\n[ERROR] {0} \n",
"error.unexpectedMessage": "Webview sent an unexpected message",
"info.deployDevice": "\n[INFO] Deploying code to the device...\n",
Expand All @@ -17,4 +17,4 @@
"info.welcomeOutputTab": "Welcome to the Adafruit Simulator output tab !\n\n",
"label.webviewPanel": "Adafruit CPX",
"name": "Adafruit Simulator"
}
}
81 changes: 78 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"onCommand:pacifica.openSimulator",
"onCommand:pacifica.runSimulator",
"onCommand:pacifica.newProject",
"onCommand:pacifica.runDevice"
"onCommand:pacifica.runDevice",
"onDebug"
],
"main": "./out/extension.js",
"contributes": {
Expand Down Expand Up @@ -98,7 +99,81 @@
"scope": "resource"
}
}
}
},
"breakpoints": [
{
"language": "python"
}
],
"debuggers": [
{
"type": "python",
"label": "Pacifica Simulator Debugger",
"program": "./out/debugAdapter.js",
"runtime": "node",
"configurationAttributes": {
"launch": {
"properties": {
"program": {
"type": "string",
"description": "Absolute path to the code file.",
"default": "${file}"
},
"stopOnEntry": {
"type": "boolean",
"description": "Automatically stop after launch.",
"default": false
},
"justMyCode": {
"type": "boolean",
"default": true
},
"args": {
"type": "array",
"description": "Command line arguments passed to the program.",
"default": [],
"items": {
"type": "string"
}
},
"rules": {
"type": "array",
"description": "Debugger rules.",
"default": [],
"items": {
"path": "string",
"include": "boolean"
}
}
}
}
},
"initialConfigurations": [
{
"type": "python",
"request": "launch",
"name": "Pacifica Simulator Debugger",
"program": "${file}",
"stopOnEntry": false,
"justMyCode": true
}
],
"configurationSnippets": [
{
"label": "Pacifica Simulator Debugger : Launch",
"description": "Pacifica Simulator Debugger - A configuration for debugging a python code file for the Pacifica simulator.",
"body": {
"type": "python",
"request": "launch",
"name": "Pacifica Simulator Debugger",
"program": "${file}",
"stopOnEntry": false,
"justMyCode": true
}
}
]
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
Expand Down Expand Up @@ -165,4 +240,4 @@
"eslintConfig": {
"extends": "react-app"
}
}
}
21 changes: 17 additions & 4 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@ const localize: nls.LocalizeFunc = nls.config({
})();

export const CONSTANTS = {
DEBUG_CONFIGURATION_NAME: "Pacifica Simulator Debugger",
ERROR: {
INVALID_FILE_NAME_DEBUG: localize(
"error.invalidFileNameDebug",
'The file you tried to run isn\'t named "code.py" or "main.py". Rename your file if you wish to debug it.'
),
NO_DEVICE: localize(
"error.noDevice",
"No plugged in boards detected. Please double check if your board is connected and/or properly formatted"
),
NO_FILE_TO_RUN: localize(
"error.noFileToRun",
"\n[ERROR] We can't find the .py file to run. Open up a new .py file, or browse through some examples to start with: https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/tree/master/examples"
"\n[ERROR] We can't find the .py file to run. Open up a new .py file, or browse through some examples to start with: https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/tree/master/examples\n"
),
NO_PROGRAM_FOUND_DEBUG: localize(
"error.noProgramFoundDebug",
"Cannot find a program to debug."
),
STDERR: (data: string) => {
return localize("error.stderr", `\n[ERROR] ${data} \n`);
Expand Down Expand Up @@ -46,7 +55,7 @@ export const CONSTANTS = {
),
FIRST_TIME_WEBVIEW: localize(
"info.firstTimeWebview",
"To reopen the simulator click on the \"Open Simulator\" button on the upper right corner of the text editor, or select the command \"Open Simulator\" from command palette."
'To reopen the simulator click on the "Open Simulator" button on the upper right corner of the text editor, or select the command "Open Simulator" from command palette.'
),
NEW_PROJECT: localize(
"info.newProject",
Expand Down Expand Up @@ -112,7 +121,6 @@ export enum WebviewMessages {
PLAY_SIMULATOR = "play-simulator"
}


// tslint:disable-next-line: no-namespace
export namespace DialogResponses {
export const HELP: MessageItem = {
Expand All @@ -129,4 +137,9 @@ export namespace DialogResponses {
};
}

export default CONSTANTS;
export const USER_CODE_NAMES = {
CODE_PY: "code.py",
MAIN_PY: "main.py"
};

export default CONSTANTS;
Loading

0 comments on commit 6e054ca

Please sign in to comment.