Fix nested member access and ImageResource pattern detection#96
Open
adamlaw-kraken wants to merge 1 commit intoonevcat:masterfrom
Open
Fix nested member access and ImageResource pattern detection#96adamlaw-kraken wants to merge 1 commit intoonevcat:masterfrom
adamlaw-kraken wants to merge 1 commit intoonevcat:masterfrom
Conversation
Fixes incomplete detection of Xcode-generated asset symbols for: 1. Folder-organized assets (nested member access) 2. ImageResource dot notation references 3. Asset names containing dots **Problems Fixed:** 1. **Nested Member Access (Issue onevcat#83 follow-up)** PR onevcat#84 added support for simple patterns like `.icFlag`, but didn't handle nested patterns like `Image(.Icons.Settings.logo)` that Xcode generates for folder-structured asset catalogs. 2. **ImageResource Pattern** `ImageResource.homeIcon` and `ImageResource.Icons.Settings.logo` patterns were not detected at all. 3. **Dots in Asset Names** Asset names like "empty.icon" or "navigation-menu.row.icon" were incorrectly converted to `.empty.icon` instead of `.emptyIcon`. The generatedAssetSymbolKey function didn't treat dots as word boundaries like Xcode does. **Solution:** 1. Added regex pattern for nested member access inside Image() calls 2. Added regex pattern for ImageResource dot notation 3. Track ranges to exclude nested patterns from simple matching 4. Updated suffix matching logic for namespaced symbols 5. Fixed generatedAssetSymbolKey to treat dots as word boundaries 6. Added comprehensive tests for all patterns **Testing:** - New tests cover: deeply nested patterns (4+ levels), ImageResource notation, whitespace handling, dots in filenames, and mixed usage - Verified on real iOS project with folder-organized assets **Impact:** This fix makes FengNiao work correctly with modern Xcode projects that organize assets in folders and use type-safe asset symbols.
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.
Fixes incomplete detection of Xcode-generated asset symbols for:
Problems Fixed:
Nested Member Access (Issue Add check unuse for Xcode generated asset symbols #83 follow-up) PR Handle generated asset symbols via member access scanning #84 added support for simple patterns like
.icFlag, but didn't handle nested patterns likeImage(.Icons.Settings.logo)that Xcode generates for folder-structured asset catalogs.ImageResource Pattern
ImageResource.homeIconandImageResource.Icons.Settings.logopatterns were not detected at all.Dots in Asset Names Asset names like "empty.icon" or "navigation-menu.row.icon" were incorrectly converted to
.empty.iconinstead of.emptyIcon. The generatedAssetSymbolKey function didn't treat dots as word boundaries like Xcode does.Solution:
Testing:
Impact:
This fix makes FengNiao work correctly with modern Xcode projects that organize assets in folders and use type-safe asset symbols.