Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Comments in OCLInput
Comments in OCLInput [message #760840] Mon, 05 December 2011 07:28 Go to next message
John Guerson is currently offline John Guerson
Messages: 51
Registered: August 2011
Member
Hi,
Could someone tell me how to get the comments in a document ocl (OCLInput)?

package Example
 
context School
-- commentary1
inv one_enrollment_for_student :
self.schoolOf->forAll( x: Student | x.enr1->intersection(self.enr2)->size() = 1 )

context School
-- commentary2
inv unique_id:
self.enr2->isUnique(x: Enrollment | x.id)


Perhaps through the class org.eclipse.ocl.uml.OCL. Is there a way to do this?
The method getOwnedComments() of org.eclipse.uml2.uml.Constraint always return null.

List <Constraint> constraints = myOCL.parse(document);
for (ct Constraint: constraints) {
         System.out.println (ct.getOwnedComments ());
}


The only way to do this is to do manually(through the manipulation of strings) ?

Regards,
John
Re: Comments in OCLInput [message #760949 is a reply to message #760840] Mon, 05 December 2011 12:05 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

The org.eclipse.ocl.ecore and org.eclipse.ocl.uml plugins use the old
LPG parser for which you can find start and end text offsets in the
CSTNodes. So you can certainly use these to scan for additional text. It
is a long time since I looked at this code. My recollection is that the
CSTNodes also have the LPG start and end tokens from which you can find
the comments as 'adjuncts'. The normal lex+parse+analyze takes you
straight from text via CST to AST. To get at the intermediate CST, you
will need to invoke only the lex+parse phases.

The new org.eclipse.ocl.examples.xtext plugins use Xtext and so support
editors. Comment support has been added so that /** .. */ comments are
automatically interpreted as UML Comments or Ecore documentation
EAnnotations and contribute to hover text. -- ... comments remain text only.

Regards

Ed Willink

On 05/12/2011 12:28, John wrote:
> Hi,
> Could someone tell me how to get the comments in a document ocl
> (OCLInput)?
>
> package Example
>
> context School
> -- commentary1
> inv one_enrollment_for_student :
> self.schoolOf->forAll( x: Student |
> x.enr1->intersection(self.enr2)->size() = 1 )
>
> context School
> -- commentary2
> inv unique_id:
> self.enr2->isUnique(x: Enrollment | x.id)
>
>
> Perhaps through the class org.eclipse.ocl.uml.OCL. Is there a way to
> do this? The method getOwnedComments() of
> org.eclipse.uml2.uml.Constraint always return null.
>
>
> List <Constraint> constraints = myOCL.parse(document);
> for (ct Constraint: constraints) {
> System.out.println (ct.getOwnedComments ());
> }
>
>
> The only way to do this is to do manually(through the manipulation of
> strings) ?
>
> Regards,
> John
>
Previous Topic:How to define cross-referenced custom operations
Next Topic:xtext.completeocl.ui export packages
Goto Forum:
  


Current Time: Sat Aug 30 20:33:31 EDT 2014

Powered by FUDForum. Page generated in 0.02800 seconds