|
|
|
|
Re: Xtext beginner : Issue in xpand workflow generator [message #696948 is a reply to message #696945] |
Fri, 15 July 2011 07:47 |
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03119 seconds