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

Commit 40bb52d

Browse files
elektronikworkshopadiazulay
authored andcommitted
Merge c_cpp_properties results with existing configuration
* More unit testing within cocopa. * Implemented c_cpp_properties merging -> compiler analysis results are merged into existing configuration and will preserve configurations of different name than the vscode-studio default configuration name (currently "Arduino"). This opens up the possibility for users to write their own configurations without having to disable the autogeneration. * Implemented "write on change" - `c_cpp_properties.json` will only be written if a new configuration has been detected.
1 parent 67281ae commit 40bb52d

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

BRANCHNOTES.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Provide a configuration flag which allows the user to turn this feature off - th
2020
**2020-02-06** Got it fully working (with built-in include directories) for AVR, ESP32, ESP8266. Rewrote the backend to facilitate writing of further parser engines in the future.
2121
**2020-02-07** Wrote compiler command parser npm package [cocopa](https://www.npmjs.com/package/cocopa) and began writing a test framework for it. Added a global configuration switch which allows the IntelliSense configuration generation to be turned off.
2222
**2020-02-08** Integrated `cocopa` into vscode-arduino. Added project configuration flag which can override the global flag in both ways (forced off, forced on). Made code tslint compliant. Began some documentation in [README.md](README.md). vscode-arduino now tries to generate an IntelliSense configuration even if compilation (verify) should fail. vscode-arduino now tries to generate a IntelliSense configuration even if Arduino's verify failed (if the main sketch compilation was invoked before anything failed)
23+
**2020-02-09** Moved vscode-arduino specific from cocopa over (to keep cocopa as generic as possible). More unit testing within cocopa. Some research regarding future serial monitor implementation. Implemented c_cpp_properties merging -> compiler analysis results are merged into existing configuration and will preserve configurations of different name than the vscode-studio default configuration name (currently "Arduino"). This opens up the possibility for users to write their own configurations without having to disable the autogeneration. Implemented "write on change" - `c_cpp_properties.json` will only be written if a new configuration has been detected. Now loads of tests have to be written for cocopa.
24+
2325

2426
| | Tasks |
2527
|-----:|:--------|
@@ -32,18 +34,14 @@ Provide a configuration flag which allows the user to turn this feature off - th
3234
| | :heavy_check_mark: Basic setting of parsing result |
3335
| | :heavy_check_mark: Basic file input |
3436
| | :heavy_check_mark: Basic file output |
35-
| | :white_check_mark: Merging of parsing result and existing file content |
36-
| | :white_check_mark: Handling inexistent files and folders |
37-
| | :white_check_mark: Write configuration on change only |
37+
| | :heavy_check_mark: Merging of parsing result and existing file content |
38+
| | :heavy_check_mark: Handling inexistent files and folders |
39+
| | :heavy_check_mark: Write configuration on change only |
3840
| | :white_check_mark: Option to backup old configurations? |
3941
| **Configuration flags** | :heavy_check_mark: Provide global disable flag for IntelliSense auto-config |
4042
| | :heavy_check_mark: Provide project specific override for the global flag - most users will likely use the default setup and disable auto-generation for very specific projects |
4143
| **Unit tests** | :heavy_check_mark: Basic parser (known boards, match/no match)|
42-
| | :heavy_check_mark: Querying of compiler built-in includes (Note: to be changed to generic compiler such that Arduino is not necessary for unit testing) |
43-
| | :white_check_mark: Throwing arbitrary data at parser engines |
44-
| | :white_check_mark: JSON input |
45-
| | :white_check_mark: JSON output |
46-
| | :white_check_mark: Configuration merging |
44+
| | :white_check_mark: All unit tests in cocopa |
4745
| | :white_check_mark: Test with cpp sketches |
4846
| **General** | :white_check_mark: Review and remove previous attempts messing with `c_cpp_properties.json` or IntelliSense. (Partially done - documented in the [General Tasks](#General-Tasks) section |
4947
| | :white_check_mark: Auto-run verify after a) *setting a board* b) *changing the sketch* c) *workbench initialized and no `c_cpp_properties.json` has been found*. We have to generate a valid `c_cpp_properties.json` to keep IntelliSense working in such situations. Identify other occasions where this applies (usually when adding new libraries), hint the user to run *verify*? -> Good moment would be after the workbench initialization -> message in arduino channel |
@@ -53,7 +51,7 @@ Provide a configuration flag which allows the user to turn this feature off - th
5351
| | :heavy_check_mark: Extract compiler command parser from vscode-arduino and [publish](https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c) it as a separate package which will allow reusage and easy testing without heavy vscode-arduino rucksack. Done, see [cocopa](https://www.npmjs.com/package/cocopa) |
5452
| | :white_check_mark: Finally: go through my code and look for TODOs |
5553

56-
`*` not committed to branch yet
54+
`*` not committed to branch yet
5755
`>` most of the actual parsing and configuration generation is part of [cocopa](https://github.com/elektronikworkshop/cocopa/) ([here](https://www.npmjs.com/package/cocopa)'s the npm package)
5856

5957
## Motivation
@@ -79,6 +77,8 @@ I will list every supporter here, thanks!
7977
2020-02-05 Elektronik Workshop: 40 :beers: (10h coding)
8078
2020-02-06 Elektronik Workshop: 36 :beers: (9h coding)
8179
2020-02-07 Elektronik Workshop: 48 :beers: (12h coding)
80+
2020-02-08 Elektronik Workshop: 52 :beers: (13h coding)
81+
2020-02-09 Elektronik Workshop: 40 :beers: (10h coding)
8282

8383
<!-- https://github.com/StylishThemes/GitHub-Dark/wiki/Emoji -->
8484

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@
595595
"dependencies": {
596596
"body-parser": "^1.16.1",
597597
"child_process": "^1.0.2",
598-
"cocopa": "0.0.5",
598+
"cocopa": "0.0.6",
599599
"compare-versions": "^3.4.0",
600600
"eventemitter2": "^4.1.0",
601601
"express": "^4.14.1",

src/arduino/arduino.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ export class ArduinoApp {
835835
ccp.CCppPropertiesCppStandard.Cpp11);
836836
const prop = new ccp.CCppProperties();
837837
prop.read(pPath);
838-
prop.merge(content);
838+
prop.merge(content, ccp.CCppPropertiesMergeMode.ReplaceSameNames);
839839
if (prop.write(pPath)) {
840840
arduinoChannel.info("IntelliSense configuration updated.");
841841
} else {

0 commit comments

Comments
 (0)