Skip to content

fix: 创建componentPlaceholder问题示例#98

Merged
wangshunnn merged 4 commits into
mainfrom
fix-componentPlaceholder-originalComponent-path
Feb 9, 2026
Merged

fix: 创建componentPlaceholder问题示例#98
wangshunnn merged 4 commits into
mainfrom
fix-componentPlaceholder-originalComponent-path

Conversation

@Triumph-light

@Triumph-light Triumph-light commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator

closes #97

Summary by CodeRabbit

  • New Features

    • Added JSON component support in the inspect extension with proper componentPlaceholder mapping for enhanced component resolution.
  • Bug Fixes

    • Improved usingComponents property parsing logic to be more precise and reliable when identifying component declarations, reducing potential edge case errors.

@coderabbitai

coderabbitai Bot commented Feb 4, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes introduce a new componentPlaceholder mapping for the "json" component in the extension and refine the parsing logic for usingComponents to only apply shorthand property handling when explicitly targeting the usingComponents identifier, with added documentation blocks clarifying the two code paths.

Changes

Cohort / File(s) Summary
Component Placeholder Mapping
inspect-extension/components/script-json/componentPlaceholder.mpx
Adds a new script block defining a componentPlaceholder mapping that assigns the "json" component to a 'view' value and exports it, with documentation noting native components don't error when used as placeholders.
Narrowed Shorthand Property Handling
packages/language-core/src/utils/parseJsonUsingComponents.ts
Restricts shorthand property assignment processing to specifically check for the usingComponents identifier (node.name.text === 'usingComponents') and adds inline documentation distinguishing Case 1 (shorthand) from Case 2 (normal properties).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A mapping springs forth, json finds its way,
With shorthand refined to see clearer today,
ComponentPlaceholder hops into place,
The parser now knows its true resting space! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is in Chinese and uses a vague term '问题示例' (problem example) without clearly conveying what the main fix accomplishes. Replace with a clear English title that specifically describes the fix, such as 'fix: add componentPlaceholder mapping for json component' to make the change immediately understandable.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-componentPlaceholder-originalComponent-path

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
packages/language-core/src/utils/parseJsonUsingComponents.ts (1)

77-119: Nit: the two documentation blocks could be consolidated.

The original multi-line comment on line 77–78 (usingComponents 会是两种情况) is left as a standalone fragment after the refactor. Consider merging it into the Case 1 block or removing it to avoid a dangling comment that reads as incomplete.

Proposed consolidation
-    /**
-     * usingComponents 会是两种情况
-     */
-
-    /**
-     * Case 1 - shorthand property:
+    /**
+     * Case 1 (shorthand property) — usingComponents 会是两种情况:
+     *
+     * Shorthand:

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Triumph-light Triumph-light force-pushed the fix-componentPlaceholder-originalComponent-path branch from 38129c9 to c305b12 Compare February 8, 2026 03:02
@Triumph-light Triumph-light self-assigned this Feb 8, 2026
@wangshunnn wangshunnn merged commit 1c67623 into main Feb 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

componentPlaceholder使用原生组件会提示路径报错

2 participants