Skip to main content



      Home
Home » Modeling » TMF (Xtext) » ValidateTestHelper.asserError arguments
ValidateTestHelper.asserError arguments [message #1753312] Fri, 03 February 2017 11:58 Go to next message
Eclipse UserFriend
I am fairly new to Xtext, and am trying to write a unit test to assert that an error occurs in deliberately bad syntax. I'm not exactly sure how to pass the second (EClass) argument to the function call. Can anyone post an example and explain how to specify a value for this argument?

Thanks
Re: ValidateTestHelper.asserError arguments [message #1753560 is a reply to message #1753312] Tue, 07 February 2017 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Can you be more specific about the kind of error / validation you want to test
Re: ValidateTestHelper.asserError arguments [message #1753648 is a reply to message #1753312] Wed, 08 February 2017 08:15 Go to previous message
Eclipse UserFriend
In Xtext, an EClass is the type of an element in your AST. The 'E' stands for Ecore, which offers a bit higher-level description of types than Java.
If you use a generated Ecore model (that's the default), the EClasses are defined by the rules in your grammar, e.g.

grammar ...

generate myEcore "http:..." // will result in an EPackage 'myEcore'

Foo: // will result in an EClass 'Foo'
'foo' name=ID; // will result in an EAttribute 'name'

Will result in an EClass 'Foo' with and EAttribute 'name' of type 'EString'.
Once you run the workflow, the code generator will derive an Ecore model with the EClasses from your grammar. Then it will run the EMF code generator to generate Java classes from the Ecore model.

If you need to access an EClass, e.g. to pass it to the ValidationTestHelper, you find it as a singleton in the generated EPackage class. In our case
MyEcorePackage.eINSTANCE.getFoo()
or
MyEcorePackage.Literals.FOO
If you have an element of the AST in your hands, use
myObject.eClass()
Previous Topic:Troubles With Parsing Numbers
Next Topic:Adding definition in global scope provider
Goto Forum:
  


Current Time: Sun Jun 22 21:17:57 EDT 2025

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

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

Back to the top