Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Validator and generated source in xbase
Validator and generated source in xbase [message #976898] Thu, 08 November 2012 23:15 Go to next message
Michael Scharf is currently offline Michael ScharfFriend
Messages: 301
Registered: July 2009
Senior Member
Hi,

is there a way to specify where to generate the validator class?

With xbase I have no reason to use @generated NO except for the
validator class. I use a src-gen directory for the
generated sources. But I have to modify the validator.

- is there a way to specify the directory of the validator?
- I actually use a sub-class outside of the src to implement
the validation. All I need in that case is to change the INSTANCE
of the validator. Unfortunately, the generated validator creates a
lot of warnings.


Michael
--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: Validator and generated source in xbase [message #977155 is a reply to message #976898] Fri, 09 November 2012 04:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.

On 09/11/2012 12:15 AM, Michael Scharf wrote:
> Hi,
>
> is there a way to specify where to generate the validator class?
No, it's generated in the util package.
>
> With xbase I have no reason to use @generated NO except for the
> validator class. I use a src-gen directory for the
> generated sources. But I have to modify the validator.
Yes, we don't yet support defining constraints (other than invariant
operations).
>
> - is there a way to specify the directory of the validator?
The package, yes.
> - I actually use a sub-class outside of the src to implement
> the validation. All I need in that case is to change the INSTANCE
> of the validator. Unfortunately, the generated validator creates a
> lot of warnings.
I suppose mostly you'd like to be able to define the constraints in
Xcore itself, right?
>
>
> Michael


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Validator and generated source in xbase [message #978317 is a reply to message #977155] Sat, 10 November 2012 01:05 Go to previous messageGo to next message
Michael Scharf is currently offline Michael ScharfFriend
Messages: 301
Registered: July 2009
Senior Member
Ed,
> I suppose mostly you'd like to be able to define the constraints in Xcore itself, right?

well, maybe, but my concern is that I want to strictly separate generated code form
hand-written code. I want to put the generated code into a src-gen directory which
essentially means it can be re-generated at any time. The validation *requires*
hand written code and this causes a problem.

I don't know if that is a known bug, but when I edit the xcore file and it contains
some errors *all* of my generated code is removed. We can easily re-produce it and
when that happens, we have to revert the generated code form the source code control
system in order to not loose the hand-written part.

That's why I *only* override the instance and I put the hand-written validator
into a non src-gen package.

Michael


On 09.11.2012 05:19, Ed Merks wrote:
> Michael,
>
> Comments below.
>
> On 09/11/2012 12:15 AM, Michael Scharf wrote:
>> Hi,
>>
>> is there a way to specify where to generate the validator class?
> No, it's generated in the util package.
>>
>> With xbase I have no reason to use @generated NO except for the
>> validator class. I use a src-gen directory for the
>> generated sources. But I have to modify the validator.
> Yes, we don't yet support defining constraints (other than invariant operations).
>>
>> - is there a way to specify the directory of the validator?
> The package, yes.
>> - I actually use a sub-class outside of the src to implement
>> the validation. All I need in that case is to change the INSTANCE
>> of the validator. Unfortunately, the generated validator creates a
>> lot of warnings.
> I suppose mostly you'd like to be able to define the constraints in Xcore itself, right?
>>
>>
>> Michael
>


--
Michael Scharf
Wind River Systems GmbH
http://www.WindRiver.com
http://MichaelScharf.blogspot.com/
Re: Validator and generated source in xbase [message #978611 is a reply to message #978317] Sat, 10 November 2012 06:47 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Michael,

Comments below.

On 10/11/2012 2:05 AM, Michael Scharf wrote:
> Ed,
> > I suppose mostly you'd like to be able to define the constraints in
> Xcore itself, right?
>
> well, maybe, but my concern is that I want to strictly separate
> generated code form
> hand-written code. I want to put the generated code into a src-gen
> directory which
> essentially means it can be re-generated at any time. The validation
> *requires*
> hand written code and this causes a problem.
So the best solution is not to require that.
>
> I don't know if that is a known bug, but when I edit the xcore file
> and it contains
> some errors *all* of my generated code is removed.
That's Xtext builder behavior, but maybe we should refuse to generate
when there are errors and avoid the builder's cleanup phase where it
removes any files that didn't get regenerated. Please open a bugzilla.
> We can easily re-produce it and
> when that happens, we have to revert the generated code form the
> source code control
> system in order to not loose the hand-written part.
This only happens if you generated into the folder specified as
generated source folder. If you change it (via @GenModel annotations
created by the properties view) to a different folder, i.e., the src
folder, you'll get the same old behavior as standard *.genmodels.
>
> That's why I *only* override the instance and I put the hand-written
> validator
> into a non src-gen package.
Yes, it's not nice to have all your source wiped out. But even when
things are working properly, a clean builder will still wipe it out
unless you redirect generation (via GenModel annotations) not to use the
src-gen modeler.
>
> Michael
>
>
> On 09.11.2012 05:19, Ed Merks wrote:
>> Michael,
>>
>> Comments below.
>>
>> On 09/11/2012 12:15 AM, Michael Scharf wrote:
>>> Hi,
>>>
>>> is there a way to specify where to generate the validator class?
>> No, it's generated in the util package.
>>>
>>> With xbase I have no reason to use @generated NO except for the
>>> validator class. I use a src-gen directory for the
>>> generated sources. But I have to modify the validator.
>> Yes, we don't yet support defining constraints (other than invariant
>> operations).
>>>
>>> - is there a way to specify the directory of the validator?
>> The package, yes.
>>> - I actually use a sub-class outside of the src to implement
>>> the validation. All I need in that case is to change the INSTANCE
>>> of the validator. Unfortunately, the generated validator creates a
>>> lot of warnings.
>> I suppose mostly you'd like to be able to define the constraints in
>> Xcore itself, right?
>>>
>>>
>>> Michael
>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Xcore] Problem with an .xcore model refering to a class defined in a .ecore model
Next Topic:Bug ? Resolving Ecore Cross References
Goto Forum:
  


Current Time: Thu Apr 25 04:14:57 GMT 2024

Powered by FUDForum. Page generated in 0.02889 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top