Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Nested annotations using XbaseWithAnnotations(How can I use nested annotations with XbaseWithAnnotations?)
icon5.gif  Nested annotations using XbaseWithAnnotations [message #1089802] Mon, 19 August 2013 09:04 Go to next message
Michel de Blok is currently offline Michel de BlokFriend
Messages: 8
Registered: August 2013
Junior Member
Hi all,

I am using a grammar that extends XbaseWithAnnotations and several parser rules contain the folowing definition:

annotations+=XAnnotation*


Which allows me to use Java Bean Validation annotations on my entities, e.g:

@javax.validation.constraints.AssertFalse


This works fine, but how can I specify multiple nested annotations within an annotation using XbaseWithAnnotations?

e.g. I can do this:

@AssertFalse.List(@AssertFalse)


which is accepted by the DSL editor and translates to Java perfectly. But if I try to specify multiple nested annotations, similar to the following:

@AssertFalse.List(@AssertFalse, @AssertFalse)
@AssertFalse.List({ @AssertFalse, @AssertFalse })
@AssertFalse.List(#{ @AssertFalse, @AssertFalse })


then the DSL editor always complains about mismatched input.

What is the correct syntax to specify multiple nested annotations with Xbase?
Or is it not (yet) possible to define such constructs?


NOTE: I know my example isn't functionally very usable, but I used it for simplicity. A more common use case is e.g. the @JoinColumns annotation in JPA.
Re: Nested annotations using XbaseWithAnnotations [message #1090629 is a reply to message #1089802] Tue, 20 August 2013 12:22 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Did you try
@AssertFalse.List(#[ @AssertFalse, @AssertFalse])


Am 19.08.13 16:14, schrieb Michel de Blok:
> Hi all,
>
> I am using a grammar that extends XbaseWithAnnotations and several
> parser rules contain the folowing definition:
>
> annotations+=XAnnotation*
>
> Which allows me to use Java Bean Validation annotations on my entities,
> e.g:
>
> @javax.validation.constraints.AssertFalse
>
> This works fine, but how can I specify multiple nested annotations
> within an annotation using XbaseWithAnnotations?
>
> e.g. I can do this:
>
> @AssertFalse.List(@AssertFalse)
>
> which is accepted by the DSL editor and translates to Java perfectly.
> But if I try to specify multiple nested annotations, similar to the
> following:
>
>
> @AssertFalse.List(@AssertFalse, @AssertFalse)
> @AssertFalse.List({ @AssertFalse, @AssertFalse })
> @AssertFalse.List(#{ @AssertFalse, @AssertFalse })
>
>
> then the DSL editor always complains about mismatched input.
>
> What is the correct syntax to specify multiple nested annotations with
> Xbase?
> Or is it not (yet) possible to define such constructs?
>
>
> NOTE: I know my example isn't functionally very usable, but I used it
> for simplicity. A more common use case is e.g. the @JoinColumns
> annotation in JPA.
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Nested annotations using XbaseWithAnnotations [message #1093023 is a reply to message #1090629] Fri, 23 August 2013 13:03 Go to previous messageGo to next message
Michel de Blok is currently offline Michel de BlokFriend
Messages: 8
Registered: August 2013
Junior Member
Yes, I tried that too but it doesn't work..
Re: Nested annotations using XbaseWithAnnotations [message #1222850 is a reply to message #1093023] Sat, 21 December 2013 16:00 Go to previous message
Michel de Blok is currently offline Michel de BlokFriend
Messages: 8
Registered: August 2013
Junior Member
Seems like this issue is addressed in XText 2.5. You can use the syntax suggested by Jan in that version..
Previous Topic:Problems view not refreshed after generating java class from text model
Next Topic:Accessing to errors in a model file
Goto Forum:
  


Current Time: Thu Nov 26 10:32:23 GMT 2020

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

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

Back to the top