Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Add arduino.rebuildIntelliSenseConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
hlovdal authored and adiazulay committed Jan 19, 2021
1 parent 216e1b8 commit f914a4b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
- **Arduino: Upload**: Build sketch and upload to Arduino board.
- **Arduino: Upload Using Programmer**: Upload using an external programmer.
- **Arduino: Verify**: Build sketch.
- **Arduino: Rebuild IntelliSense Configuration**: Forced/manual rebuild of the IntelliSense configuration. The extension analyzes Arduino's build output and sets the Intellisense include paths, defines, compiler arguments accordingly.

## Keybindings
- **Arduino: Upload** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>U</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>U</kbd>
- **Arduino: Verify** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>R</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>R</kbd>
- **Arduino: Rebuild IntelliSense Configuration** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>I</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>I</kbd>

## Options
| Option | Description |
Expand Down Expand Up @@ -115,9 +117,16 @@ The following settings are as per sketch settings of the Arduino extension. You
- `"enable"`: Enable the auto-generation even if globally disabled

## IntelliSense
*TODO: Rewrite this section*
vscode-arduino auto-configures IntelliSense by default. vscode-arduino analyzes Arduino's compiler output during verify and generates the corresponding configuration file at `.vscode/c_cpp_properties.json` and tries as hard as possible to keep things up to date, e.g. running verify when switching the board or the sketch.
It doesn't makes sense though to run verify repeatedly. Therefore if the workspace reports problems (for instance after adding new includes to a new library) run *verify* such that IntelliSense knows of the new include directories (since the Arduino-backend performs the library resolution externally).

TODO: Note about configuration selection in lower right.

Manual rebuild: **Ardino: Rebuild IntelliSense Configuration**,
Keybindings: **Arduino: Rebuild IntelliSense Configuration** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>I</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>I</kbd>


## Debugging Arduino Code <sup>preview</sup>
Before you start to debug your Arduino code, please read [this document](https://code.visualstudio.com/docs/editor/debugging) to learn about the basic mechanisms of debugging in Visual Studio Code. Also see [debugging for C++ in VSCode](https://code.visualstudio.com/docs/languages/cpp#_debugging) for further reference.

Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"onCommand:arduino.verify",
"onCommand:arduino.upload",
"onCommand:arduino.uploadUsingProgrammer",
"onCommand:arduino.rebuildIntelliSenseConfig",
"onCommand:arduino.selectProgrammer",
"onCommand:arduino.selectSerialPort",
"onCommand:arduino.changeBaudRate",
Expand Down Expand Up @@ -105,6 +106,10 @@
"command": "arduino.cliUploadUsingProgrammer",
"title": "Arduino CLI: Upload Using Programmer"
},
{
"command": "arduino.rebuildIntelliSenseConfig",
"title": "Arduino: Rebuild IntelliSense Configuration"
},
{
"command": "arduino.selectProgrammer",
"title": "Arduino: Select Programmer"
Expand Down Expand Up @@ -444,6 +449,11 @@
"command": "arduino.upload",
"key": "ctrl+alt+u",
"mac": "cmd+alt+u"
},
{
"command": "arduino.rebuildIntelliSenseConfig",
"key": "ctrl+alt+i",
"mac": "cmd+alt+i"
}
],
"configuration": {
Expand Down
2 changes: 1 addition & 1 deletion src/debug/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat

// always compile elf to make sure debug the right elf
if (!await ArduinoContext.arduinoApp.build(BuildMode.Verify, true, outputFolder)) {
vscode.window.showErrorMessage("Failure to verify the program, please check output for details.");
vscode.window.showErrorMessage("Failed to verify the program, please check the output for details.");
return false;
}

Expand Down
22 changes: 20 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export async function activate(context: vscode.ExtensionContext) {
const workingFile = path.normalize(openEditor.document.fileName);
const workspaceFolder = (vscode.workspace && ArduinoWorkspace.rootPath) || "";
if (!workspaceFolder || workingFile.indexOf(path.normalize(workspaceFolder)) < 0) {
vscode.window.showWarningMessage(`The working file "${workingFile}" is not under the workspace folder, ` +
"the arduino extension might not work appropriately.");
vscode.window.showWarningMessage(`The open file "${workingFile}" is not inside the workspace folder, ` +
"the arduino extension might not work properly.");
}
}
const vscodeSettings = VscodeSettings.getInstance();
Expand Down Expand Up @@ -197,6 +197,9 @@ export async function activate(context: vscode.ExtensionContext) {
registerArduinoCommand("arduino.uploadUsingProgrammer", async () => {
if (!status.compile) {
status.compile = "upload";
// TODO: no progress indicator
// and: exceptions should be handled within build
// function
try {
await arduinoContextModule.default.arduinoApp.build(BuildMode.UploadProgrammer, true);
} catch (ex) {
Expand All @@ -220,6 +223,21 @@ export async function activate(context: vscode.ExtensionContext) {
return { board: arduinoContextModule.default.boardManager.currentBoard.name };
});

registerArduinoCommand("arduino.rebuildIntelliSenseConfig", async () => {
if (!status.compile) {
status.compile = "intellisenserebuild";
await vscode.window.withProgress({
location: vscode.ProgressLocation.Window,
title: "Arduino: Rebuilding IS Configuration...",
}, async () => {
await arduinoContextModule.default.arduinoApp.build(BuildMode.Analyze, true);
});
delete status.compile;
}
}, () => {
return { board: arduinoContextModule.default.boardManager.currentBoard.name };
});

registerArduinoCommand("arduino.selectProgrammer", async () => {
if (!status.compile) {
status.compile = "upload";
Expand Down
1 change: 1 addition & 0 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ suite("Arduino: Extension Tests", () => {
"arduino.verify",
"arduino.upload",
"arduino.uploadUsingProgrammer",
"arduino.rebuildIntelliSenseConfig",
"arduino.selectProgrammer",
"arduino.showBoardManager",
"arduino.showLibraryManager",
Expand Down

0 comments on commit f914a4b

Please sign in to comment.