Skip to content

Conversation

@vshcryabets
Copy link
Owner

No description provided.

@vshcryabets vshcryabets requested a review from Copilot October 27, 2025 20:05
@vshcryabets vshcryabets self-assigned this Oct 27, 2025
@vshcryabets vshcryabets marked this pull request as ready for review October 27, 2025 20:05
Copy link
Contributor

Copilot AI left a comment

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 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 ImportsBlock instead of FileData for 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() {
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Corrected spelling: 'Addvector' should be 'AddsVector' to match camelCase naming convention.

Suggested change
fun getArrayTypeAddvectorToImports() {
fun getArrayTypeAddsVectorToImports() {

Copilot uses AI. Check for mistakes.
DataType.uint8Nullable,
DataType.uint16Nullable,
DataType.uint32Nullable,
DataType.uint64Nullable-> {
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Missing space before the arrow operator. Should be DataType.uint64Nullable -> for consistency with Kotlin style conventions.

Suggested change
DataType.uint64Nullable-> {
DataType.uint64Nullable -> {

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 46
else -> {

}
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Empty else branch serves no purpose and reduces code clarity. Consider removing it entirely.

Suggested change
else -> {
}
// No action needed for other types

Copilot uses AI. Check for mistakes.
@vshcryabets vshcryabets merged commit cd0df0d into main Oct 27, 2025
2 checks passed
@vshcryabets vshcryabets deleted the fix/cpp_imports branch October 27, 2025 20:50
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