Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 12:37 Go to next message
Stuart Hutchesson is currently offline Stuart HutchessonFriend
Messages: 9
Registered: September 2011
Junior Member
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 13:08 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
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 13:37 Go to previous message
Stuart Hutchesson is currently offline Stuart HutchessonFriend
Messages: 9
Registered: September 2011
Junior Member
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: Sat Mar 06 15:13:02 GMT 2021

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

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

Back to the top