Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » accessing features of a Java type
accessing features of a Java type [message #895497] Fri, 13 July 2012 09:43 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1762
Registered: July 2009
Location: Firenze, Italy
Senior Member
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


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: accessing features of a Java type [message #896442 is a reply to message #895497] Wed, 18 July 2012 12:08 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
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
Previous Topic:Export DSL
Next Topic:Opening my binary encoded files using XtextEditor
Goto Forum:
  


Current Time: Thu Feb 27 08:57:13 GMT 2020

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

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

Back to the top