I have two products. For example A and B. In A product i need to enable to one validation which is present in AValidator.xtend file and B product is depends on A so when i run B product that check needs to be disable the warning.
AValidator.xtend
:
@Check
def validateElement(Element e)
{
warning('''Element «e.name» missing in files.''', e, package.Literals.NAMED__NAME)
}
The same check should not be work for BProduct.
Is there any override function can do for these?
Many thanks in advance.
There are two ways to solve this:
You can add a system property (probably a
boolean
flag) which enables this feature. In the ini file of A, you enable the option. In B, you omit it.You can split the plugin into a library and then two plugins which you use in the products.
Splitting the plugin works like this:
You need to create a new plugin and copy all the shared code into it. It can also contain the code from the validation which is the same for both products. Give the validation code the name
SharedValidator
In this plugin, you need to rename
DslRuntimeModule
(Dsl
is the name of your grammer, it extendsAbstractDslRuntimeModule
which contains the binding for the validation). Rename it toSharedDslRuntimeModule
.Then you create a plugin for product A. It contains the specific validation. This class needs to extend
SharedValidator
.You also need to create a binding which extends
SharedDslRuntimeModule
and so you can bind the new validator class.That's the rough outline. You will have to copy/change several other files (like the
DslStandaloneSetup
and theplugin.xml
), too, but those changes should become obvious when you fix the compile errors.... Maybe a flag is more simple.