Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing value of an EMF property generated with the STRING rule
Accessing value of an EMF property generated with the STRING rule [message #1361630] Sat, 17 May 2014 08:49 Go to next message
Ole Svensson is currently offline Ole SvenssonFriend
Messages: 1
Registered: May 2014
Junior Member
Hi,

this probably is a stupid question but I cannot get it to work:
Lets say I have an Xtext grammar (with common terminals) like
Model:
   entities+=Entity*;

Entity:
   name=ID (identifier=STRING)? ';';


Now I write the following test:
@Test
def void testParsing() {
   val source = '''
   Name "Hello";
   '''
   source.parse.assertNoErrors
   val model = source.parse
		
   val entity = model.entities.get(0)
   Assert::assertEquals("Name", entity.name)
   Assert::assertEquals("Hello", entity.identifier)
}


This test always fails with an error message that complains about that "Hello" does not equal something like "org.example.example.impl.StringAttributeImpl(at)57173370 (value: Hello)".
Obviously the content of the string is correctly parsed. But how do I access it in Xtend?

Thanks
Ole
Re: Accessing value of an EMF property generated with the STRING rule [message #1362845 is a reply to message #1361630] Sat, 17 May 2014 21:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13488
Registered: July 2009
Senior Member
Hi this makes no sence at all. Areyou sure test and language fit
together? If so please post your code AS zip


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing value of an EMF property generated with the STRING rule [message #1364256 is a reply to message #1362845] Sun, 18 May 2014 11:53 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 248
Registered: June 2013
Senior Member
I read it that you compare a string to a reference.
Perhaps entity.name.toString may help.
Previous Topic:Formatter required for blocks using xtext
Next Topic:Best way to access Properties of a Class
Goto Forum:
  


Current Time: Sat Jul 04 02:45:44 GMT 2020

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

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

Back to the top