Monday, October 26, 2009

Acceleo template editor latest improvements

We try and constantly improve the Acceleo template editor as much as we can so as to make it as intuitive as possible. I haven't posted anything here about the template editing, here is a brief recapitulation of the features we're supporting (apart from the basic functions inherited from the text editor such as search, incremental search, ...). Including the latests and in no particular order :

  • Syntax highlighting
A classic for any self-respecting code editor, Acceleo provides highlighting for all module elements, though highlighting is minimal for OCL elements.
  • Error detection
Once again, a classic for any editor which contents are compiled, interpreted, or in any way error-prone.
  • Quick fix (ctrl+shift+1)
Not much accessible in terms of quick fixes yet, Acceleo only provides the possibility to create templates or queries corresponding to "not found" compilation errors.
  • Completion (ctrl+space)
We provide code completion for templates, queries, operations and OCL standard elements.
  • Open declaration (ctrl+click ; F3)
Sorry, no fancy screenshot on this one, as I don't know how to make a meaningful one :p. Anyone familiar with Eclispe's Java editor knows this one; it basically allows you to find the declaration of any variable, type, operation, ... by a single click on its usage within the code. This allows navigation to and from other Acceleo templates, and to the metamodel when calling it on a metatype.
  • Quick outline (ctrl+o)
This allows users to quickly assess the size of a given module, find a query or template defined in it and navigate to it through a few clicks. Note that this doesn't show as much information as the regular outline view, since it is only designed to outline the module's architecture.
  • Search references (ctrl+shift+g)
Still needs some polishing to only find references in the accurate scope, yet this already allows users to find references to the selected variable or template.
  • Code folding
Granted, a screenshot is somewhat cryptic for this feature if you do not already know what code folding is. Basically, blocks of code (in Acceleo, comments, templates and queries) can be folded so that they only take two lines. If you look carefully at the screenshot below, you'll notice the "+" on the left edge right to the line numbers "4" and "8" ... as well as the fact we're missing lines 5 and 9; well, those two templates are folded :p.

More features will be included in the editor as there's a bunch of cool features that can be added to simplify template editing; next are the refactoring facilities \o/.

Thursday, October 1, 2009

Generate code with the right encoding

Up until now, Acceleo allowed you to define the encoding in which the module itself should be read in the form of a comment at the very beginning of the module :However, this only affects how Acceleo reads your template file; it will not affect how Acceleo generates files from this module. So if you want to generate an XML file, and this XML file needs be encoded in a specific encoding which is not you system's default, you're stuck :p. Or at least that was true until M2.

Let's take this basic module as an example :This simple module is entirely composed of static text; its only purpose is to generate an ant file that creates a zip from a directory in a directory named "échantillons"... yes, that's an "é". If This file is generated under windows, no problem : the default windows encoding is the same as ISO-8859-1 as far as the "é" is concerned. What if this file is generated by one of your coworker who happens to be working under linux? Here's what would be generated :
And that'd could be a tragedy if the error isn't seen before someone tries and run this ant build... and sees that you generated under something else that windows! Imagine all the chocolate needed to atone for that blasphemy! Acceleo now proposes a way to define once and for all the encoding that must be used to generate a given file, and all you need is a single parameter for the file block :Take note that this is not a behaviour described by the OMG MOFM2T specification (that sadly left all encoding issues aside). As suche this feature might change form in the future, monitor the related OMG issue if you're interested by this field.