Repository navigation
|
Hi everyone, I am currently working with Acceleo 4 and I am facing a tricky formatting issue related to code generation and implicit iteration. My Goal: I need to generate an Ada-like procedure signature. The formatting depends on whether the procedure has parameters or not: If there are no parameters: The semicolon must be on the same line. If there are parameters: They must be generated on a new line with proper indentation. I have tried two different approaches, but neither gives the perfect result. Attempt 1: Placing the [if] on the same line Result: It works perfectly when there are no parameters. However, when there are parameters, the ->sep() seems to trigger an implicit iteration that duplicates the entire first line: Attempt 2: Placing the [if] on a new line Result: It works perfectly when there are parameters. However, when there are no parameters, the line break before the [if] creates an unwanted newline for the semicolon: My Question: Is it normal behavior for ->sep() to duplicate the static text of the preceding line as seen in Attempt 1? How can I achieve my expected formatting without these side effects? Thanks in advance for your help! |
Replies: 1 comment 1 reply
|
The beginning of the line is duplicated to keep the alignment (indentation) of the generated block (see the white space section of the documentation). In the first example this block is Here we use the if AQL expression (the else is mandatory), also note that indentation is added after line returns. We also use the sep() service with prefix and suffix. |
The beginning of the line is duplicated to keep the alignment (indentation) of the generated block (see the white space section of the documentation). In the first example this block is
[if (procedure.para...so anything generated before on the same line will be repeatedtype MY_TYPE is access procedurein this case.One way to deal with this is to start the block at the beginning of the line:
Here we use the if AQL expression (the else is mandatory), also note that indentation i…