Repository navigation
refactor(config): born-valid options, layered decode, drop mirrors - #576
Merged
Merged
Conversation
Feature options structs double as their config sections via defaulted<>
fields, so the field initializers are the single source of every default:
- delete InlayHintsConfig/CodeCompletionConfig mirrors and all three
hand-written field-by-field overlay blocks (apply_defaults, the
compiler.cpp copy sites, inspect's parse_completion_config)
- a default-constructed Config is fully valid; with_defaults() is gone
- apply_defaults() shrinks to finalize(): derived paths, ${workspace}
substitution, canonicalization, rule compilation, and validation of
explicit zero worker/memory values (warned and reset to defaults)
- clean the 0=auto sentinels: worker counts, memory limit, tracker
intervals and project scalars carry real initializer defaults
- workers receive the whole Config on interactive requests instead of
per-feature forwarded option fields (inlay_options/completion_options
deleted); features read their own section
- drop the dead project.max_active_file knob (no reader anywhere)
- fold document_link.h and inactive_regions.h into feature.h
- pin the layering semantics in config unit tests: sections deep-merge
per field across TOML/JSON layers, JSON null is a decode error,
feature-section typos still warn, full born-valid default surface
📝 WalkthroughWalkthroughChangesConfiguration and feature refactor
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/feature/feature.h`:
- Around line 310-318: Update inactive_regions() directive traversal in
inactive_regions.cpp to process only directives within the requested
[resume_offset, end_offset) scan interval before updating stack or serializing
regions. Ensure pending regions are closed at end_offset, and add coverage for
both bounded scans and resumed scans so directives outside the interval do not
affect results.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 26e7162a-01ad-418b-85df-40832a4497a2
📒 Files selected for processing (26)
docs/clice.tomldocs/en/dev/contribution.mddocs/en/guide/configuration.mddocs/zh/dev/contribution.mddocs/zh/guide/configuration.mdsrc/driver/inspect.ccsrc/feature/document_link.hsrc/feature/feature.hsrc/feature/inactive_regions.cppsrc/feature/inactive_regions.hsrc/index/preamble_state.hsrc/server/compiler/compiler.cppsrc/server/compiler/indexer.cppsrc/server/protocol/worker.hsrc/server/service/query.cppsrc/server/state/config.cppsrc/server/state/config.hsrc/server/state/workspace.hsrc/server/transport/lsp_client.cppsrc/server/transport/master_server.cppsrc/server/worker/stateful_worker.cppsrc/server/worker/stateless_worker.cpptests/unit/feature/inactive_region_tests.cpptests/unit/index/tu_index_tests.cpptests/unit/server/config_tests.cpptests/unit/server/query_overlay_tests.cpp
💤 Files with no reviewable changes (7)
- src/feature/document_link.h
- src/feature/inactive_regions.h
- docs/zh/guide/configuration.md
- tests/unit/server/query_overlay_tests.cpp
- tests/unit/index/tu_index_tests.cpp
- docs/clice.toml
- docs/en/guide/configuration.md
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.
What
Unifies the config system around one set of structs and one decode mechanism, then simplifies everything that existed to work around the old split.
One struct set. Feature options structs (
CodeCompletionOptions,InlayHintsOptions) now double as their clice.toml / initializationOptions sections: every field isdefaulted<T>with its default as the field initializer. The all-optional mirror structs (InlayHintsConfig,CodeCompletionConfig) are deleted, along with all three hand-written field-by-field overlay blocks (apply_defaults, the compiler copy sites, inspect's--configparser). Adding a new option key is now a one-line change.Born-valid Config. A default-constructed
Configis fully valid — no two-phase init,with_defaults()is gone.apply_defaults()shrinks tofinalize(): derived paths,${workspace}substitution, canonicalization, rule glob compilation, and validation (an explicit zero worker count / memory budget is warned and reset — it was previously a silent auto sentinel).Layering is the decode. Config sources are decoded sequentially onto one object (clice.toml, then initializationOptions); the decoder only touches named fields and nested sections merge per field. This is the mechanism the server already used for the initializationOptions overlay — the refactor removes everything that duplicated it.
Workers carry the whole Config.
QueryParams/BuildParamslose their per-feature forwarded option fields (inlay_options,completion_options) and carry oneConfig; features read their own section. No per-feature forwarding field is ever added again.Also: the dead
project.max_active_fileknob is removed (it had no reader; unknown keys in existing configs surface as a warning, not an error), and the tinydocument_link.h/inactive_regions.hheaders are folded intofeature.h.Compatibility
No key renames — existing clice.toml files and initializationOptions payloads behave identically, except
max_active_file(now an unknown-key warning) and explicit zero worker counts (now warned and reset instead of silently corrected).Tests
New unit tests pin the load-bearing semantics: section deep-merge across TOML/JSON layers (including a field set in both — later source wins), JSON
nullon an option is a decode error, typos inside feature sections still warn, the full born-valid default surface, and zero-value validation. All four suites pass on RelWithDebInfo plus unit tests under Debug (ASan + assertions); the snap suite passes with zero snapshot diffs, confirming the wire behavior is unchanged.