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.

Code-reformat to indent routes in RouteBuilders

See original GitHub issue

Configure IDEA’s code reformat feature (standard keybind: Ctrl + Alt + L) to correctly indent things like choices to reflect their functionality, like code-blocks are formatted in standard Java.

An example in a RouteBuilder

This is how IDEA wants to indent this code:

from("direct:getBgUser")
        .process(buildBGAuthRequest)
        .to("direct:bgmock")
        .choice()
        .when(credentialsValid)
        .process(createNumbersResponseFromBGResponse)
        .otherwise()
        .setHeader(Exchange.HTTP_RESPONSE_CODE).constant(401)
        .end()
;

And this is how IDEA should indent it:

from("direct:getBgUser")
        .process(buildBGAuthRequest)
        .to("direct:bgmock")
        .choice()
        .when(credentialsValid)
            .process(createNumbersResponseFromBGResponse)
        .otherwise()
            .setHeader(Exchange.HTTP_RESPONSE_CODE).constant(401)
        .end()
;

How the correct indentation is done in this example is purely my opinion and should be worked on further. But making it configurable would be the best way to avoid anyone calling it out as “wrong”.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:88
  • Comments:17

github_iconTop GitHub Comments

3reactions
bennetellicommented, Mar 9, 2018

@haraldfw I tried it three times, but didn’t get it up and running yet. I also would like to have this feature as soon as possible because of your reasons. Unfortunately it’s not that straightforward 😦

2reactions
davsclauscommented, Mar 4, 2018

You can manually turn code formatting off as shown here https://twitter.com/JavaGuyUA/status/969963553817092096

Read more comments on GitHub >

github_iconTop Results From Across the Web

Completely unusable and annoying auto format in any camel ...
This is a camel route written in java DSL ... If you do not want Intellij IDEA automatically indent code on paste (regardless...
Read more >
How to indent/format a selection of code in Visual Studio Code?
Select the lines you want to indent, and; use Ctrl + ] to indent them. If you want to format a section (instead...
Read more >
RouteBuilder - Apache Camel
The RouteBuilder is a base class which is derived from to create routing rules using the DSL. Instances of RouteBuilder are then added...
Read more >
Code Reformat Finished - OpenSSL Blog
The '-v' argument provides verbose output, and '-c' applies comment formatting rules. The next problem was that we wanted indent to reformat our ......
Read more >
Basic Editing in Visual Studio Code
Indentation. VS Code lets you control text indentation and whether you'd like to use spaces or tab stops. By default, VS Code inserts...
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