Update annotation links on rename #89

Open
marfavi wants to merge 14 commits from fix/resync-on-v-rename into main
Owner

Fixes #43.

Renaming a .v file or folder now rewrites affected links in open C files, re-syncs only those documents, and refreshes annotation and inline diagnostics.

Fixes #43. Renaming a `.v` file or folder now rewrites affected links in open C files, re-syncs only those documents, and refreshes annotation and inline diagnostics.
Refresh annotations after files are renamed (#43)
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 39s
Extension / Format, types, lint, extension tests (pull_request) Successful in 2m20s
993b49442d
marfavi changed title from Refresh annotations after files are renamed to WIP: Refresh annotations after files are renamed 2026-10-29 09:54:46 +01:00
Rewrite annotation links to renamed files
Some checks failed
Grammar / Corpus and binding tests (pull_request) Successful in 57s
Extension / Format, types, lint, extension tests (pull_request) Has been cancelled
82dbbc8b1a
Renaming a .v file or a folder left every annotation that linked into it pointing at the old path, so the resync only reported the link as missing. Rewrite those paths in the open C documents first, then re-sync: the annotation store and diagnostics now describe the renamed target.

A renamed C document also leaves its stored annotations and diagnostics keyed by the old URI; drop them before the resync.
Ignore change events already reflected in the cached tree
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 52s
Extension / Format, types, lint, extension tests (pull_request) Successful in 2m17s
00ab47df21
Applying the rename rewrite and syncing before VS Code delivers the change event made documentTree replay that change a second time, which edits the fresh tree with stale offsets. Skip a change whose text the cached tree already describes.
marfavi force-pushed fix/resync-on-v-rename from 00ab47df21
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 52s
Extension / Format, types, lint, extension tests (pull_request) Successful in 2m17s
to 685745ea7e
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 1m4s
Extension / Format, types, lint, extension tests (pull_request) Successful in 2m12s
2026-10-29 19:55:55 +01:00
Compare
marfavi changed title from WIP: Refresh annotations after files are renamed to Update annotation links on rename 2026-10-29 20:25:54 +01:00
EatOreo requested changes 2026-10-30 11:15:08 +01:00
Dismissed
@ -38,0 +149,4 @@
}
}
return links;
}
Owner

I don't want all this (line 46-152) in this file but in another one

I don't want all this (line 46-152) in this file but in another one
marfavi marked this conversation as resolved
@ -215,0 +370,4 @@
const affected = new Set<string>();
for (const document of vscode.workspace.textDocuments) {
if (document.languageId !== 'c') continue;
const annotations = await checkAnnotations(
Owner

we are parsing all annotations again? arent they up to date in the annotationsStore?

we are parsing all annotations again? arent they up to date in the annotationsStore?
marfavi marked this conversation as resolved
Merge branch 'main' into fix/resync-on-v-rename
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 1m6s
Extension / Format, types, lint, extension tests (pull_request) Successful in 3m8s
228939c4ff
Refactor rename link handling and document it
Some checks failed
Extension / Format, types, lint, extension tests (pull_request) Has been cancelled
Grammar / Corpus and binding tests (pull_request) Has been cancelled
734f562e89
Move the rename path/link helpers out of documentSync into renameLinks.ts, as requested in review. Use the annotation store for open C documents instead of reparsing every annotation during a rename.

Document renaming a Rocq file or folder as a feature in the README and changelog.
Match stored annotations by URI string
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 1m10s
Extension / Format, types, lint, extension tests (pull_request) Successful in 3m31s
a79f059579
The annotation store is keyed by the URI objects documents were opened with, which are not guaranteed to be the event document's URI object. Compare string forms so the rename pass reliably finds the cached annotations.
@ -215,0 +241,4 @@
*/
function storedAnnotations(
uri: vscode.Uri,
): readonly (FunctionAnnotation | LoopAnnotation)[] | undefined {
Owner

the annotationStore should just use strings as keys instead of uri's this would safe us from doing all this, but lets just add it for now

the annotationStore should just use strings as keys instead of uri's this would safe us from doing all this, but lets just add it for now
EatOreo approved these changes 2026-10-30 14:23:26 +01:00
Dismissed
EatOreo left a comment

fix annotationStore

fix annotationStore
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 1m10s
Required
Details
Extension / Format, types, lint, extension tests (pull_request) Successful in 3m31s
Required
Details
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'fix/resync-on-v-rename:fix/resync-on-v-rename'
git switch 'fix/resync-on-v-rename'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code2rocq/crocq!89
No description provided.