Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » XPand: String concatination
XPand: String concatination [message #61586] Sun, 24 May 2009 22:26 Go to next message
No real name is currently offline No real nameFriend
Messages: 61
Registered: July 2009
Member
In the XPand-Editor, I get an error when trying to concatenate a string
with a model-value. Here is my template:

«IMPORT otml»
«IMPORT uml»

«DEFINE main FOR Model»
«EXPAND showpackages FOREACH this.nestedPackage»
«ENDDEFINE»

«DEFINE showpackages FOR Package»
«FILE "\\" + this.name + "foo"» <---- ERROR HERE
test
«ENDFILE»
«ENDDEFINE»

I marked the line, where the error occurs. The problem is:
"Couldn't find operation '+(uml::String)' for type 'String'".

I tried explizit casting, but it did not work:
"«FILE "\\" + (String)this.name + "foo"»".
But it would work like that:
"«FILE "\\" + (String)this.name»".
While this does not work:
"«FILE "\\" + this.name»".

And another (for me) interesting fact: If I use the template by using
Xpand programmaticly, it works just fine. So why does the editor (and
problem-view) have problems?



Thank you for any help
Re: XPand: String concatination [message #61611 is a reply to message #61586] Mon, 25 May 2009 10:40 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Hmm, looks like a bug in the tooling around the UML typesystem. I filed
a bug for that
https://bugs.eclipse.org/bugs/show_bug.cgi?id=277666

I hope we can fix it before the Galileo release.

Regards
Jan

Usul schrieb:
> In the XPand-Editor, I get an error when trying to concatenate a string
> with a model-value. Here is my template:
>
> «IMPORT otml»
> «IMPORT uml»
>
> «DEFINE main FOR Model»
> «EXPAND showpackages FOREACH this.nestedPackage» «ENDDEFINE»
>
> «DEFINE showpackages FOR Package»
> «FILE "\\" + this.name + "foo"» <---- ERROR HERE
> test
> «ENDFILE»
> «ENDDEFINE»
>
> I marked the line, where the error occurs. The problem is: "Couldn't
> find operation '+(uml::String)' for type 'String'".
> I tried explizit casting, but it did not work: "«FILE "\\" +
> (String)this.name + "foo"»". But it would work like that: "«FILE "\\"
> + (String)this.name»". While this does not work: "«FILE "\\" +
> this.name»".
>
> And another (for me) interesting fact: If I use the template by using
> Xpand programmaticly, it works just fine. So why does the editor (and
> problem-view) have problems?
>
>
>
> Thank you for any help
>


---
Get professional support from the Xtext committers at www.typefox.io
Re: XPand: String concatination [message #61659 is a reply to message #61611] Mon, 25 May 2009 19:22 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Change the order of the UML and EMF metamodel contributors in the
project settings. UML must come first when using both, otherwise EMF
wins and maps the String primitive type to an EClassType, but the UML
typesystem recognizes the primitives and maps them to the builtin
typesystem.

~Karsten

~Karsten

On 25.05.09 12:40, Jan Kšoehnlein wrote:
> Hmm, looks like a bug in the tooling around the UML typesystem. I filed
> a bug for that
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=277666
>
> I hope we can fix it before the Galileo release.
>
> Regards
> Jan
>
> Usul schrieb:
>> In the XPand-Editor, I get an error when trying to concatenate a
>> string with a model-value. Here is my template:
>>
>> «IMPORT otml»
>> «IMPORT uml»
>>
>> «DEFINE main FOR Model»
>> «EXPAND showpackages FOREACH this.nestedPackage» «ENDDEFINE»
>>
>> «DEFINE showpackages FOR Package»
>> «FILE "\\" + this.name + "foo"» <---- ERROR HERE
>> test
>> «ENDFILE»
>> «ENDDEFINE»
>>
>> I marked the line, where the error occurs. The problem is: "Couldn't
>> find operation '+(uml::String)' for type 'String'". I tried explizit
>> casting, but it did not work: "«FILE "\\" + (String)this.name +
>> "foo"»". But it would work like that: "«FILE "\\" +
>> (String)this.name»". While this does not work: "«FILE "\\" + this.name»".
>>
>> And another (for me) interesting fact: If I use the template by using
>> Xpand programmaticly, it works just fine. So why does the editor (and
>> problem-view) have problems?
>>
>>
>>
>> Thank you for any help
>>


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: XPand: String concatination [message #61705 is a reply to message #61659] Mon, 25 May 2009 22:59 Go to previous message
No real name is currently offline No real nameFriend
Messages: 61
Registered: July 2009
Member
Hi Karsten,


> Change the order of the UML and EMF metamodel contributors in the
> project settings. UML must come first when using both, otherwise EMF
> wins and maps the String primitive type to an EClassType, but the UML
> typesystem recognizes the primitives and maps them to the builtin
> typesystem.

> ~Karsten

In "Project"->"Properties"->"Xtend/Xpand" I checked both "UML2 profiles"
and "EMF Metamodels" and put "UML2 profiles" up to first place. The
example I posted works then. But this does not work:

«IMPORT uml» <---- ERROR 1
«IMPORT otml»

«DEFINE createFile(String packageName) FOR TeamClass»
«FILE packageName + "\\" + this.name + ".java"» <---- ERROR 2
Team: «this.name»
«ENDFILE»
«ENDDEFINE»

«DEFINE createFile(String packageName) FOR PackageableElement»
«FILE packageName + "\\" + this.name + ".txt"» *
Else: «this.name»
«ENDFILE»
«ENDDEFINE»


Error 1: "Couldn't find operation '+(uml::String)' for type 'String'"
Error 2: "String expected!"


That is pretty strange, because only one (seemingly random) line is
affected. Without your solution, the line marked with "*" also had Error
1 (that error diesappeared).


> On 25.05.09 12:40, Jan Kšoehnlein wrote:
>> Hmm, looks like a bug in the tooling around the UML typesystem. I filed
>> a bug for that
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=277666
>>
>> I hope we can fix it before the Galileo release.
>>
>> Regards
>> Jan
>>
>> Usul schrieb:
>>> In the XPand-Editor, I get an error when trying to concatenate a
>>> string with a model-value. Here is my template:
>>>
>>> «IMPORT otml»
>>> «IMPORT uml»
>>>
>>> «DEFINE main FOR Model»
>>> «EXPAND showpackages FOREACH this.nestedPackage» «ENDDEFINE»
>>>
>>> «DEFINE showpackages FOR Package»
>>> «FILE "\" + this.name + "foo"» <---- ERROR HERE
>>> test
>>> «ENDFILE»
>>> «ENDDEFINE»
>>>
>>> I marked the line, where the error occurs. The problem is: "Couldn't
>>> find operation '+(uml::String)' for type 'String'". I tried explizit
>>> casting, but it did not work: "«FILE "\" + (String)this.name +
>>> "foo"»". But it would work like that: "«FILE "\" +
>>> (String)this.name»". While this does not work: "«FILE "\" + this.name»".
>>>
>>> And another (for me) interesting fact: If I use the template by using
>>> Xpand programmaticly, it works just fine. So why does the editor (and
>>> problem-view) have problems?
>>>
>>>
>>>
>>> Thank you for any help
>>>
Previous Topic:Polymorphism in XPand
Next Topic:[Announce] M2T XPAND 0.7.0RC2 is available
Goto Forum:
  


Current Time: Sat Nov 09 05:40:57 GMT 2024

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

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

Back to the top