add shared utilities (Names, NameUtils, TypeMapping) - #8
Conversation
…eMapping) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR introduces shared generator utilities under core/gen to centralize naming helpers and KotlinPoet type mapping logic, along with initial unit tests to lock in expected behavior for downstream code generation.
Changes:
- Add
Names.ktwith KotlinPoetClassName/MemberNamereferences for Ktor, kotlinx.serialization, datetime, and error-handling symbols. - Add
NameUtils.ktstring helpers for casing, enum constant naming, and operation-name generation from HTTP method + path. - Add
TypeMapping.ktto mapTypeRefto KotlinPoetTypeName, plus unit tests forNameUtilsandTypeMapping.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/kotlin/com/avsystem/justworks/core/gen/Names.kt | Adds shared KotlinPoet symbol references for generated code. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt | Adds shared string/name transformation utilities for generators. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/TypeMapping.kt | Adds shared TypeRef → KotlinPoet TypeName mapping. |
| core/src/test/kotlin/com/avsystem/justworks/core/gen/NameUtilsTest.kt | Adds unit tests for NameUtils behavior. |
| core/src/test/kotlin/com/avsystem/justworks/core/gen/TypeMappingTest.kt | Adds unit tests for primitive/collection/reference type mappings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
mzielu
left a comment
There was a problem hiding this comment.
Check the copilot comments as well
- Fix CONTENT_TYPE_APP_JSON to properly reference ContentType.Application as ClassName - Fix inline type separator comment to match actual _ behavior - Rename misleading "mixed case method" test to "uppercase method" - Add tests for all-uppercase input in toCamelCase/toPascalCase - Add missing tests for TypeRef.Inline and TypeRef.Unknown Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…date tests accordingly
There was a problem hiding this comment.
Pull request overview
This PR introduces shared generator utilities in core/gen to centralize KotlinPoet symbol references, provide string/name transformation helpers for code generation, and map the internal TypeRef model to KotlinPoet TypeNames (with accompanying unit tests).
Changes:
- Added
Names.ktwith sharedClassName/MemberNamereferences for Ktor, kotlinx.serialization, kotlinx-datetime, and error-handling types. - Added
NameUtils.ktwith string conversion utilities (toCamelCase,toPascalCase,toEnumConstantName,operationNameFromPath). - Added
TypeMapping.ktto mapTypeRefto KotlinPoetTypeName, plus unit tests forNameUtilsandTypeMapping.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/kotlin/com/avsystem/justworks/core/gen/Names.kt | Centralizes KotlinPoet ClassName/MemberName constants used by generators. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt | Adds name/string transformation helpers for generated identifiers and operation names. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/TypeMapping.kt | Adds TypeRef → KotlinPoet TypeName mapping utility. |
| core/src/test/kotlin/com/avsystem/justworks/core/gen/NameUtilsTest.kt | Unit tests for the new string/name utilities. |
| core/src/test/kotlin/com/avsystem/justworks/core/gen/TypeMappingTest.kt | Unit tests for the new TypeRef → TypeName mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| @Test | ||
| fun `toEnumConstantName returns original for all-special-chars input`() { | ||
| assertEquals("!!!", "!!!".toEnumConstantName()) |
There was a problem hiding this comment.
Do we want EnumConstantName to work like this in this scenario?
The issue is just that returning "!!!" as-is pretends it's a usable enum name when it isn't. Throwing an IllegalArgumentException is the cleaner option - it makes the problem visible at generation time rather than producing code that won't compile.
There was a problem hiding this comment.
but Kotlin Poet will escape it for us
…toEnumConstantName` with additional tests
There was a problem hiding this comment.
Pull request overview
Adds a small set of shared codegen utilities in core to centralize KotlinPoet name references, string naming conversions, and model TypeRef → KotlinPoet TypeName mapping. This supports upcoming generator work by providing reusable building blocks with basic unit tests.
Changes:
- Introduces
Names.ktwith centralized KotlinPoetClassName/MemberNamereferences for Ktor, kotlinx.serialization, datetime, and shared client/error symbols. - Adds
NameUtils.ktstring utilities for casing/identifier transformations and deriving operation names from method+path. - Adds
TypeMapping.ktfor convertingTypeRefinto KotlinPoetTypeName, plus unit tests forNameUtilsandTypeMapping.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/kotlin/com/avsystem/justworks/core/gen/Names.kt | Centralizes KotlinPoet references for generator output (Ktor/serialization/datetime/error/client-base). |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt | Adds shared string naming utilities used by parsing/generation layers. |
| core/src/main/kotlin/com/avsystem/justworks/core/gen/TypeMapping.kt | Adds TypeRef → KotlinPoet TypeName mapping used by generators. |
| core/src/test/kotlin/com/avsystem/justworks/core/gen/NameUtilsTest.kt | Unit tests covering casing and operation naming helpers. |
| core/src/test/kotlin/com/avsystem/justworks/core/gen/TypeMappingTest.kt | Unit tests covering primitive/collection/reference/inline/unknown type mappings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Summary
Names.kt— constants for Ktor, kotlinx.serialization, and error handling class namesNameUtils.kt— string utilities (toCamelCase, toPascalCase, toEnumConstantName, operationNameFromPath)TypeMapping.kt— maps TypeRef to KotlinPoet TypeNameStack
master🤖 Generated with Claude Code