Closed eclipse-viatra-bot closed 2 months ago
By Benedek Horvath on Oct 15, 2020 05:57
Hello,
Besides line breaks, the escaping of quotes in the message attribute of the @Constraint annotations is not taken into consideration either.
E.g.:
@Constraint(message = "Action cannot have Pin \"object\".", key = {example}, severity = "error")
results in a generated code:
annotation.addAttribute("message", "Action cannot have Pin "object".");
The generated code is syntactically incorrent, because the quotes around the word object should have been escaped.
| --- | --- | | Bugzilla Link | 562471 | | Status | UNCONFIRMED | | Importance | P3 normal | | Reported | Apr 24, 2020 11:12 EDT | | Modified | Oct 15, 2020 05:57 EDT | | Version | 2.3.2 | | Reporter | Benedek Horvath |
Description
If there is a line break character in the @Constraint annotation's message argument, then it breaks the generated pattern code.
Example pattern (excerpt):
@Constraint(message = "Hello \n world", key = {example}, severity = "error")
The generated code at the end of the "public Set doGetContainedBodies()" method is (excerpt):
{\ PAnnotation annotation = new PAnnotation("Constraint");\ annotation.addAttribute("message", "Hello \ world");\ annotation.addAttribute("key", Arrays.asList(new Object[] {\ new ParameterReference("example")\ }));\ annotation.addAttribute("severity", "error");\ addAnnotation(annotation);\ }
Note that there is an actual line break in the code in line 3, after the "Hello text. No \n is generated.