Repository navigation
Correctness: workspace index, watched files, saved edits, settings changes (3/4) - #43
Merged
Merged
Conversation
Workspace index (`core::workspace`)
- At startup, the RDF files of the workspace folders (`.ttl`, `.nt`,
`.owl`, `.trig`, `.n3`) are loaded as background documents, so their
classes, properties and shapes are known without opening them. Hidden
folders, `node_modules` and `target` are skipped; at most 500 files of
at most 5 MB per folder; RDF/XML and HTML are skipped. Clients that send
only a `rootUri` get it as their workspace. Disable with
`"disabled": ["workspace_index"]`. `FsTrait::walk` provides the bounded
walk (nothing for file systems without one).
Files changed on disk (`workspace/didChangeWatchedFiles`)
- The server registers a watcher for RDF files when the client supports
dynamic registration.
- A changed background document is reloaded from disk, a deleted one is
dropped (its triples and shapes too), and a new RDF file in the
workspace is indexed. A file open in the editor keeps the editor's text.
Saved edits (`textDocument/didSave`)
- Saving one of the user's own background documents (not a cache file)
loads its triples into the shared store, so other documents see the
saved classes and properties; closing it restores the saved version.
Unsaved edits still never reach the store.
Settings changes (`workspace/didChangeConfiguration`)
- The settings (either the settings object or `{ "swls": … }`) are applied
like `initializationOptions`, combined with the config files. Newly
configured ontologies and shapes are loaded (the new `ConfigChanged`
schedule; loading is idempotent), and open documents are re-checked.
Invalid settings are reported and the current ones kept.
Tests over stdio: workspace files are indexed (skipping `node_modules`
and hidden folders), watchers are registered, changed / deleted / created
files update completions, a saved workspace file makes its changes known,
and a settings change applies without a restart.
The workspace walk now uses the `ignore` crate (ripgrep's), so it skips what git would ignore: `.gitignore` files at every level, `.git/info/exclude`, the global git excludes and `.ignore` files, also outside a git repository. Hidden entries, `node_modules` and `target` stay skipped regardless. Files created after startup follow the same rule: before indexing a new file, `FsTrait::is_ignored` checks the ignore files between the workspace folder and the file (`util::fs::is_ignored`; the global git excludes only apply to the startup walk). Tests: the walk and `is_ignored` agree on nested `.gitignore` files, a negated pattern, `node_modules`, hidden folders and `.git/info/exclude`; over stdio, an ignored folder is not indexed at startup, nor is a file created in it later.
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.
Third of four stacked PRs, based on #42 (which is based on #41). This PR's diff only shows its own commits.
Workspace index (
core::workspace)At startup, the RDF files of the workspace folders are loaded as background documents, so their classes, properties and shapes are known without opening them.
.ttl,.nt,.owl,.trigand.n3..gitignorefiles at every level,.git/info/exclude, the global git excludes and.ignorefiles, also outside a git repository (via theignorecrate, the one ripgrep uses);node_modulesandtarget;rootUriget it as their workspace."disabled": ["workspace_index"].FsTrait::walkandFsTrait::is_ignoredprovide the bounded, ignore-aware walk. File systems without one (e.g. wasm) find nothing.Indexed shape files are known, but they do not apply to other documents automatically. As before, shapes apply when they are configured (
shapes), imported (owl:imports), or in the same document.Files changed on disk (
workspace/didChangeWatchedFiles)Saved edits (
textDocument/didSave)Settings changes (
workspace/didChangeConfiguration){ "swls": … }. They are applied likeinitializationOptionsand combined with the config files.ConfigChangedschedule. Loading is idempotent, so an ontology is never added twice.initializecannot change.Testing
node_modulesand hidden folders;completion_classdisabled) applies without a restart.is_ignoredagree on nested.gitignorefiles, a negated pattern,node_modules, hidden folders and.git/info/exclude.cargo test --workspace(602 tests),cargo fmt --all --checkandcargo clippy --workspace --all-targets -- -D warnings(Rust 1.100) pass.