Add workspace scanning to oak_scan and wire it to the LSP#1244
Open
lionel- wants to merge 9 commits into
Open
Conversation
48eb900 to
a29744e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branched from #1243
Progress towards #1212
This PR adds workspace scanning to
oak_scanand wires it into the LSP. The scanner walks a workspace folder, finds packages (anyDESCRIPTIONfile in the tree with aPackagefield, honoring.gitignore) and top-level R scripts, and registers them under aRootinoak_db.The LSP feeds three event types into the scanner:
initializeanddidChangeWorkspaceFoldersupdate workspace roots in the DB.didChangeWatchedFilesapplies surgical updates for single R files. When a change to aDESCRIPTIONfile is detected, this triggers a full rescan of the containing root (package files might be demoted to scripts).Editor-owned URLs (files the editor has open) get special handling because we ignore disk state for those. The editor contents are the source of truth. When a workspace is removed, these files survive and get placed in
OrphanRoot. This way analysis keeps working when a user closes a workspace folder while a buffer from it is still open.Files that leave a live workspace (folder removed, file deleted, buffer closed) route to
StaleRoot. We keep them there for as long as they remain deleted, and we bring them back if they are added again. This allows reusing theFileinputs without creating new ones. Salsa inputs are never garbage collected so reusing them (based on their URL key) avoids unbounded memory growth when e.g. switching git branches, which can delete and bring back many files at a time.Workspace scans run synchronously in the main loop of the LSP in this PR. Since these operations are too heavy to be run synchronously, and would stall requests from user interactions, the next PR moves
them off the main loop.