Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext beginner : Issue in xpand workflow generator
Xtext beginner : Issue in xpand workflow generator [message #696911] Fri, 15 July 2011 05:25 Go to next message
Arun  is currently offline Arun Friend
Messages: 26
Registered: July 2011
Junior Member
Hi,

For the below dsl, im trying to generate files but nothing happens. Kindly let me know where the problem is;

DSL
====

Model:
(types+=Type)*;

Type:
Droplet | FormHandler | Properties;

Droplet :
"droplet" name=ID "{"
(prop += Property)*
"}";

FormHandler :
"formhandler" name=ID;

Properties :
name=ID;

Property:
(dataTypes += DataType)* name = ID ;

DataType :
name=ID;

=======================

Template.xpt
==============


«IMPORT org::xtext::example::mydsl1::atgDsl»

«EXTENSION templates::Extensions»


«DEFINE main FOR Model»
«EXPAND droplet FOREACH types.typeSelect(Droplet)»
«ENDDEFINE»

«DEFINE droplet FOR Droplet»
«FILE name+".java"»
public class «name» extends HttpServlet {

}
«ENDFILE»
«ENDDEFINE»

=======================
Workflow
=======
<!-- other part intentionally left -->

// this class will be generated by the xtext generator
register = org.xtext.example.mydsl1.AtgDslStandaloneSetup {}
load = {
slot = "types"
type = "Type"
}
}

component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH types"
outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}


=======================

0 [main] DEBUG org.eclipse.xtext.mwe.Reader - Resource Pathes : [src/model]
0 [main] INFO org.eclipse.xpand2.Generator - No meta models configured, using JavaBeans as default.
156 [main] DEBUG xt.validation.ResourceValidatorImpl - Syntax check OK! Resource: file:/D:/eclipse-SDK-3.6.2-xtext-1.0.2-win32/ws/org.xtext.example.atgdsl.generator/src/model/Example.atgdsl
156 [main] WARN org.eclipse.xtext.mwe.SlotEntry - Could not find any exported element of type 'Type' -> Slot 'types' is empty.
202 [main] INFO .emf.mwe2.runtime.workflow.Workflow - Done.
=============================
Thanks,
Arun

Re: Xtext beginner : Issue in xpand workflow generator [message #696920 is a reply to message #696911] Fri, 15 July 2011 06:17 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

please search the web for "xtext model slot empty" or something similar. This question is asked so many times that it should not be a problem finding an answer.
The brief explanation is: Model does not have a name feature (cannot be referenced by default), so it does not go to the index. But the reader picks up only elements from the index.

Alex
Re: Xtext beginner : Issue in xpand workflow generator [message #696922 is a reply to message #696911] Fri, 15 July 2011 06:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you have actually two problems
(1)
by default only stuff that has a name gets exported an thus can be read by the reader component. But your types have a name so by default this should work.
have you made any changes to the nameprovider? or did you some simplifications to the grammar you posted? it actually is ambigous.
(2)
and if you read types in your workflow why then the template works on a model?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 15 July 2011 06:22]

Report message to a moderator

Re: Xtext beginner : Issue in xpand workflow generator [message #696945 is a reply to message #696922] Fri, 15 July 2011 07:38 Go to previous messageGo to next message
Arun  is currently offline Arun Friend
Messages: 26
Registered: July 2011
Junior Member
Christian,

Thanks for the reply. I did not have any NameProvider nor did any simplifications in model. But still the problem persists. I added and regsitered the NameProvider in runtime module as per some posts, but no luck. Seems i'm doing something wrong.

public class AtgDslNameProvider extends DefaultDeclarativeQualifiedNameProvider {

public String getQualifiedName(Model obj) {
return "Model";
}

public String getQualifiedName(Type obj) {
return "Types";
}

}


//runtime module

public class AtgDslRuntimeModule extends org.xtext.example.mydsl1.AbstractAtgDslRuntimeModule {

@Override
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
// TODO Auto-generated method stub
return AtgDslNameProvider.class;
}
}
Re: Xtext beginner : Issue in xpand workflow generator [message #696948 is a reply to message #696945] Fri, 15 July 2011 07:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you won't need a nameprovider like this - since there is a name for the types
but when i create a new mydsl project with

Model:
(types+=Type)*;

Type:
Droplet | FormHandler | Properties;

Droplet :
"droplet" name=ID "{"
(prop += Property)*
"}";

FormHandler :
"formhandler" name=ID;

Properties :
name=ID;

Property:
(dataTypes += DataType)* name = ID ; 

DataType :
name=ID;


and

«IMPORT org::xtext::example::mydsl::myDsl»

«DEFINE main FOR Type-»
«FILE name+".txt"-»
«this»
«ENDFILE-»
«ENDDEFINE»



and

module workflow.MyDslGenerator

import org.eclipse.emf.mwe.utils.*

var targetDir = "src-gen"
var fileEncoding = "Cp1252"
var modelPath = "src/model"

Workflow {

	component = org.eclipse.xtext.mwe.Reader {
		// lookup all resources on the classpath
		// useJavaClassPath = true

		// or define search scope explicitly
		path = modelPath

		// this class will be generated by the xtext generator 
		register = org.xtext.example.mydsl.MyDslStandaloneSetup {}
		load = {
			slot = "types"
			type = "Type"
		}
	}

	component = org.eclipse.xpand2.Generator {
		expand = "templates::Template::main FOREACH types"
		outlet = {
			path = targetDir
		}
		fileEncoding = fileEncoding
	}
}



and

src/model/Example.mydsl (in yourcase Example.yourextension)
droplet A {

}
droplet B {

}



It works like a charm
~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext beginner : Issue in xpand workflow generator [message #696953 is a reply to message #696948] Fri, 15 July 2011 08:01 Go to previous messageGo to next message
Arun  is currently offline Arun Friend
Messages: 26
Registered: July 2011
Junior Member
Christian,

Thanks for the reply!. That solved that issue. Tell me what i have to do/change in generator workflow file if i want to generate files for formhandler, droplet , Properties ?

«DEFINE main FOR Model»
«EXPAND droplet FOREACH types.typeSelect(Droplet)»
«EXPAND formhandler FOREACH types.typeSelect(FormHandler)»
«EXPAND properties FOREACH types.typeSelect(Properties)»
«ENDDEFINE»

«DEFINE droplet FOR Droplet»
«FILE name+".java"»
public class «name» extends HttpServlet {
//setter and getter xpand
//other servlet related stuffs
}
«ENDFILE»
«ENDDEFINE»

«DEFINE formhandler FOR FormHandler»
«FILE name+".java"»
public class «name» extends GenericFormHandler {

}
«ENDFILE»
«ENDDEFINE»

«DEFINE properties FOR Properties»
«FILE name+".txt"»
«this»
«ENDFILE»
«ENDDEFINE»
Re: Xtext beginner : Issue in xpand workflow generator [message #696961 is a reply to message #696953] Fri, 15 July 2011 08:17 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

either give model a name with the nameprovider, and read models into the slot
or define the main Defintion for
Type and its subtypes, xpand will do a polymorphic dispatch,

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:XBase - How to reduce functionality
Next Topic:Dynamic Template Proposal
Goto Forum:
  


Current Time: Thu Apr 25 09:14:58 GMT 2024

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

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

Back to the top