Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Invalid Type (OCL Collection in Acceleo) (Several Types of OCL are not found in Acceleo)
Invalid Type (OCL Collection in Acceleo) [message #1755547] Sun, 05 March 2017 14:27 Go to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 24
Registered: January 2017
Junior Member
Hello,
I am trying to use several standard OCL types and functions in my code generation,
which are listed here

http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.acceleo.doc%2Fpages%2Freference%2Flanguage.html

I am using Acceleo 3.6.6 with Eclipse Mars.2.

Following some sample code to explain the problem

[comment encoding = UTF-8 /]
[module generate('http://www.eclipse.org/uml2/5.0.0/UML', 'http://www.eclipse.org/ocl/1.1.0/OCL/Types')]

[template public generateElement(c : Class)]
       [comment @main/]
       [let o : Set = Set{'1', '2', '3'}] [/let]
[/template]


The editor tells me that Set is an invalid type, same for OrderedSet, Sequence and Bag; if I build an empty template like this

[template public generateElement(s : Set)]
[/template]


the problem still persists.


I initially had only

[module generate('http://www.eclipse.org/uml2/5.0.0/UML')]


Adding the OCL-types didn't change anything.

My original problem was that I had a class or operation with a bunch of stereotypes,
and I wanted to check if any of a Set of designated stereotypes were included.

My approach was something like this:

[template public foo (c : Class)]
    [let s : Set = OrderedSet{'Stereo1', 'Stereo2', 'Stereo3'}->intersection(c.getAppliedStereotypes())]
        [if s.notEmpty()]
            [for (st : Stereotype | s ) before('specialStuff <') separator(', ') after('>')]
                [st.name/] 
            [/for]
        [/if]
    [/let]
    class [c.name/]
[/template]


Thank you for your help

Best regards

Philip.

[Updated on: Sun, 05 March 2017 14:35]

Report message to a moderator

Re: Invalid Type (OCL Collection in Acceleo) [message #1755548 is a reply to message #1755547] Sun, 05 March 2017 15:28 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5583
Registered: July 2009
Senior Member
Hi

Works fine for me using Acceleo 3.7.0.

I suspect there is something wrong with your project.

Regards

Ed Willink
Re: Invalid Type (OCL Collection in Acceleo) [message #1755673 is a reply to message #1755548] Mon, 06 March 2017 17:53 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 24
Registered: January 2017
Junior Member
Hello Ed,
thank you for your answer again.

Assuming maybe something was wrong with my Environment, since I tried different generators and there were some conflicts, plus initially I installed Acceleo from Eclipse Marketplace, which is in Incubation there, I unistalled Acceleo completely, searched with Effective File Search (Windows advanced search app) for everything Acceleo related and deleted everything (from eclipse/features, eclipse/plugin and eclipse/configuration directories as I recall) except my projects.

When installing Acceleo 3.7 + Additional Interpreters again, there were some conflicts, so I had to uninstall UML Generator and Ecore diagram editor, afterwards I got a clean install of Acceleo 3.7 into Eclipse Mars.2.

Then I created a new Acceleo project using the 'http://www.eclipse.org/uml2/5.0.0/UML' metaclass.

Still got the same error.

Do I need to compile something in advance or anything?
Do I need any extra OCL packages installed?

Thank you for your time and trouble.

Best regards

Philip.
Re: Invalid Type (OCL Collection in Acceleo) [message #1755675 is a reply to message #1755673] Mon, 06 March 2017 18:20 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5583
Registered: July 2009
Senior Member
Hi

I'm sorry, but it is nearly four years since I migrated from Acceleo to Xtend. https://bugs.eclipse.org/bugs/show_bug.cgi?id=410265

Since the Acceleo developers are intermittent in their Forum support, I do my best to answer for them. I installed Acceleo in my workspace to check your problem; no problem.

If you persist with Acceleo, I am afraid that you may be on your own.

Regards

Ed Willink
Re: Invalid Type (OCL Collection in Acceleo) [message #1755678 is a reply to message #1755675] Mon, 06 March 2017 18:51 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 24
Registered: January 2017
Junior Member
Hello,
yes I know, that you proposed XTend.

For me it is just, that I find the syntax too hard to work with.
Just when I have longer code and want to skim the text for some template,
it seemed quite hard to distinguish Java output text from XTend code.
Yes, you have those << and >> around the code;
but when I am tired after hours of programming, I need a clear distinction of blocks in long source files, which doesn't look to convincing for me in XTend.

So I guess, I will stick with Acceleo, but thank you anyway.
If I find a solution, I will post it here.

Best regards

Philip.
Re: Invalid Type (OCL Collection in Acceleo) [message #1755745 is a reply to message #1755678] Tue, 07 March 2017 12:22 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 24
Registered: January 2017
Junior Member
Hmmm,
it seems, according to this

http://download.eclipse.org/ocl/javadoc/5.0.0/org/eclipse/ocl/types/class-use/OrderedSetType.html

that the OrderedSet type (and the others as well) is defined in 'org.eclipse.ocl.ecore' as a generic Java type, but is mapped to an Acceleo type using 'org.eclipse.ocl.types', as well as 'org.eclipse.ocl.parser' with the factory methods; when looking at my project,
there is quite a bunch of 'org.eclipse.ocl.<something>' stuff included, but in my Manifest file I can only include the 2 seen on the picture

http://prnt.sc/eh2e6r

Maybe I need to install something that has the other plugins.

Best

Philip.
Re: Invalid Type (OCL Collection in Acceleo) [message #1755752 is a reply to message #1755745] Tue, 07 March 2017 13:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5583
Registered: July 2009
Senior Member
Hi

The Classic OCL used by Acceleo uses two sets of definitions. A generic OrderedSetType<T,O> in the org.eclipse.ocl plugin is parameterized so that OrderedSet in the org.eclipse.ocl.ecore plugin maps to OrderedSet<EClassifier,EOperation>. There is an alternate parameterization for UML that is not relevant to you, even if you are using UML models, your tooling is Ecore-based. You should find that importing org.eclipse.ocl.ecore is sufficient to import everything you need. It is only if you start referencing OCL types in your Java code that any of this parameterization complexity should affect you. (The new Pivot-based OCL has none of the parameterization complexity.)

But you really shouldn't be getting anywhere close to these internal details.

You picture seems to be a picture of a link.

Regards

Ed Willink
Re: Invalid Type (OCL Collection in Acceleo) [message #1755814 is a reply to message #1755752] Wed, 08 March 2017 11:34 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 24
Registered: January 2017
Junior Member
Dear Ed,
thank you for still trying to help me.

Today I installed Eclipse Neon for a fresh start to test if my overfull Eclipse Mars had some corrupted packages, I chose the 32Bit Version, since I am using some legacy plugins.

"java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Client VM (build 25.5-b02, mixed mode, sharing)"

According to this

https://wiki.eclipse.org/Acceleo/Setup_Environment

I need EMF and OCL.

I went to Help->Install New Software->http://download.eclipse.org/releases/neon, and chose from Modeling everything EMF and OCL related except the incubating or experimental stuff.

Afterwards I installed Acceleo Help->Install New Software->http://download.eclipse.org/acceleo/updates/releases/3.7 and installed everything in Acceleo and Additional Interpreters.

Then after restarting Eclipse, I created a new Acceleo project and included the uml2 5.0 metamodel as usual.

Still the same problem

Best regards

Philip.

[Updated on: Wed, 08 March 2017 11:37]

Report message to a moderator

Re: Invalid Type (OCL Collection in Acceleo) [message #1755818 is a reply to message #1755814] Wed, 08 March 2017 12:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5583
Registered: July 2009
Senior Member
Hi

Reviewing your original report, I recall pain because Acceleo gets confused if you have org.eclipse.ocl.ecore as an open project in your workspace. As an OCL developer, this was a pretty serious limitation for me. As an ordinary user you may be able to survive by just closing the project that you loaded to 'help' with debugging. Since Acceleo's resolution's are suspect, I would recommend deleting project (not plugin) on disk as well.

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=345708#c5

The Install New Software should sort out all dependencies automatically, so it should be sufficient to unzip Eclipse then install Acceleo from the SimRel repo. Installation of other projects is only necessary if you want their full support and source code. On no account install all of EMF, EMF supports a variety of conflicting targets, such as RCP and RAP. Install just the EMF SDK (and XSD SDK). If you want UML, then you should probably install that before Acceleo.

Regards

Ed Willink

Re: Invalid Type (OCL Collection in Acceleo) [message #1755828 is a reply to message #1755818] Wed, 08 March 2017 13:51 Go to previous message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 24
Registered: January 2017
Junior Member
Dear Ed,
I beg your pardon, it seems, the error was quite dumb in the end.
I have to provide the type of the elements for Sets and Sequences,
as it seems

[let s : Set = Set{'1', '2', '3'}][/let]


gave the Invalid Type Set error, while

[let s : Set(String) = Set{'1', '2', '3'}][/let]


works fine.

I sincerly beg your pardon for giving you so much trouble,
while simply missing the right syntax.


Best regards

Philip.

[Updated on: Wed, 08 March 2017 13:53]

Report message to a moderator

Previous Topic:Xpand2 IncrementalGenerationFacade deprecated
Next Topic:[acceleo] let =null
Goto Forum:
  


Current Time: Sun Jan 21 13:02:23 GMT 2018

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

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