jlahoda commented on a change in pull request #1079: [NETBEANS-1780]:Fixed
formatting issue in Switch Expression(JDK-12)
URL:
https://github.com/apache/incubator-netbeans/pull/1079#discussion_r252137143
##########
File path:
java/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
##########
@@ -2659,11 +2750,17 @@ public Boolean visitCase(CaseTree node, Void p) {
} else {
accept(DEFAULT);
}
+ List<? extends StatementTree> statements = node.getStatements();
+ if(statements != null)
accept(COLON);
+ else if (node instanceof JCTree.JCCase) {
+ statements = ((JCTree.JCCase) node).stats;
Review comment:
Sorry, but it is difficult to say if this approach works without testing. In
some cases "stats" may contain synthesized trees, for things like:
```
int x = switch (...) {
case 0 -> 0;
default -> -1;
}
```
"stats" contains a synthetic Break statement, which refers to "0" and "-1".
I guess I'd suggest to try without referring to the field, but rather use
TreeShims.getBody(), although I admit I am not sure where that would lead.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists