Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MDT (Model Development Tools) » UML2 MOFM2T API DOC?(Is there an API Doc for uml2/5.0.0/UML anywhere?)
UML2 MOFM2T API DOC? [message #1755151] Tue, 28 February 2017 13:49 Go to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 25
Registered: January 2017
Junior Member
Hello,
I am trying to set up a code generator for an Android NDK-project using Acceleo.
While there seem to be plenty of tutorials with code snippets, I have yet to find an API DOC
for the eclipse.org/uml2/5.0.0/UML metamodel.

I tried code completion from within Eclipse with something like


[template public foo(c : Class)]
...
c. (now press Ctrl + Space)
...
[/template]

but to no avail.

Isn't there any document that is like the Java API Doc, listing all functions and attributes (not just the ones used by chance in certain tutorials) for
a specific Type (like class, operation, attribute, stereotype, package, etc.) best with a short description of what they do?

Thank you very much for your help.

Best

Philip.

Re: UML2 MOFM2T API DOC? [message #1755152 is a reply to message #1755151] Tue, 28 February 2017 13:58 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1172
Registered: July 2009
Location: Canada
Senior Member

Hi, Philip,

See https://www.eclipse.org/modeling/mdt/javadoc/?cp=83_3_2#uml2 where you will find Javadocs for all current and past versions of the UML2 API. As linked from the UML2 Developer Guide at http://help.eclipse.org.

BTW, the UML2 project has its own dedicated forum for user discussions.

HTH,

Christian
Re: UML2 MOFM2T API DOC? [message #1755155 is a reply to message #1755152] Tue, 28 February 2017 14:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5929
Registered: July 2009
Senior Member
Hi

Acceleo/MOFM2T is a modeling tool and so you use model element names such as "name" rather than "name"/"getName()"/"setName() that you might get misled by in JavaDocs.

The definitive API is as in the UML 2.5 specification. Opening UML.ecore can be quite helpful. The Java Type Hierarchy of the UML2 Java model can also be helpful provided you reverse the Java names back to the model names.

Acceleo appears to be the primary M2T in Eclipse, but you should be aware that as a Java++, Xtend has M2T capabilities as well; look for String Templates in the documentation.

I find Xtend+Java easier to use than Acceleo since Xtend provides a Java within template within Java capability, offering inner Java detail, and outer Java control. In contrast Acceleo is OCL/Java inner detail within template control; an outer Java capability is only available if you rewrite the main program.

Regards

Ed Willink
Re: UML2 MOFM2T API DOC? [message #1755169 is a reply to message #1755152] Tue, 28 February 2017 16:57 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 25
Registered: January 2017
Junior Member
First of all thank you both for your quick and informative answers.
I beg your pardon, that I postet in the wrong Forum;
I am still not sure, if this is about UML or MOFM2T or Acceleo.

Maybe a little more details would have been great.
I have already read those

https://wiki.eclipse.org/Acceleo/Getting_Started
http://www.omg.org/spec/MOFM2T/1.0/PDF/
http://www.omg.org/spec/UML/2.5/PDF/

The first one, for instance has an example for generating JavaBeans
containing the following code snippet

[template public generate(aClass : Class)]
[file (aClass.name.concat('.java'), false)]
   public class [aClass.name.toUpperFirst()/] {
   [for...


So I know at least, that there has to be some Object or Type named 'Class', which has to have an attribute 'name', which is itself an object with an operation 'toupperFirst()'.

I looked for 'toupperFirst' in the above documents, found it in the second but not in the third one.

But, I neither found the keywords 'stereotype' nor 'package' in the second one
(package is in there, but not as a metaclass but only somewhere within XML-Code).

When I look at the JavaDoc provided by Christian W. Damus

http://download.eclipse.org/modeling/mdt/uml2/javadoc/5.0.0/

The UML metaclass 'Class' has a method called ''getName()" as Ed Willink pointed out,
which returns a 'java.lang.String', which then doesn't have a method "toupperFirst()".
So I wonder if all those really are the right places to look for a documentation.

Best regards

Philip.

P.s. It seems to me that XTend is for generating Java Source code, while I want Java, C++, Gradle, CMake code.

[Updated on: Tue, 28 February 2017 17:05]

Report message to a moderator

Re: UML2 MOFM2T API DOC? [message #1755172 is a reply to message #1755169] Tue, 28 February 2017 17:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5929
Registered: July 2009
Senior Member
Hi

toUpperFirst() is an Acceleo library routine. Use Help->Contents->Acceleo.

A power/confusion of many M2x tools is the addition of contextual operations; operations that behave as part of an existing type, but defined outside the type. toUpperFirst is a contextual operation for String.

You misunderstand Xtend; certainly it generates Java, but then Java might be regarded as only capable of generating Java classes; true but that is the tooling dimension. In the programming dimension you are limited only by your imagination.

Regards

Ed Willink
Re: UML2 MOFM2T API DOC? [message #1755195 is a reply to message #1755172] Tue, 28 February 2017 22:59 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 25
Registered: January 2017
Junior Member
Hello once again,
I have looked into XTend,
but I guess, I will stay with Acceleo for the time being.
The WYSIWYG nature seems to make it way more easier atm.

XTend looks like you need to invest considerably more time into learning the basics.
Anyway, I will for sure keep it in mind, and maybe try it out later.

Concerning my question, now that I realized, with your help, that the functions are those of Acceleo/MOFM2T together with those of the Metamodel (in my case UML 2.5),
I guess, I will be able to figure out the rest on my own
using the 3 documents that I posted in my last post in addition with the Acceleo help.

Thank you guys.
Re: UML2 MOFM2T API DOC? [message #1755215 is a reply to message #1755195] Wed, 01 March 2017 08:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5929
Registered: July 2009
Senior Member
Hi

Sorry but I cannot leave your mis-statement unchallenged.

Xtend is just as WYSIWYG as Acceleo wrt the template text. More so since
- it uses guillemets that ease use of awkward characters
- greys the whitespace that is part of the template making it easier to generate prettily formatted output.

See http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/xtend/GenerateVisitorsXtend.xtend for an example.

Acceleo certainly has clearer M2T documentation. Xtend is documented as a Java++ and you need to search hard to find that its support for StringTemplates means that it does M2T too.

Regards

Ed Willink
Re: UML2 MOFM2T API DOC? [message #1755229 is a reply to message #1755215] Wed, 01 March 2017 10:56 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 25
Registered: January 2017
Junior Member
Hello Ed,
thank you for clarifying.
It really looks promising,
but I don't understand, where the <<expression>> syntax comes from,
looks like EBNF to me.

In the XTend documentation

https://www.eclipse.org/xtend/documentation/204_activeannotations.html

it is suddenly used when it comes to "Phase 4: Code Generation" but never introduced.
Clearly in your example this is the part where the Java++ resides, and the rest seems to be literal text, starting within the writer.append; I guess the ''' do initiate some literal text block and somehow the << >> make an exception or something like that, but what are they,
are those the in-memory elements, that the next section "On Expressions and Statements" talks about?
I have never seen that syntax until now, I am more a C++ developer though, and my Java knoweldge is somewhat outdated.

Thank you for your time and trouble.

Best

Philip.

Re: UML2 MOFM2T API DOC? [message #1755230 is a reply to message #1755215] Wed, 01 March 2017 10:59 Go to previous messageGo to next message
Philip Schröder is currently offline Philip SchröderFriend
Messages: 25
Registered: January 2017
Junior Member
Beginning from which Java Version the stuff with ''' and << expression >> is supported, btw.?

[Updated on: Wed, 01 March 2017 11:09]

Report message to a moderator

Re: UML2 MOFM2T API DOC? [message #1755234 is a reply to message #1755230] Wed, 01 March 2017 11:17 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5929
Registered: July 2009
Senior Member
Hi

A template language has a major design challenge, how do you escape from the literal text into control text?

MOFM2T (and consequently Acceleo) made the obvious decision and stuck with the 96 ASCII characters, and so chose [.../] as control text escaping. This is a pain whenever you want to use a [ in your literal text. [.../] lacks readability IMHO.

Xtend, or rather its Xpand predecessor made the radical decision to move on from ASCII 96 and use guillemets as control text escaping. Now it is only a pain if you also want guillemets in your literal text; never happens to me. More commonly the guillemets are corrupted by inconsistent character encoding preferences (set all projects explicitly to UTF-8, Linux newlines). Guillemets are much more readable IMHO, but unfortunately they are a pain to type in arbitrary tools. I often resort to cut and paste. The triple quote is indeed the outer escape from Java text into template text.

Regards

Ed Willink
Previous Topic:news.eclipse.org is shutting down.
Next Topic:PapyrusMultiDiagramEditor corresponding in BPMN2
Goto Forum:
  


Current Time: Thu Jun 21 06:53:01 GMT 2018

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

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

Back to the top