|
Re: accessing features of a Java type [message #896442 is a reply to message #895497] |
Wed, 18 July 2012 12:08 |
Jan Koehnlein Messages: 760 Registered: July 2009 Location: Hamburg |
Senior Member |
|
|
I guess 'feature' should be a cross reference to a JvmMember instead of
an XFeatureCall.
Am 13.07.12 11:43, schrieb Lorenzo Bettini:
> Hi
>
> I'd like to have in my grammar something like
>
> FeatureLabelSpecification:
> parameterType=JvmTypeReference ':' feature=XFeatureCall
>
> in order to be able to write in my DSL something like
>
> Person:name
> Writer:surname
>
> where Person and Writer are EMF generated classes which have getName(),
> getSurname() etc.
>
> however, I cannot seem to implement scoping correctly
>
> as a first solution I tried to add this in my custom scope provider
>
> @Override
> protected JvmDeclaredType getContextType(EObject obj) {
> if (obj instanceof FeatureLabelSpecification) {
> FeatureLabelSpecification featureLabelSpecification =
> (FeatureLabelSpecification) obj;
> return (JvmDeclaredType) featureLabelSpecification
> .getParameterType().getType();
> }
>
> return super.getContextType(obj);
> }
>
> but then I get a validation error
>
> ERROR:Static access to instance member getName
>
> so I was wondering what would be a better (possibly the right :) way of
> achieving this...
>
> note that from FeatureLabelSpecification I will only need, during the
> generation, only the strings of the Java type and feature ...
>
> thanks in advance
> Lorenzo
>
>
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
---
Get professional support from the Xtext committers at www.typefox.io
|
|
|
Powered by
FUDForum. Page generated in 0.02915 seconds