Throw error in generator [message #1809744] |
Mon, 22 July 2019 11:01 |
Maharajan Nagarajan Messages: 2 Registered: July 2019 |
Junior Member |
|
|
Greetings everyone !
I am trying to generate code, i have to do lot of validation(just throw error) and it should be performed only just prior to generation.
I have created a class with all validation logics inside DeepValidation class
class DeepValidation extends AbstractMemDesignValidator
{
def init(IResourceDescriptions resDescription)
{
//Initializations for validation
}
@Check(CheckType.NORMAL)
def validation()
{
// Validation logics
}
}
I am invoking the above validation in my code generation logic, the function just halts at
...
error('Error', obj, Package.Literals.FEATURE)
...
neither it proceed further nor throws error. The code just halts here !
Background.
1) I have defined proper Grammer
2) I have defined validations, which was working fine.
3) I have defined generator and I was able to generate code properly as expected
Points to consider:
1) I have multiple dsl files (a.dsl, b.dsl, ...)
2) I have multiple grammers in my project ( a.dsl1, b.dsl1, .... a.dsl2, b.dsl2, ....)
My Questions:
1) What is going wrong ? Can't I throw error from generator package ? What is your suggestion ?
Ans: ....
2) I am Injecting IResourceDescriptions in my Generator class
class Generator extends AbstractGenerator implements IGenerator2
{
@Inject
IResourceDescriptions resourceDescription
override doGenerate(Resource input, IFileSystemAccess2 fsa, IGeneratorContext context)
{
var CSourceGenerator sourceCodeGenerator = new CSourceGenerator()
sourceCodeGenerator.SourceCodeGenerator(resourceDescription, fsa)
}
}
resourceDescription is loaded(with all data from all dsl files) only after a change in resource. What should I do to load data into resourceDescription immediately after the tool starts ?
Ans: ...
** I am basically from embedded domain, novice in xtext & xtend **
Mit freundlichen Grüßen / Regards
Maha
|
|
|
Re: Throw error in generator [message #1809749 is a reply to message #1809744] |
Mon, 22 July 2019 13:30 |
|
hi, i cannot really follow you.
the normal validator is called before the generator already
you can mark the check method with @Check(CheckType.NORMAL) so that they are executed on save/build only
the resourceDescription point i dont understand. which usecase does this target (standalone, eclipse,..., that is the "tool")
p.s. the general pattern is
@Inject
ResourceDescriptionsProvider resourceDescriptionsProvider
override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
System.err.println(resourceDescriptionsProvider.getResourceDescriptions(resource))
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Mon, 22 July 2019 13:49] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02583 seconds