0

I am generating Java Code from my Domain specific Language (DSL). My Language is using String Template files for generating Java Code from DSL.

My problem is that String Template files generate un-formatted Java code in Eclipse. Whenever I generated code, I have to press cntr + Shift + F to format each generated Java file.

Is there any way of generating formatted code ? I am using Eclipse IDE.

2
  • 2
    Why do you want your generated code to be formatted? Do you edit the generated source? Is it so badly formatted that it is not usable? (I imagine that source consisting of one long source line is useless in exception stack traces.) Commented Mar 31, 2012 at 12:34
  • I agree with Christin Semrau. Generated code is like byte code - it does not need to be pretty - or human readable. Use \r\n as your white code character and your stack trace table will be more usable. Commented Mar 31, 2012 at 13:38

2 Answers 2

2

At least you can select the project/the package of your interest and use the Ctrl+Shift+F shortcut to format all of them immediately. This is much better compare to formatting each and every files.

Sign up to request clarification or add additional context in comments.

Comments

1

You have to take care of indentation in your StringTemplate templates. I tend to write templates for fragments of code such as a function definitions, function calls or even argument declarations that have to be expanded over a collection of variable elements, and combined them programmatically as arguments to a single souce file template.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.