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

Fix imports in Kotlin model generation #309

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

MariusVolkhart
Copy link
Contributor

The models project generated Kotlin code that didn't have the correct imports. This happened because the imports were not being tracked as imports in the KotlinCodeGenerator, only as code.

The models project generated Kotlin code that didn't have the correct imports. This happened because the imports were not being tracked as imports in the KotlinCodeGenerator, only as code.
Copy link
Contributor

@edward3h edward3h left a comment

Choose a reason for hiding this comment

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

Looks good to me.

If you could add a test case that would catch this, that would be even better.

Copy link

codecov bot commented Jan 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0c83398) 91.20% compared to head (af3b52f) 91.14%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #309      +/-   ##
============================================
- Coverage     91.20%   91.14%   -0.07%     
+ Complexity     1204     1203       -1     
============================================
  Files            76       76              
  Lines          3139     3140       +1     
  Branches        489      489              
============================================
- Hits           2863     2862       -1     
- Misses          167      168       +1     
- Partials        109      110       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@casid casid merged commit 6cb0fa7 into casid:main Jan 8, 2024
@casid
Copy link
Owner

casid commented Jan 8, 2024

Sorry, I just merged a bit too fast. But the change itself is solid!

@edward3h is there a test for the Java way we could adopt for Kotlin?

@MariusVolkhart MariusVolkhart deleted the mv/kotlinBugFix branch January 10, 2024 02:34
MariusVolkhart added a commit to MariusVolkhart/jte that referenced this pull request Jan 10, 2024
This adds tests for the change made in casid#309
@MariusVolkhart
Copy link
Contributor Author

I'd probably go the route of writing a test that parses a template, produces generated files, and then compares the generated files against golden versions. Thoughts on that?

The challenge is that the jte-models project is the only place where the imports are actually read. The KotlinCodeGenerator doesn't care about the list of imports as it generates code directly.

@casid
Copy link
Owner

casid commented Jan 10, 2024

Indeed, I think writing a test from the jte-models perspective would be ideal, since that's the project that needs the imports as you said.

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