Validator inheritance doesn't seem to work - fails to add inherited EPackage to getEPackages [message #1710561] |
Wed, 07 October 2015 14:26 |
Rene Schneider Messages: 2 Registered: October 2015 |
Junior Member |
|
|
I have two DSLs: DSL A and B. DSL B "inherits" DSL A by a "grammar BBB with AAA" line in its grammar definition.
DSL A supplies custom validation code in a validator class. The Xtend validator class of DSL B that is generated automatically seems to inherit from DSL A, which is nice that's exactly what I intended. But however, the validation code from validator class A was never called.
After some debugging, I found the problem: the method "getEPackages", which apparently should return all the EPackages that a validator is responsible for, was overwritten in validator B and returns only the EPackage of DSL B, but NOT the one from DSL A (even though it inherited all the actual validation methods). I fixed this by manually creating another override in which I return both EPackages, and suddenly, my validator executed validation code for both DSLs .
I'm a bit unsure now as to whether I am simply missing some kind of option for the generation process, or whether this is a bug in the generation process. I traced the code that generates the package list in question to the ValidatorFragment, and found something that might be such a bug:
def getGeneratedPackagesToValidate() {
grammar.metamodelDeclarations.filter(GeneratedMetamodel).map[EPackage]
}
def protected getRegistryPackagesToValidate() {
val packages = allEPackagesToValidate(grammar)
packages.removeAll(allMetamodelDeclarations(grammar).filter(GeneratedMetamodel).map[EPackage].toList
)
packages
}
Shouldn't the two segments "grammar.metamodelDeclarations" and "allMetamodelDeclarations(grammar)" be practically identical? The first method finds all "generated" packages, and the second one finds "everything else", which is "everything" minus the "generated" ones.
I'm not very experienced in debugging Xtend code, so I basically left it as it is after finding a solution to my immediate problem. But it still looks strange to me, and I would expect both DSLs to be included in the generated list.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03565 seconds