Skip to content

Conversation

@alexgarzao
Copy link
Collaborator

This PR refactors how field types are represented and handled throughout the analyzer and code generator logic, moving from plain strings to the new common.FieldType struct. This change improves type safety and makes it easier to handle composed types (such as slices). The updates touch both production and test code, ensuring consistent usage of FieldType everywhere field types are referenced or validated.

Core refactoring:

  • Replaced string-based field type references with the new common.FieldType struct in all relevant code paths, including struct definitions, validation logic, and test cases. [1] [2] [3] [4] [5]

Analyzer logic updates:

  • Updated field operation checks and key path construction to use FieldType methods and properties, improving correctness when handling nested and composed types. [1] [2]

Test code modernization:

Imports and dependencies:

  • Added necessary imports for the new common package to all affected files. [1] [2] [3] [4]

Composed type support:

  • Added support for composed types (e.g., slices) in validation logic and tests, using the ComposedType property of FieldType. [1] [2]

@alexgarzao alexgarzao self-assigned this Sep 29, 2025
@alexgarzao alexgarzao requested a review from Copilot September 29, 2025 22:03
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 the field type representation from plain strings to a structured common.FieldType struct throughout the codebase, improving type safety and enabling better handling of composed types like arrays, slices, and maps.

  • Introduces common.FieldType struct with BaseType, ComposedType, and Size fields to replace string-based type handling
  • Updates analyzer logic to use FieldType methods for operations validation and key path construction
  • Refactors all test code to use the new type system consistently

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/parser/struct.go Updated Field struct to use common.FieldType instead of string
internal/parser/parser.go Refactored field parsing logic to construct FieldType objects
internal/codegenerator/*.go Updated code generation functions to accept and work with FieldType
internal/analyzer/analyzer.go Modified analyzer to use FieldType methods for validation
internal/common/types.go Added new FieldType struct with IsGoType() and ToString() methods
internal/common/utils.go Removed old IsGoType function in favor of method on FieldType
test files Updated all test cases to construct fields using new FieldType struct

@alexgarzao alexgarzao merged commit 057c05d into main Oct 1, 2025
4 checks passed
@alexgarzao alexgarzao deleted the refact-better-type-field-info branch October 1, 2025 14: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.

3 participants