feat(preproc): build macro expansion provenance model#237
Merged
Conversation
|
Docs preview: https://vide.pascal-lab.net/preview/pr-237/ |
3 tasks
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.
Summary
This PR builds a source-aware macro expansion provenance path from the preprocessor trace through HIR and into IDE features. The preprocessor model now tracks macro definitions, references, calls, recursive expansions, emitted tokens, token provenance, include chains, and inactive ranges as structured facts. Unsupported transformed-token provenance, unmapped sources, display-only expansion sources, and ambiguous multi-context queries are represented explicitly instead of being collapsed into empty results or text-search recovery.
HIR maps those facts into repository-facing source concepts. Real source files, file-backed virtual sources, display-only virtual expansion text, configured predefines, include buffers, and unmapped sources are represented distinctly. Expansion display text is exposed under
/__vide/preproc/<profile>/expansion/<expansion-id>.svfor hover and range mapping, but is not treated as a parse-stable source buffer unless a file-backed virtual source exists.IDE consumers now go through
hir::preprocfor macro/include facts. This keeps goto, references, hover, inactive-branch handling, and diagnostic target selection on the same authority-driven path. Macro hover now presents the user-facing expansion story: signature, argument bindings, final expanded result, and each nested expansion step, while avoiding internal virtual-buffer or per-token provenance details.Data Flow
flowchart LR A["Source files, include buffers, and configured predefines"] --> B["Source-aware preprocessor trace"] B --> C["Preproc semantic model"] C --> C1["Macro definitions and references"] C --> C2["Macro calls and expansion graph"] C --> C3["Emitted tokens and token provenance"] C --> C4["Include chains and inactive ranges"] C1 --> D["HIR preproc source map"] C2 --> D C3 --> D C4 --> D D --> E["MappedPreprocSource"] E --> E1["RealFile"] E --> E2["VirtualFile file-backed virtual source"] E --> E3["VirtualDisplay display-only expansion text"] E --> E4["Unmapped source"] E3 --> F["/__vide/preproc/<profile>/expansion/<expansion-id>.sv"] D --> G["HIR node to expanded token range"] G --> H["Token provenance"] H --> I["source token"] H --> J["macro call"] H --> K["macro body"] H --> L["macro argument"] H --> M["predefine / builtin"] H --> N["unsupported / unavailable"] D --> O["hir::preproc facade"] O --> P["goto / references / hover"] O --> Q["diagnostic target selection"] O --> R["macro expansion hover"]User-Facing Behavior
vide.tomlwhen an authoritative manifest range exists.Validation
cargo fmt --checkcargo test -p preproccargo test -p hir preproc -- --nocapturecargo test -p ide preproc -- --nocapturecargo check -p idecargo check -p videgit diff --check