Skip to main content



      Home
Home » Modeling » TMF (Xtext) » String to Integer Conversion in Xtend2(String to Integer Conversion in Xtend2)
String to Integer Conversion in Xtend2 [message #761403] Tue, 06 December 2011 07:37 Go to next message
Eclipse UserFriend
I am having to perform some arithmetic on my model fields during code generation in Xtend2. I cannot seem to find any examples of how to perform the equivalent of Integer.parseInt(str) in Xtend2. My Xtend function contains the following :

var int result = 0
for (p : s.element.indexed) 
{
   for (e: r.elements)
   {
       if (p.getValue.equals(e.name))
       {		   	  
           result = result + Integer.parseInt(e.size)
        }
   }
}				


where e.size returns a string. However I get a "Couldn't resolve reference to JvmIdentifiableElement 'Integer'" error here.

I'm sure there is a simple solution to this but I have been battling with this all morning....
Re: String to Integer Conversion in Xtend2 [message #761421 is a reply to message #761403] Tue, 06 December 2011 08:08 Go to previous messageGo to next message
Eclipse UserFriend
parseInt is a static method of Integer, accessible through the ::-syntax:
Integer::parseInt(e.size)
Re: String to Integer Conversion in Xtend2 [message #761443 is a reply to message #761421] Tue, 06 December 2011 08:37 Go to previous message
Eclipse UserFriend
Meinte,

Doh! Thank you - that solved it.....
Previous Topic:How to get AST from plugin project
Next Topic:Additional proposal info for content assist
Goto Forum:
  


Current Time: Sun Jul 13 01:29:46 EDT 2025

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

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

Back to the top