Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 315352

Summary: ValidationDelegate body is not genmodeled as a StringLiteral
Product: [Modeling] EMF Reporter: Ed Willink <ed>
Component: CoreAssignee: Ed Merks <Ed.Merks>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
Fix to use toStringLiteral none

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 ***