Skip to content

[KMP] Add ImageVector Generator#913

Merged
t-regbs merged 5 commits intomainfrom
feature/kmp-image-vector-generator
Mar 1, 2026
Merged

[KMP] Add ImageVector Generator#913
t-regbs merged 5 commits intomainfrom
feature/kmp-image-vector-generator

Conversation

@t-regbs
Copy link
Copy Markdown
Collaborator

@t-regbs t-regbs commented Feb 27, 2026

refs: #711 #425


📝 Changelog

If this PR introduces user-facing changes, please update the relevant Unreleased section in changelogs:

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 27, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa70f70 and 11654e2.

📒 Files selected for processing (1)
  • components/generator/core/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/core/PathNodeRenderer.kt

Walkthrough

Adds a new Kotlin Multiplatform imagevector generator module and public API under io.github.composegears.valkyrie.generator.kmp.imagevector. New public types: FullQualifiedImports, ImageVectorGenerator (object) with convert(IrImageVector, String, ImageVectorGeneratorConfig): ImageVectorOutput, ImageVectorGeneratorConfig, ImageVectorOutput, and OutputFormat (BackingProperty, LazyProperty). Implements file-level generators and renderers (ImageVectorFileGenerator, BackingPropertyRenderer, LazyPropertyRenderer), a central internal ImageVectorRenderer, utilities (CodeWriter, ImportCollector, NodeParams, RenderBlocks), JVM parity tests, buildscript entries, and settings include. Also adds PathNodeRenderer extensions in generator.core and introduces IrFill.Gradient with LinearGradient/RadialGradient implementing it.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[KMP] Add ImageVector Generator' clearly and concisely describes the main change: adding a new ImageVector Generator component for Kotlin Multiplatform, which aligns with the extensive changes across multiple imagevector-related files in the changeset.
Description check ✅ Passed The PR description includes relevant issue references (#711 and #425) and the changelog template with checkboxes for tracking user-facing changes across IntelliJ Plugin, CLI, and Gradle Plugin changelogs, meeting the repository's documentation requirements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/kmp-image-vector-generator

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: 1

🧹 Nitpick comments (5)
components/generator/kmp/imagevector/api/imagevector.api (1)

1-16: Consider renaming FullQualifiedImports before the API settles

Since this is new public ABI, correcting the type name to FullyQualifiedImports now avoids long-term public-surface debt.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/generator/kmp/imagevector/api/imagevector.api` around lines 1 -
16, Rename the public ABI class FullQualifiedImports to FullyQualifiedImports
across the API surface: update the class declaration and all its constructors
and methods (including <init>, synthetic constructors, component1/2/3, copy and
copy$default, equals, hashCode, toString and getters
getBrush/getColor/getOffset) to the new type name, and adjust all
references/usages and generated signatures so the public API exposes
FullyQualifiedImports instead of FullQualifiedImports; ensure any serialization,
reflective lookups, and external consumers are updated to the new name to avoid
breaking the public ABI.
components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt (1)

168-175: Reuse writeBlockCall in addPath mode for consistent multiline formatting

This branch manually writes params, so multiline values (e.g., gradients) are formatted differently than the rest of the renderer. Reusing writeBlockCall keeps output style consistent and reduces duplicate formatting logic.

♻️ Proposed refactor
         val params = collectPathParams(node, config)
         if (config.usePathDataString) {
-            writer.line("${writer.indent(level)}addPath(")
-            params.forEach { writer.line("${writer.indent(level + 1)}$it,") }
-            val tailComma = if (config.addTrailingComma) "," else ""
-            writer.line(
-                "${writer.indent(level + 1)}pathData = addPathNodes(\"${node.paths.asPathDataString().escapeKotlin()}\")$tailComma",
-            )
-            writer.line("${writer.indent(level)})")
+            writeBlockCall(
+                writer = writer,
+                level = level,
+                call = "addPath",
+                params = params + "pathData = addPathNodes(\"${node.paths.asPathDataString().escapeKotlin()}\")",
+                addTrailingComma = config.addTrailingComma,
+                indentMultilineContent = true,
+            )
             return
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt`
around lines 168 - 175, The code manually emits the addPath block (lines using
writer.line, params.forEach, and building pathData) which causes inconsistent
multiline formatting; replace this manual emission with a call to writeBlockCall
in "addPath" mode: call writeBlockCall("addPath", level = level, params = params
+ listOf("pathData =
addPathNodes(\"${node.paths.asPathDataString().escapeKotlin()}\")${if
(config.addTrailingComma) \",\" else \"\"}")) so the existing writeBlockCall
formatting logic is reused and the trailing-comma behavior from
config.addTrailingComma is preserved.
components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImportCollector.kt (1)

92-97: Remove redundant usesColor re-check in linear-gradient scan

flags.usesColor is already set to true on Line 91, so the hasUnnamedColors branch does not change behavior.

♻️ Proposed simplification
                             is IrFill.LinearGradient -> {
                                 flags.usesBrush = true
                                 flags.usesOffset = true
                                 flags.usesColor = true
-                                val hasUnnamedColors = fill.colorStops.any {
-                                    it.irColor.toName() == null || !config.useComposeColors
-                                }
-                                if (hasUnnamedColors) {
-                                    flags.usesColor = true
-                                }
                             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImportCollector.kt`
around lines 92 - 97, The branch that recomputes hasUnnamedColors and sets
flags.usesColor is redundant because flags.usesColor is already set true just
above; remove the hasUnnamedColors computation and the surrounding if block in
ImportCollector (the linear-gradient scan where fill.colorStops and
it.irColor.toName() / config.useComposeColors are checked) so the earlier
flags.usesColor assignment is the single source of truth.
components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorGenerator.kt (1)

17-17: Consider adding validation for indentSize.

Currently indentSize accepts any Int value, including zero or negative numbers, which could produce malformed output. Consider documenting the expected range or adding validation.

This could be addressed with an init block or by using require:

data class ImageVectorGeneratorConfig(
    // ... other fields
    val indentSize: Int,
    // ...
) {
    init {
        require(indentSize > 0) { "indentSize must be positive, was: $indentSize" }
    }
}

Alternatively, document the expected range in a KDoc comment.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorGenerator.kt`
at line 17, The config currently allows any Int for indentSize; add validation
in ImageVectorGeneratorConfig to reject non-positive values (e.g., use an init
block with require(indentSize > 0) and a clear error message) or alternatively
add a KDoc documenting the valid range; update ImageVectorGeneratorConfig (the
data class containing the indentSize property) to enforce or document the
expected positive indentSize.
components/generator/kmp/imagevector/src/jvmTest/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorParityJvmTest.kt (1)

127-140: Consider including format info in assertion for easier debugging.

When an assertion fails, it may not be immediately clear which OutputFormat caused the failure. Consider using assertThat(output).isEqualTo(expected) with a descriptive message or restructure to make the format explicit in failure output.

♻️ Proposed improvement for clearer failure messages
         OutputFormat.entries.forEach { format ->
             val output = ImageVectorGenerator.convert(
                 vector = parserOutput.irImageVector,
                 iconName = parserOutput.iconName,
                 config = configTransform(format),
             ).content

             val expected = format.toResourceText(
                 pathToBackingProperty = backingExpected,
                 pathToLazyProperty = lazyExpected,
             )

-            assertThat(output).isEqualTo(expected)
+            assertThat(output)
+                .describedAs("Output for format: $format")
+                .isEqualTo(expected)
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/generator/kmp/imagevector/src/jvmTest/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorParityJvmTest.kt`
around lines 127 - 140, The test loop over OutputFormat.entries doesn't include
the format in the assertion, making failures ambiguous; update the assertion in
the loop that currently calls assertThat(output).isEqualTo(expected) to include
the format (e.g., use assertThat(output).withFailMessage("Format=%s",
format).isEqualTo(expected) or assertThat(output).describedAs("format=%s",
format).isEqualTo(expected)) so failures show which OutputFormat failed; make
this change near the loop using OutputFormat.entries,
ImageVectorGenerator.convert and format.toResourceText.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImportCollector.kt`:
- Around line 16-18: The import string for the icon pack is built even when
config.iconPackPackage is empty, producing malformed imports like "import
.Icons"; update the condition in ImportCollector (the block that references
config.iconPack, config.iconPackPackage and config.resolvePackageName()) to
require a non-empty/non-blank iconPackPackage before concatenating the package
and icon (e.g. check config.iconPackPackage.isNotBlank() in addition to
config.iconPack.isNotEmpty() and the package inequality) so the import is only
added when a valid package prefix exists.

---

Nitpick comments:
In `@components/generator/kmp/imagevector/api/imagevector.api`:
- Around line 1-16: Rename the public ABI class FullQualifiedImports to
FullyQualifiedImports across the API surface: update the class declaration and
all its constructors and methods (including <init>, synthetic constructors,
component1/2/3, copy and copy$default, equals, hashCode, toString and getters
getBrush/getColor/getOffset) to the new type name, and adjust all
references/usages and generated signatures so the public API exposes
FullyQualifiedImports instead of FullQualifiedImports; ensure any serialization,
reflective lookups, and external consumers are updated to the new name to avoid
breaking the public ABI.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorGenerator.kt`:
- Line 17: The config currently allows any Int for indentSize; add validation in
ImageVectorGeneratorConfig to reject non-positive values (e.g., use an init
block with require(indentSize > 0) and a clear error message) or alternatively
add a KDoc documenting the valid range; update ImageVectorGeneratorConfig (the
data class containing the indentSize property) to enforce or document the
expected positive indentSize.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt`:
- Around line 168-175: The code manually emits the addPath block (lines using
writer.line, params.forEach, and building pathData) which causes inconsistent
multiline formatting; replace this manual emission with a call to writeBlockCall
in "addPath" mode: call writeBlockCall("addPath", level = level, params = params
+ listOf("pathData =
addPathNodes(\"${node.paths.asPathDataString().escapeKotlin()}\")${if
(config.addTrailingComma) \",\" else \"\"}")) so the existing writeBlockCall
formatting logic is reused and the trailing-comma behavior from
config.addTrailingComma is preserved.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImportCollector.kt`:
- Around line 92-97: The branch that recomputes hasUnnamedColors and sets
flags.usesColor is redundant because flags.usesColor is already set true just
above; remove the hasUnnamedColors computation and the surrounding if block in
ImportCollector (the linear-gradient scan where fill.colorStops and
it.irColor.toName() / config.useComposeColors are checked) so the earlier
flags.usesColor assignment is the single source of truth.

In
`@components/generator/kmp/imagevector/src/jvmTest/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorParityJvmTest.kt`:
- Around line 127-140: The test loop over OutputFormat.entries doesn't include
the format in the assertion, making failures ambiguous; update the assertion in
the loop that currently calls assertThat(output).isEqualTo(expected) to include
the format (e.g., use assertThat(output).withFailMessage("Format=%s",
format).isEqualTo(expected) or assertThat(output).describedAs("format=%s",
format).isEqualTo(expected)) so failures show which OutputFormat failed; make
this change near the loop using OutputFormat.entries,
ImageVectorGenerator.convert and format.toResourceText.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9e7b773 and 00a62eb.

📒 Files selected for processing (21)
  • components/generator/kmp/imagevector/api/imagevector.api
  • components/generator/kmp/imagevector/api/imagevector.klib.api
  • components/generator/kmp/imagevector/build.gradle.kts
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorFileGenerator.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorGenerator.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/render/BackingPropertyRenderer.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/render/Common.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/render/LazyPropertyRenderer.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/render/PathNodeRenderer.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/CodeWriter.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImportCollector.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/NodeParams.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/RenderBlocks.kt
  • components/generator/kmp/imagevector/src/jvmTest/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/ImageVectorParityJvmTest.kt
  • components/generator/kmp/imagevector/src/jvmTest/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/common/OutputFormatResource.kt
  • components/generator/kmp/imagevector/src/jvmTest/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/common/TestImageVectorConfig.kt
  • sdk/ir/core/api/core.api
  • sdk/ir/core/api/core.klib.api
  • sdk/ir/core/src/commonMain/kotlin/io/github/composegears/valkyrie/sdk/ir/core/IrFill.kt
  • settings.gradle.kts

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: 1

🧹 Nitpick comments (1)
components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt (1)

95-103: Consider extracting a shared indent helper for consistency.

The manual " ".repeat(config.indentSize * level) calculation works but differs from CodeWriter.indent() used elsewhere. A small shared helper could improve consistency and reduce duplication.

♻️ Example approach

Add a top-level or extension helper:

internal fun indent(size: Int, level: Int): String = " ".repeat(size * level)

Then use it here and potentially refactor CodeWriter.indent() to delegate to it.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt`
around lines 95 - 103, The code in ImageVectorRenderer.kt uses manual "
".repeat(config.indentSize * level) which is inconsistent with
CodeWriter.indent(); add a shared helper function (e.g., internal fun
indent(size: Int, level: Int): String) and replace the manual repeat calls in
the ImageVectorRenderer buildString block (and any similar occurrences) with
indent(config.indentSize, level), and update CodeWriter.indent() to delegate to
this helper so all indentation uses the same implementation; reference
ImageVectorRenderer, CodeWriter.indent(), config.indentSize and level when
making these changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/RenderBlocks.kt`:
- Around line 46-61: When param contains '\n' change the multiline handling so
the comma is appended to the last content line instead of emitted on its own
line: in the block using lines.forEachIndexed { lineIndex, line -> ... } (and
referencing indentMultilineContent, writer.line, param, comma, level), detect
the final index (lineIndex == lines.lastIndex) and, if comma.isNotEmpty(),
include the comma in that writer.line call (respecting the same prefix/indent
logic); remove the separate writer.line("${writer.indent(level + 1)}$comma")
emission so no standalone comma line is produced.

---

Nitpick comments:
In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt`:
- Around line 95-103: The code in ImageVectorRenderer.kt uses manual "
".repeat(config.indentSize * level) which is inconsistent with
CodeWriter.indent(); add a shared helper function (e.g., internal fun
indent(size: Int, level: Int): String) and replace the manual repeat calls in
the ImageVectorRenderer buildString block (and any similar occurrences) with
indent(config.indentSize, level), and update CodeWriter.indent() to delegate to
this helper so all indentation uses the same implementation; reference
ImageVectorRenderer, CodeWriter.indent(), config.indentSize and level when
making these changes.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00a62eb and 7831748.

📒 Files selected for processing (3)
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImportCollector.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/RenderBlocks.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImportCollector.kt

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt`:
- Line 85: The generated builder name isn't escaped before embedding into the
Kotlin string literal: change the add call that currently uses
config.resolveIconBuilderName() to call
config.resolveIconBuilderName().escapeKotlin() so the name is safely quoted
(mirror the existing escapeKotlin() usage used for the "name" param in
NodeParams.kt and for path data in ImageVectorRenderer.kt); update the add("name
= \"${...}\"") expression to use the escaped value to prevent quotes/backslashes
in user-provided names from breaking the generated code.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/NodeParams.kt`:
- Line 103: The escapeKotlin() extension currently only escapes backslashes and
double quotes; update the function (String.escapeKotlin) to also escape dollar
signs (replace "$" with "\$") to prevent Kotlin template interpolation when
generating string literals, and optionally also escape control characters like
newline, carriage return and tab ("\n", "\r", "\t") to be more robust; locate
the String.escapeKotlin implementation and add the additional replace calls in
the chain or sequence so all those characters are properly escaped before
returning.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7831748 and e806c25.

📒 Files selected for processing (10)
  • components/generator/core/api/core.api
  • components/generator/core/api/core.klib.api
  • components/generator/core/build.gradle.kts
  • components/generator/jvm/imagevector/src/main/kotlin/io/github/composegears/valkyrie/generator/jvm/imagevector/spec/Common.kt
  • components/generator/jvm/imagevector/src/main/kotlin/io/github/composegears/valkyrie/generator/jvm/imagevector/spec/PathNodeSpec.kt
  • components/generator/jvm/imagevector/src/main/kotlin/io/github/composegears/valkyrie/generator/jvm/imagevector/util/GroupBuilder.kt
  • components/generator/jvm/imagevector/src/main/kotlin/io/github/composegears/valkyrie/generator/jvm/imagevector/util/PathBuilder.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/NodeParams.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/RenderBlocks.kt
💤 Files with no reviewable changes (1)
  • components/generator/jvm/imagevector/src/main/kotlin/io/github/composegears/valkyrie/generator/jvm/imagevector/spec/PathNodeSpec.kt
✅ Files skipped from review due to trivial changes (1)
  • components/generator/jvm/imagevector/src/main/kotlin/io/github/composegears/valkyrie/generator/jvm/imagevector/util/PathBuilder.kt

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.

🧹 Nitpick comments (1)
components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt (1)

95-102: Centralize indentation via CodeWriter to reduce formatting drift.

builderStart() manually repeats spaces while other sections use CodeWriter.indent(). Reusing the writer’s indent logic keeps formatting rules in one place.

♻️ Proposed refactor
-            append("${indent(2)}$backingName = ${builderStart(config, vector, 2)}")
+            append("${indent(2)}$backingName = ${builderStart(this, config, vector, 2)}")
...
-            append("${indent(1)}${builderStart(config, vector, 1)}")
+            append("${indent(1)}${builderStart(this, config, vector, 1)}")
...
-    private fun builderStart(config: ImageVectorRenderConfig, vector: IrImageVector, level: Int): String {
+    private fun builderStart(
+        writer: CodeWriter,
+        config: ImageVectorRenderConfig,
+        vector: IrImageVector,
+        level: Int,
+    ): String {
...
-                append("${" ".repeat(config.indentSize * (level + 1))}$arg$comma\n")
+                append("${writer.indent(level + 1)}$arg$comma\n")
...
-            append("${" ".repeat(config.indentSize * level)})")
+            append("${writer.indent(level)})")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt`
around lines 95 - 102, The builderStart() implementation in
ImageVectorRenderer.kt currently hardcodes indentation with "${" ".repeat(...)}"
in the buildString; replace those manual repeats with the shared CodeWriter
indentation API (e.g., call writer.indent(level + 1) for each arg line and
writer.indent(level) for the closing parenthesis) so formatting is centralized,
preserve the existing args.forEachIndexed logic and comma/trailing-comma
behavior (config.addTrailingComma) and, if writer is not in scope, accept or
pass a CodeWriter instance into builderStart() to use its indent method.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt`:
- Around line 95-102: The builderStart() implementation in
ImageVectorRenderer.kt currently hardcodes indentation with "${" ".repeat(...)}"
in the buildString; replace those manual repeats with the shared CodeWriter
indentation API (e.g., call writer.indent(level + 1) for each arg line and
writer.indent(level) for the closing parenthesis) so formatting is centralized,
preserve the existing args.forEachIndexed logic and comma/trailing-comma
behavior (config.addTrailingComma) and, if writer is not in scope, accept or
pass a CodeWriter instance into builderStart() to use its indent method.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e806c25 and fa70f70.

📒 Files selected for processing (2)
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/ImageVectorRenderer.kt
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/NodeParams.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/generator/kmp/imagevector/src/commonMain/kotlin/io/github/composegears/valkyrie/generator/kmp/imagevector/util/NodeParams.kt

@t-regbs t-regbs merged commit dc5f8f2 into main Mar 1, 2026
3 checks passed
@t-regbs t-regbs deleted the feature/kmp-image-vector-generator branch March 1, 2026 19:37
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.

2 participants