-
Notifications
You must be signed in to change notification settings - Fork 68
[ggj]fix: fix block comment to construct file header #168
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
Conversation
String expected = "/*\n" + "* this is a test comment\n" + "*/\n"; | ||
commentStatement.accept(writerVisitor); | ||
assertEquals(writerVisitor.write(), expected); | ||
} |
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.
Could we please add a test for something with "bad formatting" like short lines and new lines in-between, so we can see how/whether that will be formatted?
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.
- The formatter will not reformat the short lines (verified in local), below example will just keep it is.
/*
* this is
* a test comment
*/
- new lines in between like
this is \n\n a test comment
will also reserve the new lines by formatter. (which is useful because we have extra new line in the apache license)
/*
* this is
*
* a test comment
*/
- long line is also kept as it is. unless it's surrounded by
/** */
. So when we construct the multi line block comment, the new line is used to be as splitter and we should be carefule about each line.
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.
Good, could we please add a test that demonstrates these cases?
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.
Yes, short lines/ newLineInbetween were added in the unit test, thanks!
String expected = "/*\n" + "* this is a test comment\n" + "*/\n"; | ||
commentStatement.accept(writerVisitor); | ||
assertEquals(writerVisitor.write(), expected); | ||
} |
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.
Good, could we please add a test that demonstrates these cases?
src/test/java/com/google/api/generator/engine/writer/JavaWriterVisitorTest.java
Show resolved
Hide resolved
🤖 I have created a release \*beep\* \*boop\* --- ## [0.11.0](https://www.github.com/googleapis/java-shared-dependencies/compare/0.10.2...v0.11.0) (2020-10-13) ### Dependencies * update dependency com.google.http-client:google-http-client-bom to v1.37.0 ([#166](https://www.github.com/googleapis/java-shared-dependencies/issues/166)) ([c0a7f06](https://www.github.com/googleapis/java-shared-dependencies/commit/c0a7f06103a60953fd3d40f605d3112d2a69ac48)) * update dependency io.grpc:grpc-bom to v1.32.2 ([#165](https://www.github.com/googleapis/java-shared-dependencies/issues/165)) ([b982441](https://www.github.com/googleapis/java-shared-dependencies/commit/b982441ab69e2d48e5f4c887e50447a62d8d0640)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
🤖 I have created a release \*beep\* \*boop\* --- ## [1.93.0](https://www.github.com/googleapis/java-core/compare/v1.92.6...v1.93.0) (2020-02-27) ### Features * support conditional policies ([#110](https://www.github.com/googleapis/java-core/issues/110)) ([c5329a7](https://www.github.com/googleapis/java-core/commit/c5329a73b9e3aa40ea983d580934e3087fa30666)) ### Bug Fixes * fix conversion for pre-epoch timestamps ([#160](https://www.github.com/googleapis/java-core/issues/160)) ([1c720fd](https://www.github.com/googleapis/java-core/commit/1c720fd23d2ba48a4b84fefcd84adfcc7e83cd3a)) ### Dependencies * update dependency com.google.api:gax-bom to v1.54.0 ([#168](https://www.github.com/googleapis/java-core/issues/168)) ([36c46e9](https://www.github.com/googleapis/java-core/commit/36c46e9f3d18c6313cea85a262659591c1321e00)) * update dependency io.grpc:grpc-bom to v1.27.2 ([#166](https://www.github.com/googleapis/java-core/issues/166)) ([0966b99](https://www.github.com/googleapis/java-core/commit/0966b990222cf7c1d6e1b5eb4c53e6d3cb18b77c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Currently the blockComment is actually special JavaDocComment with only the plain comments. We need a constructor to build file header which is in
/* */
format. it's different from/** */
because if we wrap the file header into the current BlockComment, when we run the JavaFormatter against the whole class definition, the format will be messed up to below with extra<p>
:The escaper won't be called here, since there won't be any special characters.