Gary Sheppard created NETBEANS-4505:
---------------------------------------
Summary: Strange formatting for try/catch within switch
Key: NETBEANS-4505
URL: https://issues.apache.org/jira/browse/NETBEANS-4505
Project: NetBeans
Issue Type: Bug
Components: java - Editor
Affects Versions: 12.0
Environment: Windows 10 Version 1803
Reporter: Gary Sheppard
Attachments: NetBeansFormatSwitchTryApp_caseIndent_correct.java,
NetBeansFormatSwitchTryApp_caseIndent_formatted.java,
NetBeansFormatSwitchTryApp_noCaseIndent_correct.java,
NetBeansFormatSwitchTryApp_noCaseIndent_formatted.java
When I write a try/catch block inside a switch statement, and then I use Source
> Format or Alt-Shift-F to format the code, the formatting seems wrong.
The behavior depends on whether Tools > Options > Editor > Formatting > Indent
Case Statements in Switch is checked.
*If Indent Case Statements in Switch is checked*, I would expect formatting to
look like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
Instead, the formatting looks like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
*If Indent Case Statements in Switch is not checked*, I would expect formatting
to look like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
Instead, the formatting looks like this:
{code:java}
switch (val) {
case 0:
case 1:
try {
result = 42 / val;
} catch (ArithmeticException ex) {
System.out.println("You can't do that: " + ex.getMessage());
throw ex;
}
}{code}
I have attached complete Java source files that illustrate the behavior in both
cases.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
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