Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » EObject 'nature' of domain classes no longer available?(After changing the metamodel my generated classes are no longer of type EObject?)
EObject 'nature' of domain classes no longer available? [message #1760139] Sun, 23 April 2017 16:38 Go to next message
Susie Agerholm is currently offline Susie AgerholmFriend
Messages: 54
Registered: April 2017
Member
Hi, I am new to xText - so please bear with me Smile I am trying to implement a Formatter2 in an xText project generated from an EMF...

Previously I was able to use classes generated from my domain (e.g robot class below) like an EObject - like so...

def dispatch void format(Robot robot, extension IFormattableDocument document) {
		// TODO: format HiddenRegions around keywords, attributes, cross references, etc.
		robot.regionFor.features(URDFPackage.Literals.NAMED_ELEMENT__NAME).head.append[newLine]


But this is no longer the case. Now I get a compiler error saying that my domain class cannot be converted to EObject...

I have made som small changes to my metamodel - e.g NamedElement class, that all my objects inherit from, has been changed from abstract class to interface...could this be cause?

Also - I would like to create some convenience methods for formatting my content like so - but I having problems finding the correct syntax, so I can use the extension methods on document:

def <T extends EObject> indentKeyword(T construct, String myKeyword, extension IFormattableDocument document) {
		construct.regionFor.keyword(myKeyword).prepend[space = Strings.repeat(" ", 6)] 	
	}


Thank you very much in advance Smile
Re: EObject 'nature' of domain classes no longer available? [message #1760206 is a reply to message #1760139] Mon, 24 April 2017 14:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

regarding (1) that should not happen.
can you share a small ecore/xcore file reproducing this?

regarding (2) i dont see where the problem is

	def dispatch void format(Model model, extension IFormattableDocument document) {
	    
		for (Greeting greetings : model.getGreetings()) {
			greetings.format;
			greetings.indentKeyword("Hello", document)
		}
	}
	def <T extends EObject> indentKeyword(T construct, String myKeyword, extension IFormattableDocument document) {
        construct.regionFor.keyword(myKeyword).prepend[space = Strings.repeat(" ", 6)]  
    }


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: EObject 'nature' of domain classes no longer available? [message #1760217 is a reply to message #1760206] Mon, 24 April 2017 16:18 Go to previous message
Susie Agerholm is currently offline Susie AgerholmFriend
Messages: 54
Registered: April 2017
Member
HI Christian, thank you very much for the quick reply Smile With regards to EObject I got the idea to try and delete my Formatting2 package and regenerate from MWE2 again and that resolved it fortunately.
The indentKeyword is also working now so i guess there was some bug in the package. Sorry for the inconvenience - and thank you again! Smile
Previous Topic:XText category not available on update site
Next Topic:Syntax Highlight of disconnected rules
Goto Forum:
  


Current Time: Thu Apr 25 05:10:14 GMT 2024

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

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

Back to the top