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

Normalize replacement comments #312

Open
Bananeweizen opened this issue Jan 3, 2025 · 3 comments
Open

Normalize replacement comments #312

Bananeweizen opened this issue Jan 3, 2025 · 3 comments

Comments

@Bananeweizen
Copy link
Contributor

Currently the format of the comments with the replacements is somewhat mixed: In most cases the type of the method receiver is fully qualified, and the method arguments are not qualified. That's a very readable format.

However, some cases use fully qualified names for all types, even the method arguments. I consider that hard to read. Also it's not necessary: With the full qualified method receiver type, there are only a handful of potential overloads of the same method name that a developer might consider. It should always be sufficient to use a non-qualified type for all method arguments, without causing confusion which method to use.

I would suggest to shorten the types in the first lines of this screenshot (and other affected places):

image

@gaul
Copy link
Owner

gaul commented Jan 3, 2025

I agree that the fully-qualified method and unqualified parameter names are more readable and this was the intent. I am happy to merge PRs that manually make the style consistent although automatically enforcing the format seems more difficult. A complete solution would be to programmatically generate modernizer.xml #72.

@mkarg
Copy link
Contributor

mkarg commented Jan 12, 2025

There is another option we could consider: We could write <comment>Prefer {{signature:S}} for improved performance.</comment> to create the format proposed by @Bananeweizen from the unambiguous Java method signature syntax S. The signature: prefix let us introduce more parameter sources in future, while :S suffix is an actual Java method signature as already used in <name>. The benefits are:

  • The actual format template is stored in one single location in Java code, so it can be changed in future without replacing thousands of <comment> elements.
  • The software can throw a ClassNotFoundException for incorrect S, effectively preventing any typos in the comment.

@gaul
Copy link
Owner

gaul commented Jan 12, 2025

It would be great to do anything better than the current human-generated modernizer.xml. Ideally the input would be valid Java that a Maven phase processes into modernizer.xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants