Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds IntEnum support #484

Merged
merged 5 commits into from
Nov 28, 2022
Merged

feat: Adds IntEnum support #484

merged 5 commits into from
Nov 28, 2022

Conversation

epau
Copy link
Contributor

@epau epau commented Nov 23, 2022

  • Generate IntEnum shapes
  • Moves shared enum casing logic to Utils so it can be easily shared
  • Updates test generator to sort members by lower camel case

Issue #

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

epau added 2 commits November 23, 2022 11:42
- Generate IntEnum shapes
- Moves shared enum casing logic to Utils so it can be easily shared
- Updates test generator to sort members by lower camel case
@epau epau requested a review from jbelkins November 23, 2022 16:45
Comment on lines -230 to -243
var enumCaseName = CaseUtils.toCamelCase(
name.orElseGet {
value
}.replace(Regex("[^a-zA-Z0-9_ ]"), "")
)
if (!SymbolVisitor.isValidSwiftIdentifier(enumCaseName)) {
enumCaseName = "_$enumCaseName"
}

if (shouldBeEscaped && reservedWords.contains(enumCaseName)) {
enumCaseName = SymbolVisitor.escapeReservedWords(enumCaseName)
}

return enumCaseName
Copy link
Contributor Author

Choose a reason for hiding this comment

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

import software.amazon.smithy.swift.codegen.model.nestedNamespaceType
import java.util.*

class IntEnumGenerator(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The contents of this file are mostly taken from the existing EnumGenerator with slight tweaks to support IntEnums specifically.

Copy link
Contributor

@jbelkins jbelkins left a comment

Choose a reason for hiding this comment

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

Do we need an accompanying PR for SDK to un-pin the Smithy version?

@epau
Copy link
Contributor Author

epau commented Nov 28, 2022

Do we need an accompanying PR for SDK to un-pin the Smithy version?

yep! will do that next!

@epau epau merged commit 35d41e8 into main Nov 28, 2022
@epau epau deleted the epau/feat/int-enum branch November 28, 2022 15:04
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.

2 participants