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

Rename classes to avoid name clashes #642

Merged
merged 9 commits into from
Nov 22, 2020
Merged

Rename classes to avoid name clashes #642

merged 9 commits into from
Nov 22, 2020

Conversation

xirc
Copy link
Contributor

@xirc xirc commented Nov 21, 2020

This PR solves the issue #543.

#543 (comment)

How about renaming those internal classes to __???Value directly?

As suggested by @ghostdogpr, I've changed the internal class names.

  • NullValue to __NullValue
  • NumberValue to __NumberValue
  • EnumValue to __EnumValue
  • StringValue to __StringValue
  • BooleanValue to __BooleanValue
  • ListValue to __ListValue
  • ObjectValue to __ObjectValue

@ghostdogpr
Copy link
Owner

Nice! There's one more thing to do: modifying the code generation to use those new names. The relevant code is there: https://github.com/ghostdogpr/caliban/blob/master/tools/src/main/scala/caliban/tools/ClientWriter.scala

Let me know if you need more explanations.

@xirc
Copy link
Contributor Author

xirc commented Nov 21, 2020

@ghostdogpr Thanks for the review! I will try it tomorrow morning (JST+9:00).
Because the CI is success, I guess that the code generation is not tested yet, right?
I think it's better to test the code generation.
So, I will also try to test it if there is no technical problem.

@ghostdogpr
Copy link
Owner

It is tested (here: https://github.com/ghostdogpr/caliban/blob/master/tools/src/test/scala/caliban/tools/ClientWriterSpec.scala) but the output is a string (generated code), and we just verify that this is the expected code, we don't actually verify that it compiles. That's why the tests passed. If you have a better idea for testing this, feel free to add it 👍

@xirc
Copy link
Contributor Author

xirc commented Nov 21, 2020

Thanks! I got it.
In this PR, I will focus on changing the code generation and its existing test because I think writing a test verifying that generated code compiles is out of topic in this PR and makes the PR huge.

@@ -8,47 +8,47 @@ import io.circe.{ Decoder, Encoder, Json }
sealed trait Value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it better to rename Value to __Value?
I think the type may have the potential to collide with a user type name.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, I agree.

Copy link
Owner

@ghostdogpr ghostdogpr left a comment

Choose a reason for hiding this comment

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

Perfect! Thanks for the contribution!

@ghostdogpr ghostdogpr merged commit 87d9142 into ghostdogpr:master Nov 22, 2020
@xirc xirc deleted the rename-classes-to-avoid-name-clashes branch November 22, 2020 05:12
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