Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Check if a feature matches one among more terminals
Check if a feature matches one among more terminals [message #988498] Fri, 30 November 2012 04:28 Go to next message
Eclipse UserFriend
Hi Smile

in a declarative validator for a type of my own language, how can I check if a feature of this grammar element matches one among more terminals?

Suppose that the rule defining this type is:

ANonTerminal:
  myFeature=TERMINAL1 anotherFeature=AnotherNonTerminal |
  myFeature=TERMINAL2 anotherFeature=AnotherNonTerminal |
  myFeature=TERMINAL3 anotherFeature=AnotherNonTerminal
;


and I want to write something like this:

public class AbstractMyLanguageJavaValidator extends AbstractDomainmodelJavaValidator {

  ...

  @Check
  public void myOwnCheck(ANonTerminal elem) {
    if (elem.getMyFeature == TERMINAL2) {
      warning(...);
    }
  }

}


Could you help me please? Thanks in advance! Smile
Re: Check if a feature matches one among more terminals [message #988645 is a reply to message #988498] Fri, 30 November 2012 15:32 Go to previous message
Eclipse UserFriend
Hi Marco,

please try to use NodeModelUtils.findNodeForFeature, ask the node for
the grammar element and check that against the grammar access of your
language.

Best regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 30.11.12 14:35, schrieb Marco Naddeo:
> Hi :)
>
> in a declarative validator for a type of my own language, how can I
> check if a feature of this grammar element matches one among more
> terminals?
>
> Suppose that the rule defining this type is:
>
> ANonTerminal:
> myFeature=TERMINAL1 anotherFeature=AnotherNonTerminal |
> myFeature=TERMINAL2 anotherFeature=AnotherNonTerminal |
> myFeature=TERMINAL3 anotherFeature=AnotherNonTerminal
> ;
>
> and I want to write something like this:
>
>
> public class AbstractMyLanguageJavaValidator extends
> AbstractDomainmodelJavaValidator {
>
> ...
>
> @Check
> public void myOwnCheck(ANonTerminal elem) {
> if (elem.getMyFeature == TERMINAL2) {
> warning(...);
> }
> }
>
> }
>
> Could you help me please? Thanks in advance! :)
Previous Topic:Combine tests and validation
Next Topic:Need hover for keyword or block of elements
Goto Forum:
  


Current Time: Sun Jul 27 14:41:55 EDT 2025

Powered by FUDForum. Page generated in 0.03250 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top