Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext/xtend generating an intf for type(code generation with xtend)
Xtext/xtend generating an intf for type [message #843390] Fri, 13 April 2012 02:13 Go to next message
Mike Klein is currently offline Mike KleinFriend
Messages: 4
Registered: April 2012
Junior Member
I am using Indigo w/xtext&xtend 2.2.1, xbase and mwe2 to develop a dsl.

I am struggling with ability to have xtend code generate an additional interface file.

I have tried creating additional xtend files along with a specific mwe2 file but closest I get is code generation of files way other than my model and it gets done at typedef time rather than when in launched eclipse rt when plugin is installed and operational.

I am also curious if there is a way in which the intf/impl and other xtend templates from eclipse plugin can be actually exposed to the user in resulting project so they could be tweaked by advanced users.

I read on this site "Xtend just does classes and nothing else"...does this mean I must use Xpand or Jet for my intf definitions generated from dsl?

Thanks in advance...mike.

[Updated on: Fri, 13 April 2012 03:16]

Report message to a moderator

Re: Xtext/xtend generating an intf for type [message #843481 is a reply to message #843390] Fri, 13 April 2012 04:35 Go to previous messageGo to next message
tiange zhang is currently offline tiange zhangFriend
Messages: 16
Registered: February 2011
Location: Shanghai, China
Junior Member
hi,

if you are using xbase, i guess you should override AbstractModelInferrer to infer your Jvm model
here is a code sample to infer an interface and an implementation for a DSL model element:

   	def dispatch infer(Entity e, IAcceptor<JvmDeclaredType> acceptor, boolean isPrelinkingPhase) {

		if(e.fullyQualifiedName==null) return

		val iface = e.toInterface(e.fullyQualifiedName.toString)[
		]
		
		val impl = e.toClass(e.implFullyQualifiedName.toString)[
			superTypes += iface.createTypeRef()
			createDefaultConstructor(e)
		]
		
		acceptor.accept(iface)
		acceptor.accept(impl)
	}


Re: Xtext/xtend generating an intf for type [message #844484 is a reply to message #843481] Sat, 14 April 2012 03:03 Go to previous messageGo to next message
Mike Klein is currently offline Mike KleinFriend
Messages: 4
Registered: April 2012
Junior Member
This is already being done (per new xtext project)...and modifying project's primary/sole xtend file won't get me an additional intf file produced I believe.

I am looking for more xtext-xtend unified means of producing all artifacts (w/my own codegen) I need to implement "type" definition. The ability to use something like xbase to more easily produce/xform "handler" methods in my model is appealing.

Ecore produces an intf/impl for codegen (I realize there are 'n' ways to do this) but I am looking for additional lang features xtext provides. Am still pretty new to using eclipse for modeling and it took days to get past old versions, read of numerous docs, etc.

My language for describing models is akin to an "expanded ecore". I only expect textual editing of models to be most appropriate. I hope to use gef/gmf later for the application model.

From my current read of things I am expecting to modify my mwe2 workflow file to process an additional pipeline for interface artifact.
Re: Xtext/xtend generating an intf for type [message #844732 is a reply to message #844484] Sat, 14 April 2012 09:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi,

what about posting your mew2 including a comment so that we can understand what you really want to do.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext/xtend generating an intf for type [message #845112 is a reply to message #844732] Sat, 14 April 2012 19:11 Go to previous messageGo to next message
Mike Klein is currently offline Mike KleinFriend
Messages: 4
Registered: April 2012
Junior Member
As I am unsure how to modify my mwe2 to produce/codegen a 2nd file for intf I am unsure of good this would do.

I'm assuming my question is posed correctly...if I'm modeling entities I would think more than 1:1 entity->classImpl mapping w/be required by many folks. I may want to generate additional files for intfs, data adapters, event handling, etc.

I am looking how/where to hookup a 2nd xtend file (if I understand xtend cg correctly) to produce this 2nd intf file when plugin gets installed/run. Right now only an impl gets generated.

So my type I've defined is foo with a property bar::string I would expect impl w/attr and getter/setter (already provided via xtext/xtend) and a 2nd file for the methods only.

[Updated on: Sat, 14 April 2012 19:12]

Report message to a moderator

Re: Xtext/xtend generating an intf for type [message #845132 is a reply to message #845112] Sat, 14 April 2012 19:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13493
Registered: July 2009
Senior Member
Hi,

there are lots of possibilities to do this. dpending if you want to hook in via workflow or builder or whatever

(1) Infer the Stuff using JvmModelInferrer
(2) Subclass JvmModelGenerator and hook into the doGenerate Method (you habe to change the IGenerator Binding)
(3) bind a second/different IGenerator in a second ISetup / Special RuntimeModule and declare a second Generator Component in the Workflow.

(2) and (3) are Independent from using Xbase/Jvm Model Inferring

A Similar Question is handled in
http://www.eclipse.org/forums/index.php/mv/msg/262341/757455/#msg_757455

~<Christian



Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 14 April 2012 19:43]

Report message to a moderator

Re: Xtext/xtend generating an intf for type [message #846057 is a reply to message #845132] Sun, 15 April 2012 18:11 Go to previous message
Mike Klein is currently offline Mike KleinFriend
Messages: 4
Registered: April 2012
Junior Member
Thanks so much for assistance Christian/all.

I will look into all of these points.
Previous Topic:QuickFix error
Next Topic:Polymorphism based filtering JVM types proposal
Goto Forum:
  


Current Time: Sat Jul 11 05:11:35 GMT 2020

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

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

Back to the top