A functionality has been added to code generation, to know where the output comes from.
In CodeWorker, an output file is generated by a template-based script. The directive #coverage
asks for the recording of every script position giving rise to a piece of the output file.
This directive is located anywhere in the script to study, and requires a variable the code
generation engine will populate with coverage data.
The variable will be a list of sorted segments, entirely determined by their starting position
in the output and by the position of the corresponding script instruction.
These positions are respectively stored in attributes output and script.
An added information is assigned to the node representing the segment. It specifies the type of
script instruction, belonging to one of the following values:
- R: rough text,
- W: expression, variable or call to a writeText()-family procedure,
- I: call to a insertText()-family procedure,
- O: call to overwritePortion() procedure,
Example:
rough text @this.name@ EOL
@
#coverage(project.coverage)
Let say that this.name is worth "VARIABLE_CONTENT".
The script generates the following output file:
rough text VARIABLE_CONTENT EOL
The variable project.coverage is then worth the following list:
["0"] = "R"
|--+
script = 12
output = 0
["1"] = "W"
|--+
script = 21
output = 11
["2"] = "R"
|--+
script = 29
output = 27
|