Skip to content

Commit 3989690

Browse files
author
Michele Pasinelli
committed
Added CodeLens to show the effective value, support for VSCode 1.109
1 parent d86b6db commit 3989690

10 files changed

Lines changed: 1127 additions & 790 deletions

CHANGELOG.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Changelog
1+
# Changelog
22

33
## 0.1.0
4-
- Prima versione pubblica
5-
- Refresh formule
6-
- Write-back valori
7-
- Migliorato parsing formule
4+
- First public release
5+
- Formula refresh
6+
- Value write-back
7+
- Improved formula parsing
8+
9+
## 0.1.3
10+
- Support for VSCode 1.109
11+
- Added CodeLens to extract the effective value from complex `#define` statements
-302 KB
Binary file not shown.

README.md

Lines changed: 108 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,166 @@
1-
# CalcDocs Formula Hover & Go to Definition
1+
# 🧮 CalcDocs - Formula Hover, Definition and C/C++ Sync
22

3-
Formula navigation and evaluation for YAML engineering formulas and C/C++ constants inside Visual Studio Code.
3+
Formula navigation and evaluation for YAML engineering formulas and C/C++ constants directly inside Visual Studio Code.
44

5-
![CalcDocs Demo](https://raw.githubusercontent.com/mik1981/Calcdocs-VSCode-Extension/main/resources/CalcDocs_Refresh.gif)
5+
![CalcDocs Demo](https://github.com/mik1981/Calcdocs-VSCode-Extension/raw/main/resources/CalcDocs_Refresh.gif)
6+
![CalcDocs Screenshot](https://github.com/mik1981/Calcdocs-VSCode-Extension/raw/main/resources/CalcDocs_Definition.jpg)
67

7-
![CalcDocs Screeshot](https://raw.githubusercontent.com/mik1981/Calcdocs-VSCode-Extension/main/resources/CalcDocs_Definition.jpg)
8+
CalcDocs helps firmware, embedded, and software teams keep formulas, documentation, and source constants aligned.
89

9-
CalcDocs helps firmware, embedded, and software teams keep **technical formulas, documentation, and source code aligned** directly inside the editor.
10+
- GitHub project: [Calcdocs-VSCode-Extension](https://github.com/mik1981/Calcdocs-VSCode-Extension/)
11+
- Issues: [Open an issue](https://github.com/mik1981/Calcdocs-VSCode-Extension/issues)
1012

11-
---
12-
13-
## ✨ Features
13+
## 📑 Index
1414

15-
- Hover over formula symbols in **YAML, C, and C++** files
16-
- **Go to Definition** for:
17-
- formula keys defined in `formulas*.yaml` / `formulas*.yml`
18-
- numeric `#define` and `const` symbols in C/C++
19-
- Formula expansion using known values
20-
- Automatic refresh of YAML formulas
21-
- Numeric evaluation when a formula can be fully resolved
22-
- Automatic update of YAML fields (`dati` and `value`)
23-
- Periodic background analysis of the workspace
24-
- Quick refresh command available in the status bar
15+
- [Install from `.vsix` File (Quick Guide)](#install-from-vsix-file-quick-guide)
16+
- [Features](#features)
17+
- [Commands](#commands)
18+
- [Configuration](#configuration)
19+
- [File Scanning Rules](#file-scanning-rules)
20+
- [Quick Example](#quick-example)
21+
- [Contributing](#contributing)
22+
- [Sponsor](#sponsor)
23+
- [Roadmap](#roadmap)
24+
- [License](#license)
2525

2626
---
2727

28-
## Quick Example
28+
## 📦 Install from `.vsix` File (Quick Guide)
2929

30-
Example YAML formula file:
30+
If you already have the file `calcdocs-vscode-extension-0.1.3.vsix`, you can install it without using the Marketplace.
3131

32-
```yaml
33-
MAX_SPEED:
34-
formula: RPM * WHEEL_RADIUS * 0.10472
35-
unit: m/s
36-
steps:
37-
- Read RPM from sensor
38-
- Convert RPM to rad/s
39-
value: 12.5
32+
**Graphical method (recommended):**
4033

41-
RPM:
42-
value: 1000
34+
1. Open **Visual Studio Code**.
35+
2. Go to the **Extensions** view (left sidebar icon or press `Ctrl+Shift+X`).
36+
3. Click the three dots `...` at the top of the Extensions panel.
37+
4. Select **Install from VSIX...**.
38+
5. Choose the `.vsix` file and confirm.
39+
6. Restart VS Code.
4340

44-
WHEEL_RADIUS:
45-
value: 0.2
41+
**Terminal method (optional):**
42+
43+
```bash
44+
code --install-extension calcdocs-vscode-extension-0.1.3.vsix
4645
```
47-
When hovering on MAX_SPEED or RPM, CalcDocs provides:
48-
- expanded formula
49-
- current values
50-
- navigation to symbol definition
5146

52-
---
47+
**Verify the installation:**
5348

54-
## 🧠 Commands
49+
1. Open the Command Palette (`Ctrl+Shift+P`).
50+
2. Search for `CalcDocs: Forza aggiornamento formule`.
51+
3. If the command is visible, the extension has been installed correctly.
52+
53+
---
5554

56-
### Command Description
57-
CalcDocs: Force formula refresh Rebuilds the formula index and updates YAML values
58-
CalcDocs: Set scan interval Configures periodic background analysis
59-
Status bar refresh Quick manual refresh of formulas
55+
## 🚀 Features
56+
57+
- C/C++ source files always remain under your control; the extension only flags potential misalignments.
58+
- Hover on formula symbols in YAML files.
59+
- Optional fallback hover/definition providers for C/C++ (`calcdocs.enableCppProviders`).
60+
- Go to definition for:
61+
- keys defined in `formula*.yaml` / `formulas*.yml`
62+
- `#define` and `const` symbols found in C/C++ files
63+
- Formula expansion with known symbol values.
64+
- Numeric evaluation when expressions can be fully resolved.
65+
- Recursive resolution of complex C/C++ definitions (`#define` and `const` with dependencies).
66+
- C/C++ CodeLens for composite definitions with computed numeric values.
67+
- Mismatch detection between C/C++ constants and YAML computed values (warning lens when difference is significant).
68+
- YAML write-back of `dati` and `value` fields on refresh.
69+
- Status bar quick refresh and periodic background analysis.
6070

6171
---
6272

63-
## 📂 File Scanning Rules
73+
## ⌨️ Commands
6474

65-
Supported formula files:
66-
- formula*.yaml
67-
- formulas*.yml
75+
| Command | What it does |
76+
| --- | --- |
77+
| `CalcDocs: Forza aggiornamento formule` | Rebuilds index, recalculates formulas, and writes back YAML (`dati`, `value`) |
78+
| `CalcDocs: Imposta intervallo scansione` | Sets periodic scan interval in seconds (`0` disables periodic scan/watchers) |
79+
| Status bar button `CalcDocs` | Manual quick refresh |
6880

69-
Supported code files:
70-
- .c
71-
- .h
72-
- .cpp
73-
- .hpp
81+
---
82+
83+
## ⚙️ Configuration
84+
85+
Available workspace settings:
7486

75-
Customizable ignored folders
76-
Extension activation occurs when opening a YAML file in the workspace.
87+
- `calcdocs.scanInterval` (number, default `0`)
88+
- `calcdocs.ignoredDirs` (string array, folders excluded from analysis)
89+
- `calcdocs.enableCppProviders` (boolean, default `false`, keeps C/C++ tools as primary)
7790

7891
---
7992

80-
## 🚀 Why CalcDocs
93+
## 🔍 File Scanning Rules
94+
95+
Formula files:
96+
97+
- `formula*.yaml`
98+
- `formula*.yml`
99+
- `formulas*.yaml`
100+
- `formulas*.yml`
81101

82-
CalcDocs is useful when engineering formulas, documentation, and source code constants must stay synchronized.
102+
Code files:
83103

84-
It helps teams:
85-
- reduce context switching
86-
- quickly understand formulas
87-
- navigate between documentation and code
88-
- debug engineering calculations faster
104+
- `.c`, `.h`, `.cpp`, `.hpp`, `.cc`, `.hh`
105+
106+
Activation events:
107+
108+
- `onStartupFinished`
109+
- `onLanguage:yaml`
89110

90111
---
91112

92-
## 🔎 Keywords
113+
## 🧪 Quick Example
114+
115+
```yaml
116+
MAX_SPEED:
117+
formula: RPM * WHEEL_RADIUS * 0.10472
118+
unit: m/s
119+
value: 12.5
93120

94-
- vscode
95-
- yaml formulas
96-
- engineering formulas
97-
- embedded development
98-
- c/cpp constants
99-
- formula evaluation
100-
- hover documentation
101-
- go to definition
121+
RPM:
122+
value: 1000
123+
124+
WHEEL_RADIUS:
125+
value: 0.2
126+
```
127+
128+
```c
129+
#define SPEED_LIMIT_FACTOR (RPM / 2 + 10)
130+
const int MAX_SPEED = SPEED_LIMIT_FACTOR * 2;
131+
```
132+
133+
CalcDocs can expand and resolve these symbols, show computed values in hover/CodeLens, and navigate to their definitions.
102134

103135
---
104136

105137
## 🤝 Contributing
106138

107139
Contributions are welcome, especially for:
108140

109-
parser improvements
110-
141+
- parser improvements
111142
- diagnostics
112-
- testing
143+
- tests
113144
- developer experience
114145

115146
---
116147

117148
## ❤️ Sponsor
118149

119-
If you find this extension useful, consider sponsoring the project to support its development.
150+
If you find this extension useful, consider sponsoring the project.
120151

121152
[![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://www.paypal.me/gianmichelepasinelli)
122153

123154
---
124155

125-
## 📌 Roadmap
156+
## 🗺️ Roadmap
126157

127158
Planned improvements:
159+
128160
- YAML schema validation
129-
- more robust expression parsing
130-
- automated tests for YAML write-back
161+
- stronger expression parsing
162+
- more automated tests for YAML write-back
131163
- configurable include/exclude paths
132-
- improved multi-root workspace support
133164

134165
---
135166

363 KB
Binary file not shown.

resources/CalcDocs_Definition.jpg

-27.3 KB
Loading

resources/CalcDocs_Refresh.gif

119 KB
Loading

0 commit comments

Comments
 (0)