Add variable/constructor/tvar binding-reference highlighting#2187
Merged
disconcision merged 12 commits intoprobes-IIIfrom Mar 23, 2026
Merged
Add variable/constructor/tvar binding-reference highlighting#2187disconcision merged 12 commits intoprobes-IIIfrom
disconcision merged 12 commits intoprobes-IIIfrom
Conversation
When the caret is on a variable binding (pattern) or reference (expression), highlights related bindings and uses with an underline + subtle background. Supports variables, constructors, and type variables. - StaticsBase: add uses_of_binding (handles let and fun forms) and var_highlight_ids (computes related IDs for any Info.t) - VarHighlight.re: new decoration module computing and rendering overlays - CodeEditable: wire VarHighlight into the decoration layer - editor.css: styling for var-highlight overlays Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the mouse hovers over a variable binding or reference, highlights related bindings and uses with a dashed underline + background. Hover highlights take precedence over caret highlights when present. - Measured: add piece_at_point for point-to-piece hit testing - CodeWithStatics: add hover_id to model state - CodeEditable: add Hover action, extend mousemove handler to dispatch hover updates when no button held, add mouseleave to clear hover - VarHighlight: compute highlights from both caret and hover sources - editor.css: dashed underline style for hover variant Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rewrite uses_of_binding to scan info_map instead of climbing ancestors. The old approach only handled Let/Fun; now works for all binding forms (match/case, fixf, theorem, etc.) without enumerating them. - Fix multiple references: old code used VarMap.lookup (List.assoc_opt) which only returned first co_ctx entry due to CoCtx.union concatenation. - Add bidirectional type variable highlighting (InfoTPat binding→uses). - Disable hover dispatch (infrastructure retained for future re-enablement). - Clean up VarHighlight.re: use DecUtil.abs_style, remove debug logging. - Move styling to CSS (border-bottom + subtle background tint). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9 tests: let ref→binding, let binding→refs, fun params, match/case bindings (both directions), shadowing, multiple refs, type variable ref→binding, type variable binding→refs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- CoCtx.union: properly merge entries for same variable name instead of concatenating (which caused VarMap.lookup to shadow duplicates). - uses_of_binding: use InfoPat.co_ctx directly instead of scanning the entire info_map. O(1) lookup instead of O(n) scan. - Ctx.add_ctrs: use each variant's own annotation ID instead of the type definition's ID, so constructor highlights point to individual constructor declarations rather than the whole sum type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Populate InfoTPat.tvar_co_ctx via a post-processing pass in Statics.mk so uses_of_tvar_binding does O(1) lookup instead of scanning the info_map. Add constructor highlight tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Hover dispatch restored in mousemove handler with equality check to avoid redundant dispatches. Hover highlights shown with dashed underline; caret highlights remain as fallback when hover target has no variable info. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The pattern's co_ctx was only receiving body.co_ctx, so recursive self-references inside the definition weren't visible as uses. Now unions def.co_ctx with body.co_ctx. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Drop hover_id from Model, Hover action variant, mousemove dispatch, piece_at_point, hover CSS, and all related wiring. Caret-based highlighting is sufficient. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Constructor references now register in co_ctx (like Var does), so uses bubble up to the enclosing TyAlias. uses_of_ctr_binding climbs ancestors to read them. Enables definition→uses and reference→sibling highlighting for constructors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pattern constructors (e.g. `A` in `| A => ...`) now contribute to co_ctx via collect_pat_ctr_refs, wired into all expression forms with patterns (Fun, Let, Theorem, FixF, Case). This enables bidirectional highlighting between constructor definitions, expression uses, and pattern uses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@ ## probes-III #2187 +/- ## ============================================== + Coverage 51.20% 51.28% +0.07% ============================================== Files 251 252 +1 Lines 30225 30341 +116 ============================================== + Hits 15478 15561 +83 - Misses 14747 14780 +33
🚀 New features to boost your workflow:
|
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.
tvar_co_ctxto InfoTPat via a single post-processing pass for type variable highlighting