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  |
Philip Schröder Messages: 28 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 #1755673 is a reply to message #1755548] |
Mon, 06 March 2017 17:53   |
Philip Schröder Messages: 28 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 #1755678 is a reply to message #1755675] |
Mon, 06 March 2017 18:51   |
Philip Schröder Messages: 28 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 #1755828 is a reply to message #1755818] |
Wed, 08 March 2017 13:51  |
Philip Schröder Messages: 28 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
|
|
|
Goto Forum:
Current Time: Thu Nov 30 18:56:39 GMT 2023
Powered by FUDForum. Page generated in 0.02009 seconds
|