Skip to content

review fix: EnumValues constructor call should be marked as implicit#2090

Merged
monperrus merged 10 commits intoINRIA:masterfrom
surli:enum-value-comments
Jun 22, 2018
Merged

review fix: EnumValues constructor call should be marked as implicit#2090
monperrus merged 10 commits intoINRIA:masterfrom
surli:enum-value-comments

Conversation

@surli
Copy link
Copy Markdown
Collaborator

@surli surli commented Jun 21, 2018

No description provided.

@surli surli changed the title WiP fix: enum value comments are not processed review fix: enum value comments are not processed Jun 21, 2018
@surli surli changed the title review fix: enum value comments are not processed review fix: in EnumValues constructor call Jun 21, 2018

List<CtComment> comments = firstEnumValue.getComments();
assertEquals(1, comments.size());
assertTrue(comments.get(0) instanceof CtJavaDoc);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

assert on the comment content

@surli surli changed the title review fix: in EnumValues constructor call Wip fix: in EnumValues constructor call Jun 21, 2018

for (CtEnumValue enumValue : enumValues) {
CtExpression defaultExpression = enumValue.getDefaultExpression();
assertTrue(defaultExpression.isImplicit());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

assert on the pretty-print of enum values (implicit constructor calls)

@surli surli changed the title Wip fix: in EnumValues constructor call Wip fix: EnumValues constructor call should be marked as implicit Jun 21, 2018
@surli
Copy link
Copy Markdown
Collaborator Author

surli commented Jun 21, 2018

@pvojtechovsky I got an assertion error with PrinterTest#testPrinterTokenListener because I added a line separator in a printList call (you can see it in my diff of DJPP):

elementPrinterHelper.printList(ctEnum.getEnumValues(),
					null, false, null, false, false, "," + DefaultJavaPrettyPrinter.LINE_SEPARATOR, false, false, ";",
					enumValue -> scan(enumValue));

I don't really know where to start for fixing that one... Do you have an idea?

elementPrinterHelper.printList(ctEnum.getEnumValues(),
null, false, null, false, false, ",", true, false, ";",
null, false, null, false, false, "," + DefaultJavaPrettyPrinter.LINE_SEPARATOR, false, false, ";",
enumValue -> scan(enumValue));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it is not actually allowed to send token which contains two different token types: "," and EOL

Solution:
replace

enumValue -> scan(enumValue)

with

enumValue -> {
   printer.writeln();
   scan(enumValue)
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great thanks!

if (!constructorCall.isImplicit()) {
this.getPrinterTokenWriter().writeSeparator("(");
elementPrinterHelper.printList(constructorCall.getArguments(), null, false, null, false, false, ",", true, false, null, expr -> scan(expr));
this.getPrinterTokenWriter().writeSeparator(")");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove both writeSepratator calls and use instead:

elementPrinterHelper.printList(constructorCall.getArguments(), null, false, "(", false, false, ",", true, false, ")", expr -> scan(expr));

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmmm I tried with "(" for the first parameter, but it works indeed better at the right place :)

@surli surli changed the title Wip fix: EnumValues constructor call should be marked as implicit review fix: EnumValues constructor call should be marked as implicit Jun 21, 2018
@surli surli changed the title review fix: EnumValues constructor call should be marked as implicit review 2 fix: EnumValues constructor call should be marked as implicit Jun 22, 2018
@monperrus
Copy link
Copy Markdown
Collaborator

should only be merged after #2096?

@surli
Copy link
Copy Markdown
Collaborator Author

surli commented Jun 22, 2018

No it can be already merged

@surli surli changed the title review 2 fix: EnumValues constructor call should be marked as implicit review fix: EnumValues constructor call should be marked as implicit Jun 22, 2018
@monperrus monperrus merged commit 57d0d39 into INRIA:master Jun 22, 2018
@surli surli deleted the enum-value-comments branch June 22, 2018 13:51
@surli surli mentioned this pull request Jun 25, 2018
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.

3 participants