Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xtend2] access static member in another package
[xtend2] access static member in another package [message #786377] Mon, 30 January 2012 10:46 Go to next message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
Hello all,

in xtend2, I can write something like this
val foo = new my.very.long.package.Class()


But if a try to access a static member the editor complains. That is, I cannot write something like this
val foo = my.very.long.package.Class::IamStatic()


Where Class is either a Java class or an xtend2 class, and the current class is in another package, of course.
So, how can I access a static member of a class contained in another package?

I do not want (or cannot) import the class and then simply use
Class::IamStatic()

because I need to keep the "namespace" explicit in the code to avoid confusion. Moreover, I might be inside a class whose name is again 'Class', an so without package specification I cannot tell the compiler to use the class in the other package.

thanks
B
Re: [xtend2] access static member in another package [message #786427 is a reply to message #786377] Mon, 30 January 2012 12:07 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Bruce,

val foo = my::very::long::package::Class::IamStatic()

should work.

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

Am 30.01.12 11:46, schrieb Bruce L.:
> Hello all,
>
> in xtend2, I can write something like this
>
> val foo = new my.very.long.package.Class()
>
>
> But if a try to access a static member the editor complains. That is, I
> cannot write something like this
>
> val foo = my.very.long.package.Class::IamStatic()
>
>
> Where Class is either a Java class or an xtend2 class, and the current
> class is in another package, of course.
> So, how can I access a static member of a class contained in another
> package?
>
> I do not want (or cannot) import the class and then simply use
> Class::IamStatic()
> because I need to keep the "namespace" explicit in the code to avoid
> confusion. Moreover, I might be inside a class whose name is again
> 'Class', an so without package specification I cannot tell the compiler
> to use the class in the other package.
>
> thanks
> B
Re: [xtend2] access static member in another package [message #786446 is a reply to message #786427] Mon, 30 January 2012 12:45 Go to previous message
Bruce L. is currently offline Bruce L.Friend
Messages: 81
Registered: June 2011
Member
Doh! Embarrassed
I thought I tried it...
Thank you, it works

B
Previous Topic:Could not resolve reference to Type (Type: DataType | Class)
Next Topic:xtext-proxy on maven.eclipse.org is 'Out of Service'
Goto Forum:
  


Current Time: Tue Apr 23 16:20:53 GMT 2024

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

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

Back to the top