Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » XPand: String concatination
XPand: String concatination [message #61586] Sun, 24 May 2009 18:26 Go to next message
Eclipse UserFriend
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 06:40 Go to previous messageGo to next message
Eclipse UserFriend
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
>
Re: XPand: String concatination [message #61659 is a reply to message #61611] Mon, 25 May 2009 15:22 Go to previous messageGo to next message
Eclipse UserFriend
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
>>
Re: XPand: String concatination [message #61705 is a reply to message #61659] Mon, 25 May 2009 18:59 Go to previous message
Eclipse UserFriend
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: Wed May 07 19:51:43 EDT 2025

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

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

Back to the top