Skip to content

Fix formatComment to keep stable reformating and add comments unit tests#280

Merged
clementdessoude merged 2 commits intojhipster:masterfrom
clementdessoude:fix/comments-stable
Oct 15, 2019
Merged

Fix formatComment to keep stable reformating and add comments unit tests#280
clementdessoude merged 2 commits intojhipster:masterfrom
clementdessoude:fix/comments-stable

Conversation

@clementdessoude
Copy link
Copy Markdown
Contributor

@clementdessoude clementdessoude commented Oct 8, 2019

Fix #279

As discussed in #279, it is impossible to know what is inside a block comment, and how it could be reformatted. So, as Prettier in JS, let's keep the original comment and its indentation when the comment is not JavaDoc (see https://prettier.io/docs/en/rationale.html#comments)

@jhaber
Copy link
Copy Markdown

jhaber commented Oct 8, 2019

👍 thanks for the quick fix

@lppedd
Copy link
Copy Markdown

lppedd commented Oct 15, 2019

@clement26695 another suggestion. Take for example this method definition.

public Long create(final InlineObject7 /* BackupItem */ dto) {

Currently it gets formatted as

public Long create(final InlineObject7 /* BackupItem */dto) {

So the space before dto is removed.
It would be better, if possible, to keep it.


My barbaric temporary fix

if (lines.length === 1) {
  res.push(lines[0] + ' ');
} else {
  lines.forEach(line => {
    res.push(line);
    res.push(prettier.literalline);
  });

  res.pop();
}

Comment thread packages/prettier-plugin-java/scripts/update-test-output.js
*/
rowKeyToIndex = Maps.indexMap(rowList);
rowKeyToIndex =
Maps.indexMap(rowList);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this what we want ?

@clementdessoude clementdessoude merged commit 3aa27bd into jhipster:master Oct 15, 2019
@clementdessoude clementdessoude deleted the fix/comments-stable branch October 15, 2019 14:45
@clementdessoude
Copy link
Copy Markdown
Contributor Author

I will keep it in mind @lppedd ! I prefer to merge this as it is better than that we have right now but will try to find time to improve this

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.

Multiline comment formatting not idempotent

4 participants