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

Commit 625610f

Browse files
committed
Add analyzeOnOpen and don't analyze by default
1 parent 6d15746 commit 625610f

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
8282
| `arduino.defaultBaudRate` | Default baud rate for the serial port monitor. The default value is 115200. Supported values are 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400 and 250000 |
8383
| `arduino.defaultTimestampFormat` | Format of timestamp printed before each line of Serial Monitor output. You can find list of all available placeholders [here](https://github.com/samsonjs/strftime#supported-specifiers). |
8484
| `arduino.disableIntelliSenseAutoGen` | When `true` vscode-arduino will not auto-generate an IntelliSense configuration (i.e. `.vscode/c_cpp_properties.json`) by analyzing Arduino's compiler output. |
85+
| `arduino.analyzeOnOpen` | When true, automatically run analysis when the project is opened. |
8586

8687
The following Visual Studio Code settings are available for the Arduino extension. These can be set in global user preferences <kbd>Ctrl</kbd> + <kbd>,</kbd> *or* <kbd>Cmd</kbd> + <kbd>,</kbd> or workspace settings (`.vscode/settings.json`). The latter overrides the former.
8788

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,11 @@
541541
"type": "string",
542542
"default": "",
543543
"markdownDescription": "Format of timestamp printed before each line of Serial Monitor output. You can find list of all available placeholders [here](https://github.com/samsonjs/strftime#supported-specifiers)."
544+
},
545+
"arduino.analyzeOnOpen": {
546+
"type": "boolean",
547+
"default": false,
548+
"markdownDescription": "When true, automatically run analysis when the project is opened."
544549
}
545550
}
546551
},

src/arduino/vscodeSettings.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const configKeys = {
2020
USE_ARDUINO_CLI: "arduino.useArduinoCli",
2121
DISABLE_INTELLISENSE_AUTO_GEN: "arduino.disableIntelliSenseAutoGen",
2222
DEFAULT_TIMESTAMP_FORMAT: "arduino.defaultTimestampFormat",
23+
ANALYZE_ON_OPEN: "arduino.analyzeOnOpen",
2324
};
2425

2526
export interface IVscodeSettings {
@@ -37,6 +38,7 @@ export interface IVscodeSettings {
3738
useArduinoCli: boolean;
3839
disableIntelliSenseAutoGen: boolean;
3940
defaultTimestampFormat: string;
41+
analyzeOnOpen: boolean;
4042
updateAdditionalUrls(urls: string[]): void;
4143
}
4244

@@ -124,6 +126,10 @@ export class VscodeSettings implements IVscodeSettings {
124126
return this.getConfigValue<string>(configKeys.DEFAULT_TIMESTAMP_FORMAT);
125127
}
126128

129+
public get analyzeOnOpen(): boolean {
130+
return this.getConfigValue<boolean>(configKeys.ANALYZE_ON_OPEN);
131+
}
132+
127133
public async updateAdditionalUrls(value) {
128134
await this.setConfigValue(configKeys.ADDITIONAL_URLS, value, true);
129135
}

src/arduinoActivator.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ExampleManager } from "./arduino/exampleManager";
1010
import { ExampleProvider } from "./arduino/exampleProvider";
1111
import { LibraryManager } from "./arduino/libraryManager";
1212
import { ProgrammerManager } from "./arduino/programmerManager";
13+
import { VscodeSettings } from "./arduino/vscodeSettings";
1314
import ArduinoContext from "./arduinoContext";
1415
import { DeviceContext } from "./deviceContext";
1516

@@ -25,11 +26,22 @@ class ArduinoActivator {
2526
const arduinoSettings = new ArduinoSettings();
2627
await arduinoSettings.initialize();
2728
const arduinoApp = new ArduinoApp(arduinoSettings);
28-
await arduinoApp.initialize();
29+
30+
// Initializing the app before the device context will cause a
31+
// setting changed event that triggers analysis.
32+
const analyzeOnOpen = VscodeSettings.getInstance().analyzeOnOpen;
33+
if (analyzeOnOpen) {
34+
await arduinoApp.initialize();
35+
}
2936

3037
// TODO: After use the device.json config, should remove the dependency on the ArduinoApp object.
3138
const deviceContext = DeviceContext.getInstance();
3239
await deviceContext.loadContext();
40+
41+
if (!analyzeOnOpen) {
42+
await arduinoApp.initialize();
43+
}
44+
3345
// Show sketch status bar, and allow user to change sketch in config file
3446
deviceContext.showStatusBar();
3547
// Arduino board manager & library manager

0 commit comments

Comments
 (0)