Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Issue with code generation
Issue with code generation [message #1807912] Wed, 12 June 2019 08:22 Go to next message
Yoann Farre is currently offline Yoann FarreFriend
Messages: 116
Registered: November 2017
Senior Member
Hello,

Using the C++ code generator, I obtain an error that looks like to a bug but I'm not sure about.

The use case is the following one:

I generate automatically a transition in a state machine from a sequence diagram. To keep a link between the transition and the sequence diagram which produces the transition, I created a stereotype applied on the transition which contains a Message as stereotype attribute.

When I generate the code, I want to generate the state machine of the class but the sequence diagram and the Message is useless fot that use case so I applied the Stereotype NoCodeGen (C_Cpp profile) on the package which contains the sequence diagram (and all owned elements).

Now, if I generate the code from this model, I obtain an error (see attached files : pop up and stack trace).

If I remove the message from the transition (so I break the link), the error doesn't occur.

To generate the code correctly, I have to close and open the model.

Seeing the error log, I suppose that the transformation chain try to access to the values of SendEvent and Receive Event elements of the Message.

I precise that the Message Occurence Specifications are stored in the same resource (MyModel.uml) than the other UML elements.

Could you help me with this issue?

Thanks.

Yoann.
  • Attachment: error_log.txt
    (Size: 7.44KB, Downloaded 18 times)
  • Attachment: Error.PNG
    (Size: 19.29KB, Downloaded 77 times)
Re: Issue with code generation [message #1807964 is a reply to message #1807912] Thu, 13 June 2019 11:49 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 228
Registered: March 2011
Location: Paris Saclay, France
Senior Member
The error message indicates that the referenced message-occurence-specification (from the stereotype attribute) is not contained in any resource. If you debug, the eContainer of the message-occurence-specification is probably null as well, i.e. it's not owned by another object. This can happen due to multiple reasons. One is the use of an element created by the UMLFactory that has never been added to a container. But it's more likely an issue of the model copier. If I should look into the issue, I would need your modelto reproduce/identify the issue.

Ansgar
Re: Issue with code generation [message #1808035 is a reply to message #1807964] Fri, 14 June 2019 08:42 Go to previous messageGo to next message
Yoann Farre is currently offline Yoann FarreFriend
Messages: 116
Registered: November 2017
Senior Member
Hello Ansgar,

Thank you. Your answer helps me to find the issue. It is not directly related to the code generation feature, it's only a curious side effect. Indeed, the MessageOccurenceSpecification was not contained in any resource in the source model (but even not existing in the model and that was the reason I didn't understand this issue).

To explain in more detail:
When the Message was created in the sequence diagram, the customization I'm contributing open a pop up dialog and the user has the option to cancel the creation of the Message. In this case a "CommandResult.newCancelledCommandResult()" is returned by the method "doExecuteWithResult" method. The Message and the MessageOccurenceSpecification are well deleted from the model but the MessageOccurenceSpecification are not removed from the field CoveredBy in the Lifeline elements. To be clearer, a reference to a removed element stay in the model.

Nevertheless, this behavior raises two questions:
First : Is it wanted that the copier used for the transformation chain (LazyCopier) copy elements contained in a Package with NoCodeGen stereotype?
Second: The cancel of a command should probably remove all elements and references but in this case, it removes the elements but not some references to this elements. It is probably linked to this thread and the use of GMF commands: GMF commands

Regards.

Yoann.
Re: Issue with code generation [message #1808433 is a reply to message #1808035] Mon, 24 June 2019 14:35 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 228
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi Yoann,

concerning your first question: the lazy copier does not evaluate the "NoCodeGen" stereotype, i.e. it will copy this package regardless of the stereotype. It will (of course) preserve the stereotype.

I'm probably not the best person to answer your second questions as I did not encounter this problem. Elements created within an aborted transaction are normally destroyed. If you use a command within the transaction to set a reference, this should be undone as well. As far as I know, only exceptions as as an NPE could leave the model in an inconsistent state - in this case before the command could be canceled.

Ansgar




Re: Issue with code generation [message #1808434 is a reply to message #1808433] Mon, 24 June 2019 14:48 Go to previous message
Yoann Farre is currently offline Yoann FarreFriend
Messages: 116
Registered: November 2017
Senior Member
Hi Ansgar,

Ok it's clearer. False alert for the code generator, sorry.

No exception was launched during the process I described so it's probably a bug. I workaround the issue by adding a delete command for the shadow references.

Regards.

Yoann.
Previous Topic:Papyrus SysML Tutorial (version 0.1.2)
Next Topic:Eclipse on Mac update sites access problem
Goto Forum:
  


Current Time: Mon Dec 16 02:40:42 GMT 2019

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

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

Back to the top