-
-
Notifications
You must be signed in to change notification settings - Fork 345
feat: Include line numbers for file references in .po files from useExtracted & incorporate for sorting of messages
#2201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
Make StrictExtractedMessage and its fields public. Add a test for merging duplicate messages while preserving descriptions. Co-authored-by: jan <[email protected]>
Co-authored-by: jan <[email protected]>
| relativeFilePath, | ||
| message.references | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description merging uses last file instead of first
The PR discussion states that "a description is picked up as soon as any message has one and then kept for all entries" (first description wins). However, the merging logic at lines 315-319 only copies from prevMessage to message if message[key] is null. This means if a later file has a description, it overwrites the earlier one. The test expects "Description from FileZ" but FileY.tsx is processed first (alphabetically) and has a description, so it should be "Description from FileY" per the stated requirement.
Additional Locations (1)
Co-authored-by: Cursor Agent <[email protected]>
.po files from useExtracted & incorporate for sorting of messages
Change notes for consumers
Implementation
The
Referencestruct now includes alinefield alongsidepath, enabling consumers to know exactly where each message was found in the source file.Before:
{ "id": "+YJVTi", "message": "Hey!", "references": [{ "path": "src/Component.tsx" }] }After:
{ "id": "+YJVTi", "message": "Hey!", "references": [{ "path": "src/Component.tsx", "line": 5 }] }Approach
Used SWC's
PluginSourceMapProxyto look up line numbers from AST span positions. This is SWC's internal position tracking (always available during parsing), not the optional output source maps (.mapfiles).Considerations
Performance:
lookup_char_posuses O(log n) binary search on pre-computed line offsets. Only called once per extracted message, not on every AST node visit.Source map availability:
PluginSourceMapProxyis only constructible in the plugin environment. UsedOption<PluginSourceMapProxy>to allow tests to passNone(tests validate AST output, not emitted results).Line numbering: SWC's
lookup_char_posreturns 1-indexed line numbers (first line is 1).Column numbers: Deliberately excluded—line numbers provide sufficient granularity for the use case without adding noise to the output.
Input vs output source maps: The position tracking we use is always available (SWC needs it for error reporting). This is independent of whether output source maps are configured.
Note
Introduces precise source locations for extracted messages and aligns sorting with reference path and line.
linefor each reference, aggregates duplicate usages, and exposes results; new JSON fixtures validate outputExtractorMessageReference.line; addcompareReferencesand sort messages by path then line inutilsCatalogManagermerges per-file references, preserves other-file refs, sorts withcompareReferences, and ignores refs in equality checks;.pooutputs include line numbers.pocatalogs updatedpo-parserto^2.1.1; addindexmapto SWC pluginWritten by Cursor Bugbot for commit 9ca7057. This will update automatically on new commits. Configure here.