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

ChangeType: rename java file for non-public class too if the java file name matches the class name #2528

Closed
ge0ffrey opened this issue Dec 14, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@ge0ffrey
Copy link
Contributor

ge0ffrey commented Dec 14, 2022

Given

File: src/main/java/a/A1.java
Content:

package a;

class A1 {} // non-public

with a ChangeType from a.A1 to a.A2, it will result in:

File: src/main/java/a/A1.java
Content:

package a;

class A2 {} // non-public

The resulting content is fine, but the filename should have renamed to A2.java too.

Even despite the fact that class A1 isn't public, because the filename A1.java matched the original classname A1.

@ge0ffrey
Copy link
Contributor Author

ge0ffrey commented Dec 14, 2022

One could argue that unlike for public classes, there is no JLS need that A2, after the change, is in the file A2.java. However in practice, this is what users pretty much always want, given that the rename of the filename only happens if (and only if) the A1 was in the file A1.java to begin with.

For the theoretical case that they don't want the file rename , one could argue to introduce it as a boolean configuration property renameFileOfNonPublicClassWithSameName but I think that's overkill (YAGTNI), so I 'd leave that out until someone asks for it. (And I would predict no one will ever ask for it.)

@traceyyoshima traceyyoshima added the enhancement New feature or request label Dec 14, 2022
@traceyyoshima traceyyoshima self-assigned this Dec 14, 2022
@tkvangorder tkvangorder added this to the 7.34.1 milestone Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants