Support addPath in Icon Generation#840
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughA new boolean configuration flag 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@tools/cli/src/main/kotlin/io/github/composegears/valkyrie/cli/command/SvgXmlToImageVectorCommand.kt`:
- Line 242: Add a CLI boolean option for usePathDataString and thread it through
to the generator instead of hardcoding false: add a booleanOption(...) for
usePathDataString in SvgXmlToImageVectorCommand alongside the other options
(useComposeColors, addTrailingComma, useFlatPackage), update
SvgXmlToImageVectorCommand.run() to pass the parsed flag into
svgXml2ImageVector(...), and modify the svgXml2ImageVector function signature
and its call sites to accept and forward usePathDataString into the
ImageVectorGeneratorConfig construction (replace the hardcoded usePathDataString
= false with the new parameter).
🧹 Nitpick comments (4)
tools/gradle-plugin/src/main/kotlin/io/github/composegears/valkyrie/gradle/internal/task/GenerateImageVectorsTask.kt (1)
91-91:usePathDataStringis hardcoded tofalse— consider exposing it as a configurable Gradle plugin option.Unlike other generation options (
useExplicitMode,addTrailingComma, etc.) which are backed by@Inputproperties,usePathDataStringis hardcoded. This means Gradle plugin users cannot opt into path data string generation. If this is intentional for the initial rollout (IDE-only), a// TODOcomment would help track the gap.sdk/intellij/psi/imagevector/src/main/kotlin/io/github/composegears/valkyrie/sdk/intellij/psi/imagevector/common/KtCallExpression.kt (1)
78-87: Silent empty-list fallback on parse failure — consider whether this is acceptable.When
PathParser.parsePathStringthrows (Line 86),runCatchingsilently returns an empty path list. This means a malformedpathDatastring in the source file will produce an icon with no visible paths, with no indication of the parse error. The same silent-failure pattern applies to the early-return guards.This is consistent with the other
extract*/parse*functions in this file that return defaults on missing/invalid input, so it may be intentional. Just flagging in case logging the error or propagating it would be preferred for debuggability.sdk/intellij/psi/imagevector/src/main/kotlin/io/github/composegears/valkyrie/sdk/intellij/psi/imagevector/parser/RegularImageVectorPsiParser.kt (2)
71-83: Consider usingwhenorelse ifto avoid redundant checks.The sequential
ifstatements mean all three conditions are evaluated even after a match. Awhenexpression would be more idiomatic and slightly more efficient, though this follows the existing pattern in the file.♻️ Suggested refactor
private fun KtCallExpression.parseVectorNode(): IrVectorNode? { - var node: IrVectorNode? = null - if (calleeExpression?.text == "path") { - node = parsePath() - } - if (calleeExpression?.text == "addPath") { - node = parseAddPath() - } - if (calleeExpression?.text == "group") { - node = parseGroup() - } - return node + return when (calleeExpression?.text) { + "path" -> parsePath() + "addPath" -> parseAddPath() + "group" -> parseGroup() + else -> null + } }
126-140:parseAddPathlargely duplicatesparsePath— consider extracting shared parameter parsing.Both
parseAddPath(lines 126–140) andparsePath(lines 107–124) constructIrVectorNode.IrPathwith identical field extraction logic for all parameters exceptpaths. A shared helper could reduce duplication, but this is manageable given the scope.
|
@t-regbs what about cli and gradle plugin? |
will push changes adding that in a bit |
07367f9 to
9d9bdb1
Compare
…tion and settings UI
…r cli and gradle plugin
4285afa to
3f00101
Compare
|
Perfect! |
Adds support for addPath in icon preview and adds a settings option for addPath for icon generation.
Closes #783
Todo: