Add CLASS_NAME support and fix Pebble template rendering for plugin templates#1144
Add CLASS_NAME support and fix Pebble template rendering for plugin templates#1144Daniel-ADFA merged 2 commits intostagefrom
Conversation
…emplates
- Add CLASS_NAME token replacement in ZipRecipeExecutor for dynamic class
naming in file paths and template content
- Add KEY_CLASS_NAME constant to ZipTemplateConstants
- Add defaultAppName field to TemplateJson for per-template project name defaults
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughRelease Notes - CLASS_NAME Support and Pebble Template Enhancements
WalkthroughAdded an optional Changes
Sequence DiagramsequenceDiagram
participant Reader as ZipTemplateReader
participant Meta as TemplateMeta (metaJson)
participant Executor as ZipRecipeExecutor
participant Pebble as Pebble Engine
participant ZIP as ZIP Output
Reader->>Meta: read metaJson (includes defaultAppName)
Meta-->>Reader: return defaultAppName
Reader->>Reader: build projectName parameter (default = defaultAppName)
Reader->>Executor: execute recipe with data.name / projectName
Executor->>Executor: sanitize projectName -> className (strip non-alnum)
Executor->>Executor: assemble identifiers including KEY_CLASS_NAME
Executor->>Pebble: render templates with identifiers
Pebble-->>Executor: rendered files/content
Executor->>Executor: replace CLASS_NAME in output paths with className
Executor->>ZIP: write files to ZIP using sanitized paths
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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: 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
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt`:
- Line 37: projectNameParameter currently only has NONEMPTY and the
ZipRecipeExecutor's use of CLASS_NAME_PATTERN with replace(...) can produce
invalid Java identifiers (e.g., leading digits or empty strings); update the
code so either projectNameParameter includes the CLASS_NAME constraint or change
ZipRecipeExecutor sanitization: after applying CLASS_NAME_PATTERN removal, strip
any leading digits, ensure the result starts with a valid Java identifier start
(letter or underscore), and if it becomes empty fallback to a safe default
(e.g., "Project" + timestamp or a sanitized projectNameParameter), referencing
CLASS_NAME_PATTERN and the method in ZipRecipeExecutor that performs the replace
to locate where to implement these checks and fallback logic.
In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt`:
- Around line 89-91: The code sets projectName = projectNameParameter {
metaJson.defaultAppName?.let { default = it } } and allows an empty/whitespace
defaultAppName to override the built-in default; change this to only assign
metaJson.defaultAppName when it is non-blank by trimming and checking
isNotBlank() (or equivalent) before setting default so that blank or whitespace
values do not replace the existing "My Application" fallback.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c2b6d9a7-efc3-4851-90d3-a55f3ad63fa6
📒 Files selected for processing (4)
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipJson.kttemplates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kttemplates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateConstants.kttemplates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt
Show resolved
Hide resolved
templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt
Show resolved
Hide resolved
# Conflicts: # templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt
Screen_recording_20260401_122423.mp4