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

Commit f914a4b

Browse files
hlovdaladiazulay
authored andcommitted
Add arduino.rebuildIntelliSenseConfig
1 parent 216e1b8 commit f914a4b

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
5050
- **Arduino: Upload**: Build sketch and upload to Arduino board.
5151
- **Arduino: Upload Using Programmer**: Upload using an external programmer.
5252
- **Arduino: Verify**: Build sketch.
53+
- **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.
5354

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

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

117119
## IntelliSense
120+
*TODO: Rewrite this section*
118121
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.
119122
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).
120123

124+
TODO: Note about configuration selection in lower right.
125+
126+
Manual rebuild: **Ardino: Rebuild IntelliSense Configuration**,
127+
Keybindings: **Arduino: Rebuild IntelliSense Configuration** <kbd>Alt</kbd> + <kbd>Cmd</kbd> + <kbd>I</kbd> *or* <kbd>Alt</kbd> + <kbd>Ctrl</kbd> + <kbd>I</kbd>
128+
129+
121130
## Debugging Arduino Code <sup>preview</sup>
122131
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.
123132

package.json

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"onCommand:arduino.verify",
3838
"onCommand:arduino.upload",
3939
"onCommand:arduino.uploadUsingProgrammer",
40+
"onCommand:arduino.rebuildIntelliSenseConfig",
4041
"onCommand:arduino.selectProgrammer",
4142
"onCommand:arduino.selectSerialPort",
4243
"onCommand:arduino.changeBaudRate",
@@ -105,6 +106,10 @@
105106
"command": "arduino.cliUploadUsingProgrammer",
106107
"title": "Arduino CLI: Upload Using Programmer"
107108
},
109+
{
110+
"command": "arduino.rebuildIntelliSenseConfig",
111+
"title": "Arduino: Rebuild IntelliSense Configuration"
112+
},
108113
{
109114
"command": "arduino.selectProgrammer",
110115
"title": "Arduino: Select Programmer"
@@ -444,6 +449,11 @@
444449
"command": "arduino.upload",
445450
"key": "ctrl+alt+u",
446451
"mac": "cmd+alt+u"
452+
},
453+
{
454+
"command": "arduino.rebuildIntelliSenseConfig",
455+
"key": "ctrl+alt+i",
456+
"mac": "cmd+alt+i"
447457
}
448458
],
449459
"configuration": {

src/debug/configurationProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class ArduinoDebugConfigurationProvider implements vscode.DebugConfigurat
137137

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

src/extension.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export async function activate(context: vscode.ExtensionContext) {
4444
const workingFile = path.normalize(openEditor.document.fileName);
4545
const workspaceFolder = (vscode.workspace && ArduinoWorkspace.rootPath) || "";
4646
if (!workspaceFolder || workingFile.indexOf(path.normalize(workspaceFolder)) < 0) {
47-
vscode.window.showWarningMessage(`The working file "${workingFile}" is not under the workspace folder, ` +
48-
"the arduino extension might not work appropriately.");
47+
vscode.window.showWarningMessage(`The open file "${workingFile}" is not inside the workspace folder, ` +
48+
"the arduino extension might not work properly.");
4949
}
5050
}
5151
const vscodeSettings = VscodeSettings.getInstance();
@@ -197,6 +197,9 @@ export async function activate(context: vscode.ExtensionContext) {
197197
registerArduinoCommand("arduino.uploadUsingProgrammer", async () => {
198198
if (!status.compile) {
199199
status.compile = "upload";
200+
// TODO: no progress indicator
201+
// and: exceptions should be handled within build
202+
// function
200203
try {
201204
await arduinoContextModule.default.arduinoApp.build(BuildMode.UploadProgrammer, true);
202205
} catch (ex) {
@@ -220,6 +223,21 @@ export async function activate(context: vscode.ExtensionContext) {
220223
return { board: arduinoContextModule.default.boardManager.currentBoard.name };
221224
});
222225

226+
registerArduinoCommand("arduino.rebuildIntelliSenseConfig", async () => {
227+
if (!status.compile) {
228+
status.compile = "intellisenserebuild";
229+
await vscode.window.withProgress({
230+
location: vscode.ProgressLocation.Window,
231+
title: "Arduino: Rebuilding IS Configuration...",
232+
}, async () => {
233+
await arduinoContextModule.default.arduinoApp.build(BuildMode.Analyze, true);
234+
});
235+
delete status.compile;
236+
}
237+
}, () => {
238+
return { board: arduinoContextModule.default.boardManager.currentBoard.name };
239+
});
240+
223241
registerArduinoCommand("arduino.selectProgrammer", async () => {
224242
if (!status.compile) {
225243
status.compile = "upload";

test/extension.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ suite("Arduino: Extension Tests", () => {
3737
"arduino.verify",
3838
"arduino.upload",
3939
"arduino.uploadUsingProgrammer",
40+
"arduino.rebuildIntelliSenseConfig",
4041
"arduino.selectProgrammer",
4142
"arduino.showBoardManager",
4243
"arduino.showLibraryManager",

0 commit comments

Comments
 (0)