Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] how to format generated java code?
[Acceleo] how to format generated java code? [message #717969] Mon, 22 August 2011 17:02 Go to next message
Leonardo Kenji Shikida is currently offline Leonardo Kenji Shikida
Messages: 37
Registered: July 2009
Member
Hi

I can format programmaticaly an already existent java class, but I canĀ“t format a new java class generated by acceleo. Probably I am forgetting some step to refresh the project or some synchronization issue.

        CodeFormatter formatter = ToolFactory.createCodeFormatter(null);
        ISourceRange range = cu.getSourceRange();
        TextEdit indent_edit =
          formatter.format(CodeFormatter.K_COMPILATION_UNIT, 
            cu.getSource(), range.getOffset(), range.getLength(), 0, null);
        cu.applyTextEdit(indent_edit, null);
        cu.reconcile();


Any help is welcome.

TIA

Leo K.
Re: [Acceleo] how to format generated java code? [message #719137 is a reply to message #717969] Fri, 26 August 2011 03:26 Go to previous message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

There are no "difference" between a "normal" Java class and a Java class generated by Acceleo, so there shouldn't be any problem to format it. You can have a look at this piece of code to do so. I used it in the past to format Acceleo generated Java class and it worked perfectly.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Previous Topic:[Acceleo] Resource Factory issue
Next Topic:[Acceleo] generating current date/time
Goto Forum:
  


Current Time: Thu Apr 24 14:50:05 EDT 2014

Powered by FUDForum. Page generated in 1.66883 seconds