Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gendoc » Question on fragment syntax
Question on fragment syntax [message #1709690] Wed, 30 September 2015 12:49 Go to next message
Marc FLAUW is currently offline Marc FLAUWFriend
Messages: 151
Registered: July 2009
Senior Member

Hi,

I have a problem using fragments. I am using Gendoc 0.5.1 with Papyrus 1.1.0 on Eclipse Mars.
I used the following code to print the documentation/ comment of a package:
[for (p:Package | self.ownedElement->filter(Package))]
1 [P.NAME/]
[for (co:Comment | p.ownedComment)]
<dropEmpty>[co._body/]</dropEmpty>
[/for]<drop/>

[/for]
I tried to move the 3 lines printing the comments to a fragment:
<fragment name='displayComments' importedBundles='commons;gmf;papyrus'>
<arg name='element' type='uml::Element'/>
[for (co:Comment | element. ownedComment)]<drop/>
<dropEmpty>[co._body/]</dropEmpty>
[/for]<drop/>
</fragment>

And then use this fragment in the main code:
[for (p:Package | self.ownedElement->filter(Package))]
2 [P.NAME/]

[p.displayComments()/]

However, I got the following errors:
The execution of a script failed: Error during generation of Gendoc script :Invalid Type: Comment
Unrecognized variable: (_body)

What did I do wrong?

Thanks and regards,

Marc
Re: Question on fragment syntax [message #1709693 is a reply to message #1709690] Wed, 30 September 2015 13:03 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 73
Registered: July 2014
Member
Fragments appear to be a bit temperamental somehow...
Do you try typing "co" with uml::Comment ?

Yves


Yves
Re: Question on fragment syntax [message #1709696 is a reply to message #1709693] Wed, 30 September 2015 13:13 Go to previous messageGo to next message
Marc FLAUW is currently offline Marc FLAUWFriend
Messages: 151
Registered: July 2009
Senior Member
Thanks, adding uml:: in front of Comment made the trick.

Best regards,

Marc
Re: Question on fragment syntax [message #1709699 is a reply to message #1709696] Wed, 30 September 2015 13:18 Go to previous messageGo to next message
Marc FLAUW is currently offline Marc FLAUWFriend
Messages: 151
Registered: July 2009
Senior Member
Related question:

when using the fragement as above:
[for (co:Comment | element. ownedComment)]<drop/>
<dropEmpty>[co._body/]</dropEmpty>
[/for]<drop/>

When there are several comments, they appear to be in the wrong order: comment2, then comment1.
Any way to make them in the right order?

Thanks,

Marc
Re: Question on fragment syntax [message #1709727 is a reply to message #1709699] Wed, 30 September 2015 14:46 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 73
Registered: July 2014
Member
The point is that ownedComment is not an ordered collection... So you will have to use another trick, again! Wink

Here is mine:
* add an ownedConstraint to the element owning the comments you want to order and give it a specific name (e.g. "_OrderedComments")
* using the contrainedElement (which is ordered) refer to the comment in the requested order.
* Use this constraint in your loop (you can use a filter on the name) rather than the ownedComment.

This is a bit cumbersome but it works and this the best I found so far.

Yves


Yves
Re: Question on fragment syntax [message #1709737 is a reply to message #1709727] Wed, 30 September 2015 15:36 Go to previous messageGo to next message
Marc FLAUW is currently offline Marc FLAUWFriend
Messages: 151
Registered: July 2009
Senior Member
Thanks, a bit cumbersome indeed.

Best regards,

Marc
Re: Question on fragment syntax [message #1709762 is a reply to message #1709737] Wed, 30 September 2015 18:00 Go to previous message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 426
Registered: July 2009
Senior Member
another solution is to define / use a sort method based on eContents, if I remember well you can do this kind of operation :

[comment Order a sequence according to containment order of the Eobject, works well if all the eobjects in the bag are contained in the same object /]
[query public sortedByContainmentOrder(arg : Bag(ecore::EObject)) : Sequence(ecore::EObject) = 
self->sortedBy(
  e : ecore::EObject | e.eContainer().eContents()->indexOf(e)
)/]


We should add this query in common gendoc bundle




Previous Topic:Stereotypes
Next Topic:More on stereotypes
Goto Forum:
  


Current Time: Thu Nov 15 16:31:06 GMT 2018

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

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

Back to the top