Standalone code generation for list of files [message #1778035] |
Fri, 08 December 2017 12:28 |
Mukesh Sharma Messages: 1 Registered: December 2017 |
Junior Member |
|
|
Scenario: I have a DSL in such a way that components can be distributed over multiple files. e.g. let say , I have foo.mydsl, bar.mydsl.
Now, I want to generate code for model composite of above mentioned files. I checked through the stub generated by xtext for standalone code generation, but it takes one resource at a time.
e.g.
def protected runGenerator(String string) {
// Load the resource
val set = resourceSetProvider.get
val resource = set.getResource(URI.createFileURI(string), true)
// Validate the resource
val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl)
if (!issues.empty) {
issues.forEach[System.err.println(it)]
return
}
// Configure and start the generator
fileAccess.outputPath = 'src-gen'
val context = new GeneratorContext => [
cancelIndicator = CancelIndicator.NullImpl
]
generator.generate(resource, fileAccess, context)
System.out.println('Code generation finished.')
}
Now, this code fails for me, because foo.mydsl has some component dependency in bar.mydsl. I want to read all dsl files in a given folder and generate the code ?
Also, if I pass folder path to the above mentioned generator, then it throws "Cannot create a resource for 'file:/tmp/dsl/'; a registered resource factory is needed" ?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03220 seconds