| XPand: String concatination [message #61586] | 
Sun, 24 May 2009 18:26   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 
>>>
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.25787 seconds