Fix reactive highlighting of property access names#8725
Open
Conversation
Reactive variable highlighting was incorrectly decorating property names when they matched a known variable. For example, given variables `mcp` and `tool`, the expression `mcp.tool` would highlight both `mcp` and `tool`, even though `tool` after the dot is a property access, not a variable reference. This was especially confusing with decorator syntax like `@mcp.tool`. The fix checks whether a `VariableName` node is preceded by a `.` sibling in the syntax tree, and if so, skips it.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines the reactive-reference analyzer used by the CodeMirror integration to avoid highlighting reactive variables when a matching identifier is used as an attribute/property name (e.g. the tool part of mcp.tool or @mcp.tool).
Changes:
- Add an
isPropertyAccess()check to excludeVariableNamenodes that are preceded by a.token from reactive highlighting. - Add snapshot tests intended to verify that property/attribute names are not highlighted as reactive references.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
frontend/src/core/codemirror/reactive-references/analyzer.ts |
Adds isPropertyAccess() and integrates it into shouldHighlightVariable to suppress highlighting of attribute/property identifiers. |
frontend/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts |
Adds tests/snapshots around @mcp.tool to ensure property names aren’t highlighted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1118
to
+1124
| test("should not highlight attribute access matching a for-loop variable", () => { | ||
| // When `tool` is used as a for-loop variable, `mcp.tool` (attribute access) | ||
| // should NOT have `tool` highlighted — it's a property, not a variable reference. | ||
| expect( | ||
| runHighlight( | ||
| ["mcp", "client"], | ||
| ` |
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.
Reactive variable highlighting was incorrectly decorating property names when they matched a known variable. For example, given variables
mcpandtool, the expressionmcp.toolwould highlight bothmcpandtool, even thoughtoolafter the dot is a property access, not a variable reference. This was especially confusing with decorator syntax like@mcp.tool.The fix checks whether a
VariableNamenode is preceded by a.sibling in the syntax tree, and if so, skips it.