vfp_symbols.ps1: index de simboluri peste cache-ul text si .prg-urile proiectului

Retine intervalul de linii al fiecarei clase/metode/proceduri, ca o potrivire de grep sa
poata fi atribuita clasei si metodei care o contine - ce grep nu poate spune intr-un .vc2,
unde antetul clasei poate fi cu mii de linii deasupra potrivirii si ~2/3 din fisier sunt
proprietati si metadata.

Moduri: -Grep (eticheteaza rezultatele, -CodeOnly taie metadata), -Where fisier:linie,
-Find (unde e definit), -Class (lant de mostenire + metode cu intervale). Indexul se
reconstruieste singur cand cache-ul e mai nou.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ceaeZUhPwyDG4LXPzigUJ
This commit is contained in:
2026-08-03 07:55:57 +03:00
parent 234f6a5e7f
commit 7f06f3ca4c
2 changed files with 317 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ It serves two purposes:
- **`git_sync.ps1`** — the **in-tree** flow (primary for migrated ROA projects): folder-mode recursive over the whole project tree (incl. `COMUN\`), generates the `.??2` text **next to each binary** (not in an external cache) so git tracks readable text instead of binaries. Incremental, converts in a temp staging area and copies back only the text (never touches the SVN working-copy binaries), cleans up orphan `.??2`, continues past per-file failures and exits nonzero on any. Params: `-ProjectRoot`, `-DbfList` (tables converted to `.db2` with data), `-RoundtripExempt`, `-SubDir`. Run at session start and before every `git commit`; do not commit while it reports failures.
- **`vcx2txt.ps1`** — PowerShell script that converts the VFP binaries of a project (read from its `.pjx`) into text under a cache folder, so the code inside `.vcx/.scx/.frx/.mnx/.dbc` binaries becomes greppable. Incremental (skips up-to-date files), does not need the VFP IDE open (uses the compiled `FoxBin2Prg.EXE`). Search-only / non-migrated projects; migrated projects use `git_sync.ps1` instead.
- **`vfp_symbols.ps1`** — symbol index over the text cache and the project's `.prg`: for every class/method/procedure it records the **line range**, so a hit can be attributed to its owner. Answers what grep cannot in a `.vc2` (where the class header may be 13k lines above the hit and ~2/3 of the file is properties/metadata): `-Grep <regex>` labels each match with `class.method` (`-CodeOnly` drops metadata hits), `-Where 'file:line'` names the enclosing member, `-Find <name>` locates the **definition**, `-Class <name>` prints the inheritance chain plus members with their ranges. Rebuilds automatically when the cache is newer (~4s); index is a regenerable `_symbols.tsv` in the cache root.
- **`txt2vcx.ps1`** — the write-back counterpart: regenerates `.vcx/.scx` binaries from edited `.vc2/.sc2` text and copies them back into the project (see "Golden rule" below for scope/limits). `-CacheRoot` defaults to `-ProjectRoot` (in-tree flow: cache→project mapping is identity); pass a separate root only for the old external-cache flow.
- **`vfp_filemap.ps1`** — shared bin↔memo↔text extension map (`.vcx`/`.vct`/`.vc2`, `.scx`/`.sct`/`.sc2`, `.pjx`/`.pjt`/`.pj2`, `.dbf`/`.fpt`/`.db2`, …), dot-sourced by `git_sync.ps1`, `vcx2txt.ps1` and `txt2vcx.ps1` so the mapping stays in one place. Also hosts `Invoke-FoxBin2PrgSafe` (timeout + `taskkill`).
- **`test_roundtrip.ps1`** — standalone fidelity/regression test for the bin→text→bin→text roundtrip and for `txt2vcx.ps1`'s guard rails (staleness, COMUN, missing binary, negative/corrupt input, multi-file runs); parametrized per project. See examples below.
@@ -51,6 +52,16 @@ It serves two purposes:
Then search the cache with Grep (e.g. `PROCEDURE do_salvare`), citing `file:line` from the cache.
Attribute hits to their owning class/method (build the index first, or let it build itself):
```powershell
& 'D:\ROA\UTIL\foxbin2prg\vfp_symbols.ps1' -CacheRoot 'D:\ROA\_vfp_textcache\roagest' -ProjectRoot 'D:\ROA\ROAGEST' -Grep 'do_salvare' -CodeOnly
# -Where 'oavize.vc2:8412' what class/method owns that line (needed before a txt2vcx edit)
# -Find 'do_salvare' where it is DEFINED (grep also returns the call sites)
# -Class frm_avize inheritance chain + members with line ranges
```
Write back an edited `.vc2`/`.sc2` (after reviewing the diff on text):
```powershell