Skip to content

Commit 2fbe954

Browse files
author
Michele Pasinelli
committed
Extend CodeLens to all C files
1 parent 3989690 commit 2fbe954

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88

99
## 0.1.3
1010
- Support for VSCode 1.109
11-
- Added CodeLens to extract the effective value from complex `#define` statements
11+
- Added CodeLens to extract the effective value from complex `#define` statements
12+
13+
## 0.1.4
14+
- Extended CodeLens to all C files

src/extension.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,53 @@ async function runAnalysis(root: string) {
325325
}
326326

327327
if (!ymlPath) {
328+
// Nessun YAML: continua comunque l’analisi C/C++
329+
if (files.length > 0) {
330+
const { defines, consts, locations } = await collectDefinesAndConsts(files, root);
331+
332+
allDefines.clear();
333+
symbolValues.clear();
334+
symbolDefs.clear();
335+
336+
// Valori da #define numerici
337+
for (const [name, expr] of defines) {
338+
try {
339+
const numeric = safeEval(expr);
340+
symbolValues.set(name, numeric);
341+
allDefines.set(name, expr);
342+
} catch {
343+
// define non numerico: lo teniamo comunque per expandExpression
344+
allDefines.set(name, expr);
345+
}
346+
}
347+
348+
// Valori da const TYPE NAME = NNN;
349+
for (const [key, val] of consts) {
350+
symbolValues.set(key, val);
351+
}
352+
353+
// Location delle define/const
354+
for (const [key, loc] of locations) {
355+
symbolDefs.set(key, loc);
356+
}
357+
358+
// NON cancellare formulaIndex qui → permette mismatch detection minima
359+
output.appendLine(`[CalcDocs] Nessun formulas*.yaml, ma analisi C/C++ completata (${symbolValues.size} valori)`);
360+
361+
updateStatusBar(); // anche se YAML non c’è, la barra non deve sparire
362+
}
363+
364+
return; // Esci, ma senza resettare tutto
365+
}
366+
/* if (!ymlPath) {
328367
formulaIndex.clear();
329368
symbolValues.clear();
330369
symbolDefs.clear();
331370
output.appendLine(`Nessun formulas*.yaml trovato in ${root}`);
332371
updateStatusBar();
333372
return;
334373
}
335-
374+
*/
336375
// Carica YAML
337376
let rawText = "";
338377
let yml: any;

0 commit comments

Comments
 (0)