|
|
Re: Using annotations in DSL [message #697603 is a reply to message #697595] |
Sun, 17 July 2011 11:08 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Gunnar,
your language could extend XbaseWithAnnotations. It provides exactly
what you are looking for. Though I've to admit that you'll have to dig
into Xtend's implementation to learn how to create annotated elements.
However, it should serve as a goog starting point.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 17.07.11 12:52, Gunnar Morling wrote:
> Hi,
>
> first off, I'd like to say that I'm really impressed by Xtext/Xtend. I
> think we're going to see a lot of exciting stuff based on these
> technologies in the future.
>
> What I'd like to know is whether it's possible to use existing Java
> annotations within a DSL. Looking at the canonic entity DSL for example,
> it would be nice if it was possible to specify JPA annotations at the
> fields of an entity in the DSL. These anotations then would just be
> transferred unaltered to the output model during code generation.
> Is something like that possible? If so, are there any examples which I
> could use as a starting point?
>
> Thanks, Gunnar
|
|
|
|
Re: Using annotations in DSL [message #1694828 is a reply to message #697707] |
Fri, 08 May 2015 09:52 |
Manisha Ghule Messages: 6 Registered: April 2015 |
Junior Member |
|
|
Hi,
I also want to support using annotations in my DSL.
In grammar, I define entity as below:
Entity:
(entityAnnotation=XAnnotation)?
'entity' name=ValidID ('extends' superType=JvmParameterizedTypeReference)? '{'
features+=Feature*
'}';
However, when I create a file of my DSL type and use annotation, I get an error: "missing EOF at '@'"
Am I missing something?
P.S.: I am trying to use JPA annotation in my file.
[Updated on: Fri, 08 May 2015 10:00] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Using annotations in DSL [message #1695195 is a reply to message #1695166] |
Tue, 12 May 2015 14:53 |
|
On 12/05/2015 14:41, Manisha Ghule wrote:
> Hi,
>
> I want to transfer annotations used in my DSL file to the generated java
> file.
> I checked xtend source code; however, for me, it seemed a bit complex as
> I am new to xtext/xtend.
>
> I tried following in my JvmModelInferrer:
>
> annotations +=
> entity.toAnnotation(entity.entityAnnotation.annotationType.class)
>
> I am getting following error:
> java.lang.IllegalArgumentException: The type
> org.eclipse.xtext.common.types.impl.JvmAnnotationTypeImpl is not on the
> classpath.
>
> My DSL file:
> import javax.persistence.Entity
>
> @Entity
> entity TestEntity {
> prop1 : String
> }
>
> Could you please provide me some pointers to get annotations in
> generated file?
>
Hi
are you getting this error when you try the editor of your DSL in a
project? If that is the case, you need to make sure that the projects
for your DSL have a dependency on the bundles containing your
annotations and in particular other Xtext bundles, like
org.eclipse.xtext.common.types.
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02795 seconds