C++ type use cases will update includes#48
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors C++ code generation to properly manage include statements when working with different data types. The key change is replacing FileData parameters with ImportsBlock parameters across multiple use cases, allowing direct management of C++ header includes based on the types being used.
- Updates type-related use cases to accept
ImportsBlockinstead ofFileDatafor more targeted include management - Adds logic to automatically add necessary C++ standard library includes (e.g.,
<vector>,<string>,<cstdint>,<optional>) when corresponding types are used - Expands test coverage to verify that includes are correctly added when types are referenced
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/enumGoldErrors.groovy | Adds a new test data class GroovyData2 with array field to exercise array type handling |
| cgen-lib/src/test/java/generators/cpp/PrepareRightValueUseCaseTest.kt | Updates tests to use ImportsBlock instead of FileData parameter |
| cgen-lib/src/test/java/generators/cpp/GetTypeNameUseCaseTest.kt | New test file verifying that type usage correctly adds required includes |
| cgen-lib/src/test/java/generators/cpp/GetArrayDataTypeUseCaseTest.kt | Updates tests to pass ImportsBlock and adds verification that <vector> include is added |
| cgen-lib/src/main/kotlin/generators/cpp/PrepareRightValueUseCase.kt | Changes signature to accept ImportsBlock instead of FileData |
| cgen-lib/src/main/kotlin/generators/cpp/GetTypeNameUseCase.kt | Adds logic to automatically add includes based on types and changes to use ImportsBlock |
| cgen-lib/src/main/kotlin/generators/cpp/GetArrayDataTypeUseCase.kt | Updates to add <vector> include when generating array types |
| cgen-lib/src/main/kotlin/generators/cpp/CppEnumGenerator.kt | Updates to pass ImportsBlock to use cases |
| cgen-lib/src/main/kotlin/generators/cpp/CppDataClassGenerator.kt | Updates to pass ImportsBlock to use cases |
| cgen-lib/src/main/kotlin/generators/cpp/CppConstantsBlockGenerator.kt | Updates to pass ImportsBlock to use cases |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| @Test | ||
| fun getArrayTypeAddvectorToImports() { |
There was a problem hiding this comment.
Corrected spelling: 'Addvector' should be 'AddsVector' to match camelCase naming convention.
| fun getArrayTypeAddvectorToImports() { | |
| fun getArrayTypeAddsVectorToImports() { |
| DataType.uint8Nullable, | ||
| DataType.uint16Nullable, | ||
| DataType.uint32Nullable, | ||
| DataType.uint64Nullable-> { |
There was a problem hiding this comment.
Missing space before the arrow operator. Should be DataType.uint64Nullable -> for consistency with Kotlin style conventions.
| DataType.uint64Nullable-> { | |
| DataType.uint64Nullable -> { |
| else -> { | ||
|
|
||
| } |
There was a problem hiding this comment.
Empty else branch serves no purpose and reduces code clarity. Consider removing it entirely.
| else -> { | |
| } | |
| // No action needed for other types |
No description provided.