Fix issue#248 - #249
Merged
Merged
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #248 by fixing Kotlin bindings code generation for function paths that are nested, numeric-prefixed, or otherwise not directly valid Kotlin identifiers, ensuring the generated sources compile and preserve original Minecraft IDs.
Changes:
- Updated function binding generation to emit valid Kotlin identifiers, avoid naming collisions, and preserve original function IDs in
asId()mappings. - Extended the codegen model (
KtPropertySpec+ renderer) to supportvarproperties and accessor-based properties (getter/setter) needed for interface implementations. - Added/updated tests to cover edge cases (nested directories, numeric names, punctuation, collisions) and contract conformance (
FunctionArgument).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| bindings/src/jvmTest/kotlin/io/github/ayfri/kore/bindings/ImportingTests.kt | Updates JVM import/codegen assertions to validate accessor-based namespace and presence of directory. |
| bindings/src/commonTest/kotlin/io/github/ayfri/kore/bindings/CommonExploreAndRenderTests.kt | Adds comprehensive edge-case tests ensuring generated function bindings compile and preserve IDs. |
| bindings/src/commonMain/kotlin/io/github/ayfri/kore/bindings/generation/identifiers.kt | Introduces Kotlin-safe identifier conversion + per-scope unique name allocation. |
| bindings/src/commonMain/kotlin/io/github/ayfri/kore/bindings/generation/enumGenerators.kt | Reworks function bindings generation to use safe names, avoid collisions, and map asId() to original paths. |
| bindings/src/commonMain/kotlin/io/github/ayfri/kore/bindings/generation/codegen/KtType.kt | Extends KtPropertySpec to support mutability and accessors (getter/setter) with nullable initializers. |
| bindings/src/commonMain/kotlin/io/github/ayfri/kore/bindings/generation/codegen/KtRenderer.kt | Updates property rendering to support var and render accessors beneath property declarations. |
Suppressed comments (1)
bindings/src/commonMain/kotlin/io/github/ayfri/kore/bindings/generation/enumGenerators.kt:207
generateFunctionsEnumTreeiteratesfunctionsin its original order when emittingrootFunctionsand enum entries. Sincefunctionsoriginates from filesystem/zip ordering, this can make the generated source order non-deterministic. Iterating in a stable order (e.g.sortedBy(Function::id)) here would make output consistent across runs.
val rootFunctions = mutableListOf<KtTypeSpec>()
val functionGroups = mutableMapOf<String, FunctionEnumGroup>()
functions.forEach { function ->
val path = function.id.substringAfter(":")
val parent = parentPath(path)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+114
to
+116
| val entries = functions.map { function -> | ||
| entriesById.getValue(function.id) to function.id.substringAfter(":") | ||
| } |
Comment on lines
90
to
+94
| if (mods.isNotEmpty()) sb.append(mods.joinToString(" ")).append(" ") | ||
| sb.append("val ").append(prop.name) | ||
| sb.append(if (prop.mutable) "var " else "val ").append(prop.name) | ||
| prop.type?.let { sb.append(": ").append(it.simpleName) } | ||
| sb.append(" = ").append(prop.initializer).append("\n") | ||
| prop.initializer?.let { sb.append(" = ").append(it) } | ||
| sb.append("\n") |
Ayfri
added a commit
that referenced
this pull request
Aug 4, 2026
… identifiers left in Resources/Tags generators after #249.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixed issue #248