Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Correct way to validate an .odesign
Correct way to validate an .odesign [message #1830249] Wed, 22 July 2020 04:24 Go to next message
Leonardo Montecchi is currently offline Leonardo MontecchiFriend
Messages: 10
Registered: September 2013
Junior Member
Hello,

I am used to run the validation from the contextual menu on my models to verify that no hidden problems are there. However, I am not sure what is the correct way to do this with .odesign files.

If I use the "classical" validate menu I get some strange errors, in particular, when I use the "oclAsType" operation:

Nothing will be left after calling oclAsType:
EClassifier=Type is not compatible with type Set([email]org.eclipse.emf.ecore.impl.EClassImpl@5951d91[/email] (name: PrimitiveType) (instanceClassName: null) (abstract: false, interface: false)[email]org.eclipse.emf.ecore.impl.EClassImpl@3ce92d27[/email] (name: PrimitiveType) (instanceClassName: null) (abstract: false, interface: false)


What does this error mean exactly? My editor works as expected, but it seems the validator always assumes that the "oclAsType" operation will return null. In this case the involved metaclasses are "Type" and "PrimitiveType". The latter is indeed subclass of the former, so the cast is possible, and, as mentioned, the expression works correctly in runtime.

I have explicitly added the metamodel to the odesign file and as a dependency to the plugin.

Thanks,
Leonardo.


Leonardo Montecchi
Instituto de Computação, UNICAMP
http://ic.unicamp.br/~leonardo
http://laser.ic.unicamp.br/

[Updated on: Wed, 22 July 2020 04:25]

Report message to a moderator

Re: Correct way to validate an .odesign [message #1830253 is a reply to message #1830249] Wed, 22 July 2020 07:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The error message includes the additional clue "with type Set" which strongly suggests that you are not using the types that you intended. Most likely something has/ha not been converted to a collection. If you were using OCL I would look at "."/"->" typos or implicit-sets, but I am not aware that you can use OCL with Sirius, I presume you are using AQL on which I cannot comment more informatively.

Regards

Ed Willink
Re: Correct way to validate an .odesign [message #1830290 is a reply to message #1830253] Wed, 22 July 2020 18:26 Go to previous messageGo to next message
Leonardo Montecchi is currently offline Leonardo MontecchiFriend
Messages: 10
Registered: September 2013
Junior Member
Hello Ed,

thank you for your answer. Yes, that part about Set is strange. I was thinking something similar, but I checked everything and the feature has LowerBound/UpperBound equal to 1, and oclAsType is called directly on the feature. The query that generates the error (among other ones, actually), is the following:

self.type.oclIsTypeOf(san::ComplexType) or (self.type.oclIsTypeOf(san::PrimitiveType) and self.type.oclAsType(san::PrimitiveType).type <> san::ExtendedPlaceType::short)


where self.type has LowerBound/UpperBound equal to 1 in the ecore metamodel. I have also tried to add "->first()" basically everywhere, but I get the same error.

I agree it is not the most beautiful query (or metamodel) but it should work.

I am using the latest version of Eclipse (2020-06)


Leonardo Montecchi
Instituto de Computação, UNICAMP
http://ic.unicamp.br/~leonardo
http://laser.ic.unicamp.br/
Re: Correct way to validate an .odesign [message #1830321 is a reply to message #1830290] Thu, 23 July 2020 10:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

As I commented before you are prbably not using the types that you intended, and I cannot really comment on AQL. However I recall that Acceleo that influenced AQL had some difficulties with complex expressions so you might try introducing some let-variables.

You might try debugging the OCL equivalent using either/both of the OCL consoles.

Of course the debugger is your friend, so run in a nested Eclipse so that you can set breakpoint on the code that gives the error. Then you may understand what model elements it is manipulating to conclude that there is a problem.

"self.type.oclAsType(san::PrimitiveType).type" looks like a typo to me that ought to give a syntax error. But maybe your secret san::PrimitiveType unlike uml::PrimitiveType has a type property.

Use of "and" and "or" without parentheses always makes me very suspicious; I don't know what it means and may have to reach for the manuals where, in the case of OCL, I know that the specification changed between OCL 2.0 and 2.2. Don't do it. Even really good programmers get it wrong; a very recent fix for EMF had an &&/|| precedence bug that was caught during a review.

Use of oclIsTypeOf is nearly always wrong. It looks suspiciously as if you should be using oclIsKindOf.

Regards

Ed Willink
Re: Correct way to validate an .odesign [message #1830357 is a reply to message #1830321] Fri, 24 July 2020 02:18 Go to previous messageGo to next message
Leonardo Montecchi is currently offline Leonardo MontecchiFriend
Messages: 10
Registered: September 2013
Junior Member
Hello Ed,

thank you for your time and for the suggestions.

Maybe I was not clear in my question, but I am talking about design time. I am specifying the editor with Sirius, and when I validate the editor it gives that error. So there is no instance element to check, and to run the debug as you suggest I think I would need to run the source code of Sirius in debug mode.

At runtime the editor works without errors, but the validation of the editor does not pass. It may have to do with Sirius not supporting complex expressions as you said. I found that transforming the element to a Sequence, then using the "->filter()" operation and then taking "->first()" works, but there must be a better solution. (it seems that "->filter()" is the cast operation in Sirius).

Regards,
Leonardo.


Leonardo Montecchi
Instituto de Computação, UNICAMP
http://ic.unicamp.br/~leonardo
http://laser.ic.unicamp.br/

[Updated on: Fri, 24 July 2020 02:19]

Report message to a moderator

Re: Correct way to validate an .odesign [message #1830362 is a reply to message #1830357] Fri, 24 July 2020 07:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

edit/compile/design/run-time it's irrelevant. You are seeing a message that confuses you. In the absence of further magic insights, your ultimate option is to use the debugger to see how that message arises. Eclipse is Open Source so you can see / debug nearly everything.

If filter() influences the situation when you are confident that you are not using collections then
a) your confidence is misplaced
b) your use of filter() introduces a different confusion
c) your tooling is defective
You just need to decide which.

Given that filter() can affect your observations you may find that you can try some variations that give you some further insights without struggling with the debugger.

Regards

Ed Willink
Previous Topic:Extending/Overriding pages
Next Topic:Using Sirius without strong coupling to aird files
Goto Forum:
  


Current Time: Fri Apr 19 21:25:38 GMT 2024

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

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

Back to the top