Skip to content

add shared utilities (Names, NameUtils, TypeMapping) - #8

Merged
halotukozak merged 5 commits into
masterfrom
feat/shared-utilities
Mar 18, 2026
Merged

add shared utilities (Names, NameUtils, TypeMapping)#8
halotukozak merged 5 commits into
masterfrom
feat/shared-utilities

Conversation

@halotukozak

Copy link
Copy Markdown
Contributor

Summary

  • Names.kt — constants for Ktor, kotlinx.serialization, and error handling class names
  • NameUtils.kt — string utilities (toCamelCase, toPascalCase, toEnumConstantName, operationNameFromPath)
  • TypeMapping.kt — maps TypeRef to KotlinPoet TypeName

Stack

  1. this PRmaster
  2. feat/model-generation → feat/shared-utilities
  3. feat/client-generation → feat/model-generation

🤖 Generated with Claude Code

…eMapping)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 17, 2026 13:52
@halotukozak
halotukozak requested a review from mzielu March 17, 2026 13:53
@halotukozak halotukozak changed the title feat: add shared utilities (Names, NameUtils, TypeMapping) add shared utilities (Names, NameUtils, TypeMapping) Mar 17, 2026
@halotukozak halotukozak self-assigned this Mar 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.kt with KotlinPoet ClassName/MemberName references for Ktor, kotlinx.serialization, datetime, and error-handling symbols.
  • Add NameUtils.kt string helpers for casing, enum constant naming, and operation-name generation from HTTP method + path.
  • Add TypeMapping.kt to map TypeRef to KotlinPoet TypeName, plus unit tests for NameUtils and TypeMapping.

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.

Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/Names.kt Outdated
Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt

@mzielu mzielu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the copilot comments as well

Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt
Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/TypeMapping.kt Outdated
halotukozak and others added 2 commits March 17, 2026 18:29
- 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>
Copilot AI review requested due to automatic review settings March 17, 2026 17:32
@halotukozak
halotukozak requested a review from mzielu March 17, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.kt with shared ClassName/MemberName references for Ktor, kotlinx.serialization, kotlinx-datetime, and error-handling types.
  • Added NameUtils.kt with string conversion utilities (toCamelCase, toPascalCase, toEnumConstantName, operationNameFromPath).
  • Added TypeMapping.kt to map TypeRef to KotlinPoet TypeName, plus unit tests for NameUtils and TypeMapping.

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 TypeRefTypeName 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.

Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/Names.kt
Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt

@mzielu mzielu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small things left

Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt

@Test
fun `toEnumConstantName returns original for all-special-chars input`() {
assertEquals("!!!", "!!!".toEnumConstantName())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but Kotlin Poet will escape it for us

…toEnumConstantName` with additional tests
Copilot AI review requested due to automatic review settings March 18, 2026 09:35
@halotukozak
halotukozak requested a review from mzielu March 18, 2026 09:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.kt with centralized KotlinPoet ClassName / MemberName references for Ktor, kotlinx.serialization, datetime, and shared client/error symbols.
  • Adds NameUtils.kt string utilities for casing/identifier transformations and deriving operation names from method+path.
  • Adds TypeMapping.kt for converting TypeRef into KotlinPoet TypeName, plus unit tests for NameUtils and TypeMapping.

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.

Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/Names.kt
Comment thread core/src/main/kotlin/com/avsystem/justworks/core/gen/NameUtils.kt

@mzielu mzielu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@halotukozak
halotukozak merged commit 25104b5 into master Mar 18, 2026
5 checks passed
@halotukozak
halotukozak deleted the feat/shared-utilities branch March 18, 2026 09:52
@halotukozak halotukozak added this to the 0.0.1 milestone Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants