-
Notifications
You must be signed in to change notification settings - Fork 150
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
Adopt Google Java style #3757
Adopt Google Java style #3757
Conversation
862aee0
to
0a70ab5
Compare
Comments to address:
|
kernel/src/main/java/org/kframework/backend/kore/KoreBackend.java
Outdated
Show resolved
Hide resolved
kernel/src/main/java/org/kframework/compile/GenerateSortPredicateRules.java
Outdated
Show resolved
Hide resolved
@radumereuta I resolved both your comments re. comment layout. For anyone reading / reviewing this change, a point I picked up while doing so is that the formatter will reformat JavaDoc comments ( If comment layouts are broken by the formatter, changing the type of comment is likely to be the answer. |
I don't care much about the specifics of the formatting (only that something consistent is enforced!), so I'm happy with the proposed changes. In terms of the JavaDoc comments @radumereuta mentioned, you can also wrap things in a |
Going to mark this as ready for review; I'd like to get it merged next week so that I can continue with automated cleanups, and we don't end up with a load of merge conflicts. |
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'm not super thrilled about the order of imports, but this seems like a reasonable way of applying a standard format everywhere, and given that this is used by Google engineers it almost certainly has integrations with pretty much any editor we might choose to use, which was my main concern. So I'm going to approve this.
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.
This is so large. I think I managed to go through half of it. I would like it if we check all the comments so they don't lose the important structures. Sometimes they really matter.
Code looks fine.
kernel/src/main/java/org/kframework/compile/GenerateSentencesFromConfigDecl.java
Show resolved
Hide resolved
kernel/src/main/java/org/kframework/compile/GenerateSortPredicateRules.java
Outdated
Show resolved
Hide resolved
I have addressed @radumereuta's comments re. formatting of comments, and I'm confident that any more such cases will be easy to fix. In the interests of not having such a large diff hanging around for ages, as planned I'm going to merge this now - if there are any issues with tooling etc. please let me know and we can work out a solution. |
This PR is an initial attempt to build some consensus around a consistent, automated code style for the K Frontend's Java code. Other parts of K already do this for other languages, and so I think there's a pretty clear precedent that we should want to set something similar up for our largest, oldest codebase:
clang-format
At a high level, the notional benefits of doing this are:
I have done some research into available auto-formatters for Java, focusing on the following points:
Beginning with (4) the standout contender for a "standardised" tool that's used by lots of Java developers in practice is Google's
google-java-format
tool, which is designed to apply the Google Java Style automatically. This PR focuses on using this tool and evaluating its tradeoffs; if we later decide it's totally unworkable then we can revisit this evaluation with a different tool.My summary of the pros and cons of this format are:
Pros
Cons
I hope that this is a fair summary of the tradeoffs of doing this kind of tooling update; I'd like to get opinions from everyone who works on this code to make sure that we're all as happy as possible with what we end up doing. Things to think about in particular:
Footnotes
By this I really just mean IntelliJ; I'm not aware of anyone using different tools to develop the K Frontend. If you're using some other setup then please let me know! ↩
This is also the situation we have with Black for Python, however, and that works fine! ↩
Though this is true for any formatter, and we probably just need to accept this pain as a once-off cost of doing business. ↩
The former is how we do automatic formatting for the other projects, so I am treating it as the default option here. ↩