-
Notifications
You must be signed in to change notification settings - Fork 53
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: resource name class deduplication #1854
Conversation
...va/com/google/api/generator/gapic/composer/resourcename/ResourceNameHelperClassComposer.java
Outdated
Show resolved
Hide resolved
gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/store/TypeStore.java
Outdated
Show resolved
Hide resolved
* @return | ||
*/ | ||
private static List<TypeNode> createImplementsTypes(String implementingClassName) { | ||
List<TypeNode> preprocessed = Arrays.asList(FIXED_TYPESTORE.get("ResourceName")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FIXED_TYPESTORE
always returns only one result. Can we check if there is conflict and fix it first, then wrap it as a list in the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used a slightly different but similarly concise way (wrap both possible results in the end). Hope you agree it's good too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks much better!
nit: It would be great if we can return TypeNode
only in this private method and wrap it as a list when we call it, since the list always contains just one element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I only saw the review comment instead of this one. I'll leave it as a quick follow up
...va/com/google/api/generator/gapic/composer/resourcename/ResourceNameHelperClassComposer.java
Outdated
Show resolved
Hide resolved
[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Diego! Looking good to me other than one nit. We should update the description as it does not reflect the latest changes. Also, this PR should probably be a fix
instead of feat
.
Adds deduplication logic for
com.google.api.resourcenames.ResourceName
implementing classes. It is possible that a generated class is also namedResourceName
, which is not currently handled by the generator.This approach consists of:
ResourceNameClassComposer
to use the full name ofResourceName
(the only implemented interface) if there is a name collision with the class being generated