这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@sav007
Copy link
Contributor

@sav007 sav007 commented Jul 10, 2017

MobileBuy SDK requires to include deprecated fields that by default excluded from generation.

This PR:

  • adds optional include_deprecated flag by default it's set to false
  • generate java Deprecated annotation for deprecated fields
  • if include_deprecated is set to true includes deprecated fields into generation

Example of generated deprecated fields:

/**
* The three-letter code for the currency that the shop accepts.
*
* @deprecated Use `paymentSettings` instead
*/
@Deprecated public ShopQuery currencyCode() {
    startField("currencyCode");

    return this;
}

Closes #6

@sav007 sav007 requested review from dylanahsmith and eapache July 10, 2017 19:38
@DanielJette
Copy link
Contributor

@realdm this seems like exactly what you're looking at

else
doc << '*'
end
doc << ' @deprecated '
Copy link
Contributor

Choose a reason for hiding this comment

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

GraphQL also has deprecated enum values; is the @deprecated annotation valid for them in java?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this PR addresses deprecation for fields not for types for now, but maybe you are right we should do the same for types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but if you are asking if this annotation applicable for enum values the answer yes.

<% fields.each do |field| %>
<%= java_doc(field) %>
<%= java_annotations(field) %>
<%= java_annotations(field) -%>
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this - do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do not generate new line in case if java_annotations(field) resolved to blank line

Copy link
Contributor

@dylanahsmith dylanahsmith left a comment

Choose a reason for hiding this comment

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

A couple of minor suggested changes, otherwise, LGTM


def erb_for(template_filename)
erb = ERB.new(File.read(template_filename))
erb = ERB.new(File.read(template_filename), 0, '-')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you also changing the safe_level argument from nil to non-nil.

If safe_level is set to a non-nil value, ERB code will be run in a separate thread with $SAFE set to the provided level.

Seems like you should just use nil for that argument.

end

if element.respond_to?(:deprecated?) && element.deprecated?
if (doc.length > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

The parenthesis are unnecessary and I think if doc.empty? is more readable.

@sav007 sav007 merged commit 119255a into master Jul 10, 2017
@sav007 sav007 deleted the feature/generate-deprecated-fields branch July 10, 2017 20:46
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.

4 participants