Skip to content

Fix parsing material icon with multiple material paths#767

Merged
egorikftp merged 1 commit intomainfrom
bugfix/idea/psi-parsing
Dec 12, 2025
Merged

Fix parsing material icon with multiple material paths#767
egorikftp merged 1 commit intomainfrom
bugfix/idea/psi-parsing

Conversation

@egorikftp
Copy link
Copy Markdown
Member

telegram-cloud-photo-size-2-5323570023496354769-w

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 11, 2025

Walkthrough

The parser logic has been refactored to support multiple materialPath calls within a single material icon definition, replacing the previous single-path handling. The parsing flow now iterates over all available path calls, extracting and processing each path lambda body with null-safety handling. Corresponding test coverage has been extended with a new test case that validates parsing of icons containing multiple materialPath blocks. Test fixtures and expected output values have been added to support this multi-path scenario.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description only contains an image link with no textual explanation of the changes. Add a written description explaining the fix and why it was necessary, such as describing the problem with single path parsing and how the multiple path support resolves it.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing parsing to support multiple material paths instead of just one.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 bugfix/idea/psi-parsing

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/psi/imagevector/src/main/kotlin/io/github/composegears/valkyrie/psi/imagevector/parser/MaterialImageVectorPsiParser.kt (1)

83-87: Consider narrowing materialPathCalls search scope if getters ever contain multiple icons

childrenOfType<KtCallExpression>() walks the entire KtBlockExpression subtree, so any materialPath call inside the getter (even if unrelated to the primary materialIcon/builder you parse above) will be included. If you later support more complex getter bodies (e.g., multiple icons or helper functions with their own materialPath calls), it may be safer to derive paths from the specific materialIcon/builder lambda body instead of the whole block.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ecfdee and 9a8b165.

📒 Files selected for processing (4)
  • components/psi/imagevector/src/main/kotlin/io/github/composegears/valkyrie/psi/imagevector/parser/MaterialImageVectorPsiParser.kt (2 hunks)
  • components/psi/imagevector/src/test/kotlin/io/github/composegears/valkyrie/psi/imagevector/KtFileToImageVectorParserTest.kt (2 hunks)
  • components/psi/imagevector/src/test/kotlin/io/github/composegears/valkyrie/psi/imagevector/expected/MaterialIcon.kt (1 hunks)
  • components/psi/imagevector/src/test/resources/backing/MaterialIcon.several.materialpath.kt (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
components/psi/imagevector/src/test/resources/backing/MaterialIcon.several.materialpath.kt (1)
components/psi/imagevector/src/test/kotlin/androidx/compose/material/icons/Icons.kt (2)
  • materialIcon (18-29)
  • materialPath (31-47)
components/psi/imagevector/src/main/kotlin/io/github/composegears/valkyrie/psi/imagevector/parser/MaterialImageVectorPsiParser.kt (1)
components/psi/imagevector/src/main/kotlin/io/github/composegears/valkyrie/psi/extension/PsiElement.kt (1)
  • childrenOfType (6-8)
components/psi/imagevector/src/test/kotlin/io/github/composegears/valkyrie/psi/imagevector/expected/MaterialIcon.kt (1)
components/psi/imagevector/src/test/kotlin/androidx/compose/material/icons/Icons.kt (2)
  • materialIcon (18-29)
  • materialPath (31-47)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (4)
components/psi/imagevector/src/test/kotlin/io/github/composegears/valkyrie/psi/imagevector/expected/MaterialIcon.kt (1)

45-86: Expected Percent icon with multiple materialPath blocks looks consistent

The new ExpectedMaterialIconWithoutParam2 mirrors the backing Percent icon (three paths, EvenOdd on the first two, default on the slash) and is well‑structured for asserting the multi‑materialPath parsing behavior.

components/psi/imagevector/src/test/resources/backing/MaterialIcon.several.materialpath.kt (1)

1-62: Backing Percent icon correctly exercises multi‑materialPath parsing

The _percent backing property and Icons.Percent builder follow the existing material icon pattern and define three materialPath blocks with coordinates and PathFillType matching the new expected icon, which is exactly what you need to validate the multi‑path parser change.

components/psi/imagevector/src/test/kotlin/io/github/composegears/valkyrie/psi/imagevector/KtFileToImageVectorParserTest.kt (1)

24-25: New multi‑materialPath test is wired correctly

Importing ExpectedMaterialIconWithoutParam2 and the parse material icon with several materialPath test that reads backing/MaterialIcon.several.materialpath.kt and asserts against that expected icon are consistent with the existing test patterns and should reliably cover the multi‑path parsing behavior.

Also applies to: 100-106

components/psi/imagevector/src/main/kotlin/io/github/composegears/valkyrie/psi/imagevector/parser/MaterialImageVectorPsiParser.kt (1)

63-79: Multi-path parsing logic looks correct and resilient

The new implementation correctly builds one IrPath per materialPath call, preserves order, and safely skips calls with missing/invalid lambda bodies via mapNotNull. This aligns with the PR goal of supporting multiple material paths and avoids failing the entire parse on a single malformed block.

@egorikftp egorikftp merged commit f129f2e into main Dec 12, 2025
4 checks passed
@egorikftp egorikftp deleted the bugfix/idea/psi-parsing branch December 12, 2025 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant