question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format Switch Statement

See original GitHub issue
Environment
  • Operating System: WSL 1 on Win 10
  • JDK version: 11.0.5 2019-10-15
  • Visual Studio Code version: 1.41.1
  • Java extension version: 0.55.1
Steps To Reproduce
  1. Add a switch statement format the document

sample project

Current Result

image

Expected Result

image

Additional Informations

Is this configurable? This is the extension that is formatting the code, right?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
fbriconcommented, Feb 5, 2020

There’s a rationale for not indenting cases: https://stackoverflow.com/questions/4509039/why-the-strange-indentation-on-switch-statements

But I still find it hurts my eyes. Also Oracle’s doc on switch shows indentation: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html.

The google formatter does the same: https://google.github.io/styleguide/javaguide.html#s4.8.4-switch

IntelliJ IDEA and Netbeans indent cases by default too.

2reactions
fbriconcommented, Feb 5, 2020

@snjeza can you please make it the default setting in jdt.ls. Current formatting of switch cases makes no sense at all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Switch statement formatting - coding style - Stack Overflow
I've been conflicted over how to format switch statements for awhile now. I see three viable options, and while I've been using the...
Read more >
switch…case in C (Switch Statement in C) with Examples
A general syntax of how switch-case is implemented in a 'C' program is as follows: switch( expression ) { case value-1: Block-1; Break;...
Read more >
switch - JavaScript - MDN Web Docs - Mozilla
The switch statement evaluates an expression, matching the expression's value against a series of case clauses, and executes statements ...
Read more >
C - switch statement - Tutorialspoint
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and...
Read more >
The switch Statement (The Java™ Tutorials > Learning the ...
A switch works with the byte , short , char , and int primitive data types. It also works with enumerated types (discussed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found