Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 315352 - ValidationDelegate body is not genmodeled as a StringLiteral
Summary: ValidationDelegate body is not genmodeled as a StringLiteral
Status: CLOSED DUPLICATE of bug 311639
Alias: None
Product: EMF
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-02 04:01 EDT by Ed Willink CLA
Modified: 2010-06-02 08:42 EDT (History)
0 users

See Also:


Attachments
Fix to use toStringLiteral (1.08 KB, patch)
2010-06-02 04:01 EDT, Ed Willink CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2010-06-02 04:01:25 EDT
Created attachment 170747 [details]
Fix to use toStringLiteral

RC3 - please adopt for RC4

The body of a validation delegate annotation is passed unchecked as the body of a string. If the delegate is a complex, or prettified OCL expression, the resulting 'Package'Validator.java contains e.g.:

protected static final String BOOK__SUFFICIENT_COPIES__EEXPRESSION = "
protected static final String BOOK__SUFFICIENT_COPIES__EEXPRESSION = "
protected static final String BOOK__SUFFICIENT_COPIES__EEXPRESSION = "
protected static final String BOOK__SUFFICIENT_COPIES__EEXPRESSION = "
protected static final String BOOK__SUFFICIENT_COPIES__EEXPRESSION = "loans->size() <= copies";

rather than

protected static final String BOOK__SUFFICIENT_COPIES__EEXPRESSION = "\n\t\t\n\t\t\n\t\t\n\t\tloans->size() <= copies";

The corresponding situation for setting and invocation delegates uses the annotation processing where Literals.toStringLiteral imposes string validity.

The attached patch invokes Literals.toStringLiteral so that in an indentable context the string is a valid string literal. The surrounding quotes are removed to preserve the API.

[It would be more elegant to remove the redundant quotes in the invoking Jet template instead, but that might have an API ripple?]
Comment 1 Ed Merks CLA 2010-06-02 07:47:08 EDT
Kenn has a nice patch updated by Axel in the other bugzilla.  Perhaps you can test it as well? We definitely want to commit this for RC4.

*** This bug has been marked as a duplicate of bug 311639 ***