Skip to content

Fix nested member access and ImageResource pattern detection#96

Open
adamlaw-kraken wants to merge 1 commit intoonevcat:masterfrom
adamlaw-kraken:fix/nested-member-access-support
Open

Fix nested member access and ImageResource pattern detection#96
adamlaw-kraken wants to merge 1 commit intoonevcat:masterfrom
adamlaw-kraken:fix/nested-member-access-support

Conversation

@adamlaw-kraken
Copy link
Copy Markdown

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 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 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.

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.
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.

1 participant