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

Bug 215407

Summary: Provide a way to suppress operation visibility
Product: [Modeling] EMF Reporter: Kenn Hussey <Kenn.Hussey>
Component: ToolsAssignee: Dave Steinberg <davidms>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: Ed.Merks
Version: 2.4.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Preliminary patches
none
Okay, it's working properly now and is ready for review
none
Example model
none
This includes the EcoreUtil and EcoreValidator changes
none
Example of the volatile problem
none
Fixes for the described issue
none
Change to use _ instead of Gen none

Description Kenn Hussey CLA 2008-01-15 16:45:28 EST
Please provide a way to suppress the visiblity of operations, much like the support provided for features. It's common (at least in my experience) for (UML) modelers to define operations with signatures that conflict with accessors for features (e.g. to specify a derivation for a derived feature), and this now violates a constraint introduced by bug 214225. The validation algorithm introduced as part of that change should be updated so that it does not complain about colliding signatures in case where the operation has suppressed visibility.
Comment 1 Ed Merks CLA 2008-01-15 17:01:45 EST
I'll try to get to this tomorrow.
Comment 2 Ed Merks CLA 2008-01-16 17:09:06 EST
Created attachment 87109 [details]
Preliminary patches

It's not quite ready for prime time, but is mostly working.

If an operation collides with a volatile feature being implemented then the body replaces the feature's body.  If it collides with a normal feature being implemented, the feature's accessor is redirected to a "Gen" version of it.

I'm just not sure I have the operation filtering working quite right...
Comment 3 Ed Merks CLA 2008-01-17 07:51:13 EST
Created attachment 87149 [details]
Okay, it's working properly now and is ready for review

I've been thinking about one more addition.  I can imagine it might be very handy to introduce fields in the Impl as part of generating an operation with a body.
Comment 4 Ed Merks CLA 2008-01-17 08:15:25 EST
Created attachment 87150 [details]
Example model

I wonder if "Gen" is really the best thing to use.  I suppose we could use "_" or pretty much anything.  The argument in favor is that renaming to Gen is exactly what'd you'd do for writing this type of pattern by hand.
Comment 5 Dave Steinberg CLA 2008-01-17 10:09:45 EST
It seems your patch doesn't include your changes to EcoreUtil.
Comment 6 Ed Merks CLA 2008-01-17 10:23:55 EST
Created attachment 87163 [details]
This includes the EcoreUtil and EcoreValidator changes
Comment 7 Dave Steinberg CLA 2008-01-17 12:14:26 EST
Hi Ed,

I've still just been looking at the incomplete patch so far, so I'll look at EcoreUtil and EcoreValidator next, but I thought I'd point out something that looks fishy first...

The new stuff you've added to GenClassImpl seems to assume that a volatile feature always results in no getter implementation being implemented. But that's not really true. Of course, there's the case of delegation to a feature map, and there's also a case where a proxy-resolving single-valued volatile feature gets delegated to a basic getter. I haven't looked closely at the set, isSet, and unset.

Anyhow, we never get to check getGetAccessorOperation() in the getter pattern for these cases, since we've already rightly handled them. But, no "Gen" suffix is included on the getter name and no corresponding operation is generated (because the volatile flag causes hasCollidingGetAccessorOperation() to return false and causes it to be filtered from getImplementedGenOperations()). So, the specified operation body is lost.

If this is to work properly, then every time we figure out whether there's a colliding accessor we really need to take into account all of the cases where we generate something more useful than a TODO comment in all three places.

Yuck.  Who thought that using operations to specify feature accessor implementations was a good idea again?
Comment 8 Dave Steinberg CLA 2008-01-17 12:17:18 EST
Created attachment 87171 [details]
Example of the volatile problem

Demonstrates mistreatment of a volatile feature that still has a generated implementation.  Compare getPriorityOrders() to getPriorityOrders2().
Comment 9 Ed Merks CLA 2008-01-17 13:05:19 EST
Created attachment 87183 [details]
Fixes for the described issue

There weren't so many cases and the getter was the worst one.  Thanks for looking so closely!
Comment 10 Dave Steinberg CLA 2008-01-17 23:15:28 EST
It looks right, and my example works now.  Though, I will admit, I didn't examine it quite as closely as I did last time.  Hope you were careful.  ;)

I'm still not sure about "Gen", either.  I think I'd rather do something like defaultGetFoo(), since this really is just another generator pattern, much like basicGetFoo().  It may be sort of analogous to the renaming by hand, but it's an entirely different mechanism.  It seems very wrong to use "Gen" to distinguish between two generated things.
Comment 11 Ed Merks CLA 2008-01-18 07:36:41 EST
Yes, I'm not so thrilled with Gen either, but I'm not fond of the idea of prefixing rather that postfixing something.  The later will help to group them in the outline view and is an easier pattern to generate as well.  I think Kenn suggested using '_' which I kind of like.  That's what we do when we want to generated getClass but it collides with Object.getClass, or when the getAccessor collides with something in the root implements interface like for getType for SDO which is in DataObject.  So I'd prefer to use '_'.  What do you think?
Comment 12 Dave Steinberg CLA 2008-01-18 07:48:18 EST
Yup, I'm okay with that.
Comment 13 Ed Merks CLA 2008-01-18 09:59:29 EST
Created attachment 87264 [details]
Change to use _ instead of Gen

Kenn,

I'll wait for you to verify that this causes no further problems for UML before I commit it.
Comment 14 Kenn Hussey CLA 2008-01-19 22:25:00 EST
I made the corresponding changes in UML2 and everything seems to work OK; the validation errors are gone now. Surprisingly, I didn't have to make any changes to the UML2 code generator...
Comment 15 Ed Merks CLA 2008-01-20 11:31:41 EST
The changes are committed to CVS for 2.4.
Comment 16 Nick Boldt CLA 2008-01-22 21:54:20 EST
Fix in CVS.
Comment 17 Nick Boldt CLA 2008-01-22 22:44:52 EST
Fix available in HEAD: 2.4.0.I200801221930.