Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xtend2][xbase] Reference to constants
[xtend2][xbase] Reference to constants [message #663191] Mon, 04 April 2011 09:28 Go to next message
Alessandro Carraro is currently offline Alessandro CarraroFriend
Messages: 27
Registered: July 2009
Junior Member
Is there a way to reference a constant (ie public+static+final) inside
an expression?

if I have
public class T{
public static String A = "x";
}

I would like to reference it but «T.A» report 2 errors:
Couldn't resolve reference to JvmIdentifiableElement 'T'.
Couldn't resolve reference to JvmIdentifiableElement 'A'.

Obviously the type has been imported

Thanks
Alex
Re: [xtend2][xbase] Reference to constants [message #663203 is a reply to message #663191] Mon, 04 April 2011 09:55 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

please try to use T::A to refer to static fields or methods.

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

Am 04.04.11 11:28, schrieb carraro.alessandro@gmail.com:
> Is there a way to reference a constant (ie public+static+final) inside
> an expression?
>
> if I have
> public class T{
> public static String A = "x";
> }
>
> I would like to reference it but «T.A» report 2 errors:
> Couldn't resolve reference to JvmIdentifiableElement 'T'.
> Couldn't resolve reference to JvmIdentifiableElement 'A'.
>
> Obviously the type has been imported
>
> Thanks
> Alex
Re: [xtend2][xbase] Reference to constants [message #663219 is a reply to message #663203] Mon, 04 April 2011 11:24 Go to previous messageGo to next message
Alessandro Carraro is currently offline Alessandro CarraroFriend
Messages: 27
Registered: July 2009
Junior Member
Il 04/04/2011 11.55, Sebastian Zarnekow ha scritto:
> Hi Alex,
>
> please try to use T::A to refer to static fields or methods.
>
> Regards,
> Sebastian

Thank you for replying and for the awesome work you already did on xtext
and xtend

Unfortunately I tried as you suggested (xbase help inspired me) but the
problem still remain:

Suppose the FQN of the class is
it.broadwaysolutions.broadgen2.DataObjectFactory<T>
and the field is SEP

but the following expression generate errors:
test(){
'''«it::broadwaysolutions::broadgen2::DataObjectFactory::SE P»'''
}

The errors are:
Couldn't resolve reference to JvmIdentifiableElement'it'.
Couldn't resolve reference to JvmIdentifiableElement'broadwaysolutions'.
mismatched input ':' expecting RULE_RICH_TEXT_END (on 1st colon)
mismatched input ':' expecting '}' (on the 3rd colon)
mismatched input ':' expecting '(' (on the 5th colon)
mismatched input ':' expecting '(' (on the 7th colon)
mismatched input '»'''' expecting '(' (at the end of the expression)

I have a workaround, but is rather unelegant: defining an extender with
a static method returning the constant.
Re: [xtend2][xbase] Reference to constants [message #663223 is a reply to message #663219] Mon, 04 April 2011 11:40 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

please note that references to static features have been implemented
after the M6. Do you use one of the latest nightlies?

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

Am 04.04.11 13:24, schrieb carraro.alessandro@gmail.com:
> Il 04/04/2011 11.55, Sebastian Zarnekow ha scritto:
>> Hi Alex,
>>
>> please try to use T::A to refer to static fields or methods.
>>
>> Regards,
>> Sebastian
>
> Thank you for replying and for the awesome work you already did on xtext
> and xtend
>
> Unfortunately I tried as you suggested (xbase help inspired me) but the
> problem still remain:
>
> Suppose the FQN of the class is
> it.broadwaysolutions.broadgen2.DataObjectFactory<T>
> and the field is SEP
>
> but the following expression generate errors:
> test(){
> '''«it::broadwaysolutions::broadgen2::DataObjectFactory::SE P»'''
> }
>
> The errors are:
> Couldn't resolve reference to JvmIdentifiableElement'it'.
> Couldn't resolve reference to JvmIdentifiableElement'broadwaysolutions'.
> mismatched input ':' expecting RULE_RICH_TEXT_END (on 1st colon)
> mismatched input ':' expecting '}' (on the 3rd colon)
> mismatched input ':' expecting '(' (on the 5th colon)
> mismatched input ':' expecting '(' (on the 7th colon)
> mismatched input '»'''' expecting '(' (at the end of the expression)
>
> I have a workaround, but is rather unelegant: defining an extender with
> a static method returning the constant.
Re: [xtend2][xbase] Reference to constants [message #663264 is a reply to message #663223] Mon, 04 April 2011 12:40 Go to previous messageGo to next message
Alessandro Carraro is currently offline Alessandro CarraroFriend
Messages: 27
Registered: July 2009
Junior Member
Il 04/04/2011 13.40, Sebastian Zarnekow ha scritto:
> Hi Alex,
>
> please note that references to static features have been implemented
> after the M6. Do you use one of the latest nightlies?
>
> Regards,
> Sebastian

Shame on me!
Thought that 15th March was updated enough :)

I'm currently using http://download.itemis.com/updates/nightly/

However to update to the latest I found (2.0.0.v201104031803) I get the
error:

No repository found containing:
osgi.bundle,org.eclipse.emf.mwe2.language.source,2.0.0.v2011 04020602


For mwe2 I'm using
http://download.eclipse.org/modeling/emft/mwe/updates/nightl y/ is it the
right place?
Re: [xtend2][xbase] Reference to constants [message #663266 is a reply to message #663264] Mon, 04 April 2011 12:45 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

I'd use the repositories that are provided by the build server, e.g.

https://hudson.eclipse.org/hudson/job/Xtext-nightly-HEAD/las tSuccessfulBuild/artifact/xtext.p2.repository/

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

Am 04.04.11 14:40, schrieb carraro.alessandro@gmail.com:
> Il 04/04/2011 13.40, Sebastian Zarnekow ha scritto:
>> Hi Alex,
>>
>> please note that references to static features have been implemented
>> after the M6. Do you use one of the latest nightlies?
>>
>> Regards,
>> Sebastian
>
> Shame on me!
> Thought that 15th March was updated enough :)
>
> I'm currently using http://download.itemis.com/updates/nightly/
>
> However to update to the latest I found (2.0.0.v201104031803) I get the
> error:
>
> No repository found containing:
> osgi.bundle,org.eclipse.emf.mwe2.language.source,2.0.0.v2011 04020602
>
>
> For mwe2 I'm using
> http://download.eclipse.org/modeling/emft/mwe/updates/nightl y/ is it the
> right place?
Re: [xtend2][xbase] Reference to constants [SOLVED] [message #663268 is a reply to message #663266] Mon, 04 April 2011 13:25 Go to previous messageGo to next message
Alessandro Carraro is currently offline Alessandro CarraroFriend
Messages: 27
Registered: July 2009
Junior Member
Il 04/04/2011 14.45, Sebastian Zarnekow ha scritto:
> Hi Alex,
>
> I'd use the repositories that are provided by the build server, e.g.
>
> https://hudson.eclipse.org/hudson/job/Xtext-nightly-HEAD/las tSuccessfulBuild/artifact/xtext.p2.repository/
>
>
> Regards,
> Sebastian

Thanks! This solved my problem, and created a new error :o
Never mind, I understand this is not released, I filed a bug on bugzilla :)

A note: imho the 'static reference' should be able to target imported
classes. atm only fully qualified constants are referrable

many thanks

Alex
Re: [xtend2][xbase] Reference to constants [SOLVED] [message #663297 is a reply to message #663268] Mon, 04 April 2011 14:54 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Alex,

it should be possible to refer to imported classes as well, e.g.

import org.mypackage.MyEnum
....
MyEnum::EnumLiteral

should work. Please file a ticket with a reproducable example if it fails.

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

Am 04.04.11 15:25, schrieb carraro.alessandro@gmail.com:
> Il 04/04/2011 14.45, Sebastian Zarnekow ha scritto:
>> Hi Alex,
>>
>> I'd use the repositories that are provided by the build server, e.g.
>>
>> https://hudson.eclipse.org/hudson/job/Xtext-nightly-HEAD/las tSuccessfulBuild/artifact/xtext.p2.repository/
>>
>>
>>
>> Regards,
>> Sebastian
>
> Thanks! This solved my problem, and created a new error :o
> Never mind, I understand this is not released, I filed a bug on bugzilla :)
>
> A note: imho the 'static reference' should be able to target imported
> classes. atm only fully qualified constants are referrable
>
> many thanks
>
> Alex
Previous Topic:NodeUtil in Xtext 2.0 (M6)? [Solved]
Next Topic:Deriving qualified names
Goto Forum:
  


Current Time: Thu Apr 25 17:34:40 GMT 2024

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

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

Back to the top