Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » OCL features, Acceleo and Sirius
OCL features, Acceleo and Sirius [message #1798136] Tue, 13 November 2018 08:01 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 186
Registered: June 2010
Senior Member
Hi,

I created a metamodel with a number of concepts having derived OCL properties. Next, I created a graphical editor for that kind of models using Sirius. In the label expression, I referred to the derived properties. There I ran into some strange things.

With this property, everything works as expected:
property operatesOn1 : ADTO[?] { derived readonly transient volatile }                                        
{                                                                                                             
    initial:                                                                                                  
        self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclAsType(dds::ADTO);   
}                                                                                                             


However, some dereference '.' operates might return null or undefined so I added som safe navigation:

property operatesOn : ADTO[?] { derived readonly transient volatile }                                               
{                                                                                                                   
    initial:                                                                                                        
        self?.parameters->first()?.oclAsType(system::TypedParameter)?.typereference?.type?.oclAsType(dds::ADTO);    
}                                                                                                                   


This does not work. My suspicion in that the safe navigation is not supported when evaluating the OCL query via the Acceleo language.

OK, then I'll rewrite it.

property operatesOn2 : ADTO[?] { derived readonly transient volatile }                                           
{                                                                                                                
    initial:                                                                                                     
        if (self.parameters->size()>0 and self.parameters->first().oclIsKindOf(system::TypedParameter))          
        then                                                                                                     
            let firstpar = self.parameters->first().oclAsType(system::TypedParameter)                            
            in                                                                                                   
            if (firstpar.typereference.oclIsUndefined() or firstpar.typereference.type.oclIsUndefined())         
            then                                                                                                 
                null                                                                                             
            else                                                                                                 
                let firstpartype = firstpar.typereference.type                                                   
                in                                                                                               
                if (firstpartype.oclIsKindOf(dds::ADTO))                                                         
                then                                                                                             
                    firstpartype.oclAsType(dds::ADTO)                                                            
                else                                                                                             
                    null                                                                                         
                endif                                                                                            
            endif                                                                                                
        else                                                                                                     
            null                                                                                                 
        endif;                                                                                                   
}                                                                                                                


This one also does not work. Maybe the 'let' expression is in the way. Let's remove it:

property operatesOn3 : ADTO[?] { derived readonly transient volatile }                                                        
{                                                                                                                             
    initial:                                                                                                                  
        if (self.parameters->size()>0 and self.parameters->first().oclIsKindOf(system::TypedParameter))                       
        then                                                                                                                  
            if ((self.parameters->first().oclAsType(system::TypedParameter).typereference.oclIsUndefined()) or                
                (self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclIsUndefined()))             
            then                                                                                                              
                null                                                                                                          
            else                                                                                                              
                if (self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclIsKindOf(dds::ADTO))     
                then                                                                                                          
                    self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclAsType(dds::ADTO)        
                else                                                                                                          
                    null                                                                                                      
                endif                                                                                                         
            endif                                                                                                             
        else                                                                                                                  
            null                                                                                                              
        endif;                                                                                                                
}                                                                                                                             


This one works again. I verified using the semantic property vies in Sirius that each of the 'operatesOn' variants delivers the same result so the ocl expressions themselves seem to be correct.

Is this indeed caused by the fact that OCL code, invokved by the Acceleo interpreter, does not support 'let' and safe navigation?

Greetings,
Wilbert.



Re: OCL features, Acceleo and Sirius [message #1798138 is a reply to message #1798136] Tue, 13 November 2018 09:20 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6440
Registered: July 2009
Senior Member
Hi

Yes. Acceleo uses the Classic Eclipse OCL that has been maintained but not evolved for many years now. As such it has none of the prototyping for a next OCL in the Unified / Pivot-based OCL.

Therefore
- no inference of let variable types
- no safe navigation
- no .....
- no API instability

Some newer functions such as selectByKind have been added. They may help a bit.

Regards

Ed Willink
Previous Topic:API for edge creation?
Next Topic:Getting exception while saving into resource set
Goto Forum:
  


Current Time: Sun Aug 25 22:04:43 GMT 2019

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

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

Back to the top