Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext] URI vs. uml::String
[Xtext] URI vs. uml::String [message #30320] Wed, 18 February 2009 18:50 Go to next message
Eclipse UserFriend
Hello,

I want to use the URI token to import other resource files.
The example for the online documentation works fine, except that I could
only make it work with absolute "file:/..." paths.

Anyway, I'm using UML as my metamodel, and the "string" properties from
UML.ecore are of type [uml::]String (mapped to java.lang.String), as
opposed to the example which generates an .ecore file having properties
of type EString (mapped to java.lang.String).

Because of this, I cannot use "name=URI" in my grammar. The .ext and
..chk files have errors.

What should I do?

Thank you,
Lucian
Re: [Xtext] URI vs. uml::String [message #30359 is a reply to message #30320] Wed, 18 February 2009 19:08 Go to previous messageGo to next message
Eclipse UserFriend
I found something here:
http://www.openarchitectureware.org/forum/viewtopic.php?foru m=29&showtopic=9521&highlight=uri

I haven't tested the recommendations, but it seems to solve the same
problem,

Lucian

Lazar Codrut-Lucian wrote:
> Hello,
>
> I want to use the URI token to import other resource files.
> The example for the online documentation works fine, except that I could
> only make it work with absolute "file:/..." paths.
>
> Anyway, I'm using UML as my metamodel, and the "string" properties from
> UML.ecore are of type [uml::]String (mapped to java.lang.String), as
> opposed to the example which generates an .ecore file having properties
> of type EString (mapped to java.lang.String).
>
> Because of this, I cannot use "name=URI" in my grammar. The .ext and
> .chk files have errors.
>
> What should I do?
>
> Thank you,
> Lucian
Re: [Xtext] URI vs. uml::String [message #30394 is a reply to message #30359] Wed, 18 February 2009 22:28 Go to previous messageGo to next message
Eclipse UserFriend
I made the example work when using UML as metamodel.
- load() method was changed
- the conversion from uml::String to String is done using reflection

This is my test grammar:
-----
ModelRule[uml::Model]:
(packagedElement+=PackageRule);

PackageRule[uml::Package]:
"package" name=ID "{"
("import" ownedComment+=CommentImportRule)*
"}";

CommentImportRule[uml::Comment]:
body=STRING;
-----

These are the methods I added to Extensions.ext:
-----
List[emf::EObject] allElements(emf::EObject element):
element.allLocalElements()
.union(element.allLocalElements().typeSelect(Comment)
.collect(e | load(createURI(e),element).flatten()
.collect(e | ((emf::EObject)e).allLocalElements())
)
).
flatten().toSet();

List[emf::EObject] allVisibleElements(emf::EObject x):
x.allElements();

String createURI(Comment comment) :
"platform:/resource/mydslproject/src/" + commentBody(comment);

String commentBody(uml::Comment comment) :
let p = comment.metaType.getProperty("body") :
p==null ? null : p.get(comment);
-----

Lucian

Lazar Codrut-Lucian wrote:
> I found something here:
> http://www.openarchitectureware.org/forum/viewtopic.php?foru m=29&showtopic=9521&highlight=uri
>
> I haven't tested the recommendations, but it seems to solve the same
> problem,
>
> Lucian
>
> Lazar Codrut-Lucian wrote:
>> Hello,
>>
>> I want to use the URI token to import other resource files.
>> The example for the online documentation works fine, except that I could
>> only make it work with absolute "file:/..." paths.
>>
>> Anyway, I'm using UML as my metamodel, and the "string" properties from
>> UML.ecore are of type [uml::]String (mapped to java.lang.String), as
>> opposed to the example which generates an .ecore file having properties
>> of type EString (mapped to java.lang.String).
>>
>> Because of this, I cannot use "name=URI" in my grammar. The .ext and
>> .chk files have errors.
>>
>> What should I do?
>>
>> Thank you,
>> Lucian
Re: [Xtext] URI vs. uml::String [message #30429 is a reply to message #30394] Thu, 19 February 2009 03:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi Lazar,

as you're referring to "oAW Xtext", I recommend to post your questions
in the forum at www.openarchitectureware.org.
This newsgroup is for "TMF Xtext" (which btw. would simply allow to
configure type conversion per rule. Also platform: or even classpath:
URIs simply work.) ;-)

Do you use the UML2 metamodel implementation with Xtend?

Cheers,
Sven


Lazar Codrut-Lucian schrieb:
> I made the example work when using UML as metamodel.
> - load() method was changed
> - the conversion from uml::String to String is done using reflection
>
> This is my test grammar:
> -----
> ModelRule[uml::Model]:
> (packagedElement+=PackageRule);
>
> PackageRule[uml::Package]:
> "package" name=ID "{"
> ("import" ownedComment+=CommentImportRule)*
> "}";
>
> CommentImportRule[uml::Comment]:
> body=STRING;
> -----
>
> These are the methods I added to Extensions.ext:
> -----
> List[emf::EObject] allElements(emf::EObject element):
> element.allLocalElements()
> .union(element.allLocalElements().typeSelect(Comment)
> .collect(e | load(createURI(e),element).flatten()
> .collect(e | ((emf::EObject)e).allLocalElements())
> )
> ).
> flatten().toSet();
>
> List[emf::EObject] allVisibleElements(emf::EObject x):
> x.allElements();
>
> String createURI(Comment comment) :
> "platform:/resource/mydslproject/src/" + commentBody(comment);
>
> String commentBody(uml::Comment comment) :
> let p = comment.metaType.getProperty("body") :
> p==null ? null : p.get(comment);
> -----
>
> Lucian
>
> Lazar Codrut-Lucian wrote:
>> I found something here:
>> http://www.openarchitectureware.org/forum/viewtopic.php?foru m=29&showtopic=9521&highlight=uri
>>
>> I haven't tested the recommendations, but it seems to solve the same
>> problem,
>>
>> Lucian
>>
>> Lazar Codrut-Lucian wrote:
>>> Hello,
>>>
>>> I want to use the URI token to import other resource files.
>>> The example for the online documentation works fine, except that I could
>>> only make it work with absolute "file:/..." paths.
>>>
>>> Anyway, I'm using UML as my metamodel, and the "string" properties from
>>> UML.ecore are of type [uml::]String (mapped to java.lang.String), as
>>> opposed to the example which generates an .ecore file having properties
>>> of type EString (mapped to java.lang.String).
>>>
>>> Because of this, I cannot use "name=URI" in my grammar. The .ext and
>>> .chk files have errors.
>>>
>>> What should I do?
>>>
>>> Thank you,
>>> Lucian
Re: [Xtext] URI vs. uml::String [message #30531 is a reply to message #30429] Fri, 20 February 2009 09:35 Go to previous messageGo to next message
Eclipse UserFriend
Apparently I am using oAW Xtext :-)
Sorry for "spamming" here. I though TMF Xtext still has some connections
with openArchitecture.com.

I tried today to install TMF Xtext, but I couldn't. It's quite
difficult. I'll try again and when I will succeed I'll get back here.

Lucian

Sven Efftinge wrote:
> Hi Lazar,
>
> as you're referring to "oAW Xtext", I recommend to post your questions
> in the forum at www.openarchitectureware.org.
> This newsgroup is for "TMF Xtext" (which btw. would simply allow to
> configure type conversion per rule. Also platform: or even classpath:
> URIs simply work.) ;-)
>
> Do you use the UML2 metamodel implementation with Xtend?
>
> Cheers,
> Sven
>
>
> Lazar Codrut-Lucian schrieb:
>> I made the example work when using UML as metamodel.
>> - load() method was changed
>> - the conversion from uml::String to String is done using reflection
>>
>> This is my test grammar:
>> -----
>> ModelRule[uml::Model]:
>> (packagedElement+=PackageRule);
>>
>> PackageRule[uml::Package]:
>> "package" name=ID "{"
>> ("import" ownedComment+=CommentImportRule)*
>> "}";
>>
>> CommentImportRule[uml::Comment]:
>> body=STRING;
>> -----
>>
>> These are the methods I added to Extensions.ext:
>> -----
>> List[emf::EObject] allElements(emf::EObject element):
>> element.allLocalElements()
>> .union(element.allLocalElements().typeSelect(Comment)
>> .collect(e | load(createURI(e),element).flatten()
>> .collect(e | ((emf::EObject)e).allLocalElements())
>> )
>> ).
>> flatten().toSet();
>>
>> List[emf::EObject] allVisibleElements(emf::EObject x):
>> x.allElements();
>>
>> String createURI(Comment comment) :
>> "platform:/resource/mydslproject/src/" + commentBody(comment);
>>
>> String commentBody(uml::Comment comment) :
>> let p = comment.metaType.getProperty("body") :
>> p==null ? null : p.get(comment);
>> -----
>>
>> Lucian
>>
>> Lazar Codrut-Lucian wrote:
>>> I found something here:
>>> http://www.openarchitectureware.org/forum/viewtopic.php?foru m=29&showtopic=9521&highlight=uri
>>>
>>>
>>> I haven't tested the recommendations, but it seems to solve the same
>>> problem,
>>>
>>> Lucian
>>>
>>> Lazar Codrut-Lucian wrote:
>>>> Hello,
>>>>
>>>> I want to use the URI token to import other resource files.
>>>> The example for the online documentation works fine, except that I
>>>> could
>>>> only make it work with absolute "file:/..." paths.
>>>>
>>>> Anyway, I'm using UML as my metamodel, and the "string" properties from
>>>> UML.ecore are of type [uml::]String (mapped to java.lang.String), as
>>>> opposed to the example which generates an .ecore file having properties
>>>> of type EString (mapped to java.lang.String).
>>>>
>>>> Because of this, I cannot use "name=URI" in my grammar. The .ext and
>>>> .chk files have errors.
>>>>
>>>> What should I do?
>>>>
>>>> Thank you,
>>>> Lucian
Re: [Xtext] URI vs. uml::String [message #30566 is a reply to message #30531] Fri, 20 February 2009 09:38 Go to previous messageGo to next message
Eclipse UserFriend
The only thing I wrote in Xtend is that fragment I posted here (in
Extensions.ext).
My grammar is reusing UML metamodel.

Lucian

Lazar Codrut-Lucian wrote:
> Apparently I am using oAW Xtext :-)
> Sorry for "spamming" here. I though TMF Xtext still has some connections
> with openArchitecture.com.
>
> I tried today to install TMF Xtext, but I couldn't. It's quite
> difficult. I'll try again and when I will succeed I'll get back here.
>
> Lucian
>
> Sven Efftinge wrote:
>> Hi Lazar,
>>
>> as you're referring to "oAW Xtext", I recommend to post your questions
>> in the forum at www.openarchitectureware.org.
>> This newsgroup is for "TMF Xtext" (which btw. would simply allow to
>> configure type conversion per rule. Also platform: or even classpath:
>> URIs simply work.) ;-)
>>
>> Do you use the UML2 metamodel implementation with Xtend?
>>
>> Cheers,
>> Sven
>>
>>
>> Lazar Codrut-Lucian schrieb:
>>> I made the example work when using UML as metamodel.
>>> - load() method was changed
>>> - the conversion from uml::String to String is done using reflection
>>>
>>> This is my test grammar:
>>> -----
>>> ModelRule[uml::Model]:
>>> (packagedElement+=PackageRule);
>>>
>>> PackageRule[uml::Package]:
>>> "package" name=ID "{"
>>> ("import" ownedComment+=CommentImportRule)*
>>> "}";
>>>
>>> CommentImportRule[uml::Comment]:
>>> body=STRING;
>>> -----
>>>
>>> These are the methods I added to Extensions.ext:
>>> -----
>>> List[emf::EObject] allElements(emf::EObject element):
>>> element.allLocalElements()
>>> .union(element.allLocalElements().typeSelect(Comment)
>>> .collect(e | load(createURI(e),element).flatten()
>>> .collect(e | ((emf::EObject)e).allLocalElements())
>>> )
>>> ).
>>> flatten().toSet();
>>>
>>> List[emf::EObject] allVisibleElements(emf::EObject x):
>>> x.allElements();
>>>
>>> String createURI(Comment comment) :
>>> "platform:/resource/mydslproject/src/" + commentBody(comment);
>>>
>>> String commentBody(uml::Comment comment) :
>>> let p = comment.metaType.getProperty("body") :
>>> p==null ? null : p.get(comment);
>>> -----
>>>
>>> Lucian
>>>
>>> Lazar Codrut-Lucian wrote:
>>>> I found something here:
>>>> http://www.openarchitectureware.org/forum/viewtopic.php?foru m=29&showtopic=9521&highlight=uri
>>>>
>>>>
>>>> I haven't tested the recommendations, but it seems to solve the same
>>>> problem,
>>>>
>>>> Lucian
>>>>
>>>> Lazar Codrut-Lucian wrote:
>>>>> Hello,
>>>>>
>>>>> I want to use the URI token to import other resource files.
>>>>> The example for the online documentation works fine, except that I
>>>>> could
>>>>> only make it work with absolute "file:/..." paths.
>>>>>
>>>>> Anyway, I'm using UML as my metamodel, and the "string" properties from
>>>>> UML.ecore are of type [uml::]String (mapped to java.lang.String), as
>>>>> opposed to the example which generates an .ecore file having properties
>>>>> of type EString (mapped to java.lang.String).
>>>>>
>>>>> Because of this, I cannot use "name=URI" in my grammar. The .ext and
>>>>> .chk files have errors.
>>>>>
>>>>> What should I do?
>>>>>
>>>>> Thank you,
>>>>> Lucian
Re: [Xtext] URI vs. uml::String [message #30636 is a reply to message #30531] Fri, 20 February 2009 15:57 Go to previous message
Eclipse UserFriend
Lazar Codrut-Lucian schrieb:
> Apparently I am using oAW Xtext :-)
> Sorry for "spamming" here. I though TMF Xtext still has some connections
> with openArchitecture.com.

Sure there are connections as we are too the authors of oAW Xtext :-)
We just want to have the two frameworks discussed in two different
forums/newsgroup, because although they are slightly different they are
not diffferent enough to not confuse people if both are discussed in the
same forum/newsgroup ;-).
You'll also find many oAW Xtext users in the other forum, so chances for
helping answers are higher there.

>
> I tried today to install TMF Xtext, but I couldn't. It's quite
> difficult. I'll try again and when I will succeed I'll get back here.

Yes, TMF Xtext is not production ready yet.
Everything is moving and we still change lots of things day by day. We
even managed to break the build these days :-(


I really value that we already have some users trying TMF Xtext, but
you'll have to dig yourself through the things and be prepared for
regular changes. On the other hand you'll get a nice framework and some
nice support in this newsgroup :-)


Cheers,
Sven
Previous Topic:[Xtext] Model elements extra initialization
Next Topic:[TCS] No parser.jar
Goto Forum:
  


Current Time: Sun May 25 06:01:22 EDT 2025

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

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

Back to the top