Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [xcore/OCL] Error in auto generated code
[xcore/OCL] Error in auto generated code [message #898488] Thu, 26 July 2012 13:22 Go to next message
Wouter Schaekers is currently offline Wouter SchaekersFriend
Messages: 17
Registered: July 2012
Junior Member
Hi

Example:
class Rule
{
Integer num
@Pivot(derivation="self.num > 3")
derived Boolean b
}

Problem: This gives me an error in the auto generated code. In the src-gen folder, Project.impl package, RuleImpl.java class:
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case Test2Package.RULE__NAME:
setName(NAME_EDEFAULT);
return;
case Test2Package.RULE__NUM:
setNum(NUM_EDEFAULT);
return;
case Test2Package.RULE__B:
setB(B_EDEFAULT);
return;
}
super.eUnset(featureID);
}

'setB(B_EDEFAULT);' gives an error: 'B_EDEFAULT cannot be resolved to a variable'
This is solved by creating a field in the generated class. Is there any way to solve this without manually fix things?

Thanks.

[Updated on: Thu, 26 July 2012 13:23]

Report message to a moderator

Re: [xcore/OCL] Error in auto generated code [message #898493 is a reply to message #898488] Thu, 26 July 2012 13:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Interesting; I had no idea that OCL could be used in this way with
Xcore; at one level it seems sensible.

At another it's rather stupid.

Xcore provides a nice Xtext editor for Java implementations of Ecore
features; use Java with Xcore.

If you want to use OCL, use the OCLinEcore Xtext editor so that you get
syntax checking on the OCL.

---

You're particular problem is that you need to specify that 'b' is
transient and volatile.

Regards

Ed Willink

On 26/07/2012 14:22, Wouter Schaekers wrote:
> Hi
>
> Example:
> class Rule
> {
> Integer num
> @Pivot(derivation="self.num > 5")
> derived Boolean b
> }
>
> Problem: This gives me an error in the auto generated code. In the
> src-gen folder, Project.impl package, RuleImpl.java class:
> @Override
> public void eUnset(int featureID)
> {
> switch (featureID)
> {
> case Test2Package.RULE__NAME:
> setName(NAME_EDEFAULT);
> return;
> case Test2Package.RULE__NUM:
> setNum(NUM_EDEFAULT);
> return;
> case Test2Package.RULE__B:
> setB(B_EDEFAULT);
> return;
> }
> super.eUnset(featureID);
> }
>
> 'setB(B_EDEFAULT);' gives an error: 'B_EDEFAULT cannot be resolved to
> a variable'
> This is solved by creating a field in the generated class. Is there
> any way to solve this without manually fix things?
>
> Thanks.
Re: [xcore/OCL] Error in auto generated code [message #898499 is a reply to message #898493] Thu, 26 July 2012 13:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Ed,

Comments below.

On 26/07/2012 3:30 PM, Ed Willink wrote:
> Hi
>
> Interesting; I had no idea that OCL could be used in this way with
> Xcore; at one level it seems sensible.
>
> At another it's rather stupid.
>
> Xcore provides a nice Xtext editor for Java implementations of Ecore
> features; use Java with Xcore.
>
> If you want to use OCL, use the OCLinEcore Xtext editor so that you
> get syntax checking on the OCL.
>
> ---
>
> You're particular problem is that you need to specify that 'b' is
> transient and volatile.
The "derived" keyword implies transient and volatile; there's currently
no way to specify a derived feature that isn't transient and isn't volatile.
>
> Regards
>
> Ed Willink
>
> On 26/07/2012 14:22, Wouter Schaekers wrote:
>> Hi
>>
>> Example:
>> class Rule
>> {
>> Integer num
>> @Pivot(derivation="self.num > 5")
>> derived Boolean b
>> }
>>
>> Problem: This gives me an error in the auto generated code. In the
>> src-gen folder, Project.impl package, RuleImpl.java class:
>> @Override
>> public void eUnset(int featureID)
>> {
>> switch (featureID)
>> {
>> case Test2Package.RULE__NAME:
>> setName(NAME_EDEFAULT);
>> return;
>> case Test2Package.RULE__NUM:
>> setNum(NUM_EDEFAULT);
>> return;
>> case Test2Package.RULE__B:
>> setB(B_EDEFAULT);
>> return;
>> }
>> super.eUnset(featureID);
>> }
For me this produces

public boolean eIsSet(int featureID)
{
switch (featureID)
{
case LibraryPackage.RULE__NUM:
return NUM_EDEFAULT == null ? num != null :
!NUM_EDEFAULT.equals(num);
case LibraryPackage.RULE__B:
return B_EDEFAULT == null ? b != null : !B_EDEFAULT.equals(b);
}
return super.eIsSet(featureID);
}

Are you using the Juno version of Xcore? This looks familiar, like a bug
that's already fix...
>>
>> 'setB(B_EDEFAULT);' gives an error: 'B_EDEFAULT cannot be resolved to
>> a variable'
>> This is solved by creating a field in the generated class. Is there
>> any way to solve this without manually fix things?
>>
>> Thanks.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore/OCL] Error in auto generated code [message #898506 is a reply to message #898493] Thu, 26 July 2012 13:50 Go to previous messageGo to next message
Wouter Schaekers is currently offline Wouter SchaekersFriend
Messages: 17
Registered: July 2012
Junior Member
Ed Willink wrote on Thu, 26 July 2012 09:30
Interesting; I had no idea that OCL could be used in this way with Xcore.

Everything that I tried to do with OCL in Xtext can be done in Xcore (or at least the things I tried).

Ed Willink wrote on Thu, 26 July 2012 09:30
At another it's rather stupid.

Xcore provides a nice Xtext editor for Java implementations of Ecore
features; use Java with Xcore.

If you want to use OCL, use the OCLinEcore Xtext editor so that you get
syntax checking on the OCL.

That's not what we want to do. We want to develop a DSL, that in the end will be parsed outside of all the Xcore/Xtext tools (So, write a parser ourselves that converts our model/constrains to C++ code.). Xcore is preferred over Xtext, because it's more abstract and less dependent on a lot of stuff. And for the same reason, we think that OCL is preferred over Java.

Ed Willink wrote on Thu, 26 July 2012 09:30
You're particular problem is that you need to specify that 'b' is
transient and volatile.

'derived transient volatile Boolean b' doesn't work (the same problem). It's just a minor problem. It would be nice if it can be fixed, but it's not that big a deal.

[Updated on: Thu, 26 July 2012 13:50]

Report message to a moderator

Re: [xcore/OCL] Error in auto generated code [message #898508 is a reply to message #898499] Thu, 26 July 2012 13:53 Go to previous messageGo to next message
Wouter Schaekers is currently offline Wouter SchaekersFriend
Messages: 17
Registered: July 2012
Junior Member
Ed Merks wrote on Thu, 26 July 2012 09:40
For me this produces

public boolean eIsSet(int featureID)
{
switch (featureID)
{
case LibraryPackage.RULE__NUM:
return NUM_EDEFAULT == null ? num != null :
!NUM_EDEFAULT.equals(num);
case LibraryPackage.RULE__B:
return B_EDEFAULT == null ? b != null : !B_EDEFAULT.equals(b);
}
return super.eIsSet(featureID);
}

Are you using the Juno version of Xcore? This looks familiar, like a bug
that's already fix...

Yes, I'm using Juno. The thing I posted was just a part of the code. The whole code:

@Ecore(invocationDelegates="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
settingDelegates="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot", validationDelegates="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot")
package Test2

annotation "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot" as Pivot

class DomainModel
{
contains Rule [] rules
}

class Rule
{
Integer num
@Pivot(derivation="self.num > 5")
derived Boolean b
}

[Updated on: Thu, 26 July 2012 13:54]

Report message to a moderator

Re: [xcore/OCL] Error in auto generated code [message #898519 is a reply to message #898508] Thu, 26 July 2012 14:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Wouter,

Yes, I can reproduce the problem with that larger block of code. Please
open a bugzilla and I'll try to get it fixed in the maintenance stream.

On 26/07/2012 3:53 PM, Wouter Schaekers wrote:
> Ed Merks wrote on Thu, 26 July 2012 09:40
>> For me this produces
>>
>> public boolean eIsSet(int featureID)
>> {
>> switch (featureID)
>> {
>> case LibraryPackage.RULE__NUM:
>> return NUM_EDEFAULT == null ? num != null :
>> !NUM_EDEFAULT.equals(num);
>> case LibraryPackage.RULE__B:
>> return B_EDEFAULT == null ? b != null : !B_EDEFAULT.equals(b);
>> }
>> return super.eIsSet(featureID);
>> }
>>
>> Are you using the Juno version of Xcore? This looks familiar, like a
>> bug that's already fix...
>
> Yes, I'm using Juno. The thing I posted was just a part of the code.
> The whole code:
>
> @Ecore(invocationDelegates="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
>
> settingDelegates="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
> validationDelegates="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot")
> package Test2
>
> annotation "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot" as Pivot
>
> class DomainModel
> {
> contains Rule [] rules
> }
>
> class Rule
> {
> Integer num
> @Pivot(derivation="self.num > 5")
> derived transient volatile Boolean b
> }


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [xcore/OCL] Error in auto generated code [message #898531 is a reply to message #898519] Thu, 26 July 2012 14:23 Go to previous message
Wouter Schaekers is currently offline Wouter SchaekersFriend
Messages: 17
Registered: July 2012
Junior Member
Ed Merks wrote on Thu, 26 July 2012 10:03
Please open a bugzilla and I'll try to get it fixed in the maintenance stream.

-> https://bugs.eclipse.org/bugs/show_bug.cgi?id=386050
Previous Topic:Associating rcp exe with "this kind of file"
Next Topic:diagram editor for dynamic objects
Goto Forum:
  


Current Time: Thu Apr 25 22:54:11 GMT 2024

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

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

Back to the top