| @Check Validator with 2 or more parameters [message #1732734] |
Thu, 19 May 2016 07:22  |
Eclipse User |
|
|
|
Hi everyone,
I'm a totally newbie at XText and grammar definition.
I have a very simple grammar where I can define 'Element', 'Diagram', and 'Model'.
It need to be generic as a metamodel, but I want to do some validations (warnings and errors) to make more friendly. For example, I could define that a "Class belongs to SequenceDiagram from BPMN". It's totally wrong, but my grammar allows this crazyness.
I already use @Check to validate if an Element name begins with capital or not, but I failed to create a @Check that receive two or more parameters. It only works with one.
What I want is a @Check method that receive Element and Diagram (for example) so I could that if Element is a Class so Diagram need to be ClassDiagram. If not, then a error message is displayed. How can I use @Check with 2 or more parameters?
Best regards
|
|
|
|
|
|
| Re: @Check Validator with 2 or more parameters [message #1732749 is a reply to message #1732744] |
Thu, 19 May 2016 16:47  |
Eclipse User |
|
|
|
Thanks!!!!
I don't know if I wrote the best code but works!!!
@Check
def checkIfDiagramContainsRightElements(Diagram diagram) {
if (diagram.kind.equals(DiagramKind.CLASSDIAGRAM)) {
if (diagram.eContainer().eGet(ModelPackage.Literals.ELEMENT__KIND) == ElementKind.CLASS) {
println("YES!!!")
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03897 seconds