Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Getting all JvmTypes matching a wildcard import
Getting all JvmTypes matching a wildcard import [message #1694412] Tue, 05 May 2015 08:13 Go to next message
Cioran Naroic is currently offline Cioran NaroicFriend
Messages: 18
Registered: December 2013
Junior Member
Hi,

I would like to be able to reference multiple JvmTypes with a wildcard mechanism in my DSL code:

feature {
    // ref java.util.List
    // ref java.util.Map
    // or...
    ref java.util.*
}


I can write a grammar for the commented lines and manipulate the references afterwards in my validator, inferrer, etc. However, I don't know how to automatically retrieve all the JvmTypes that are matched by an expression such as java.util.*

I spent some time in ImportedNamespaceAwareLocalScopeProvider, XImportSectionNamespaceScopeProvider and some others but got lost trying to find an utility that would do the job.

I don't want an import mechanism and don't need these types in any scope. I'm just looking for an API in Xtext that would be able to retrieve from QualifiedName("java.util.*") a list of #["java.util.List", "java.util.Map", ...] ?

Thanks again for your help,

Cioran
Re: Getting all JvmTypes matching a wildcard import [message #1694424 is a reply to message #1694412] Tue, 05 May 2015 09:00 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

It is clear that this won't allow you to have a reference to a JvmType for your "ref" statement.

Xtext does not provide API to resolve JvmTypes for wildcards. You will have to search for all potential Java types known in the scope. Therefore you will have to leverage JDT's search engine.

You may find some more code in JdtTypesProposalProvider which could be of use for you.




Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Getting all JvmTypes matching a wildcard import [message #1694433 is a reply to message #1694412] Tue, 05 May 2015 09:42 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Please note that whatever impl you may choose to use, it will likely
suffer from the fact, that a classloader cannot be enumerated (in
general, there are exceptions like URLClassLoader) thus you will
unlikely find all types from one package without a dependency to Eclipse.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Getting all JvmTypes matching a wildcard import [message #1695139 is a reply to message #1694433] Tue, 12 May 2015 09:21 Go to previous message
Cioran Naroic is currently offline Cioran NaroicFriend
Messages: 18
Registered: December 2013
Junior Member
Thanks, I was able to solve my problem using the JDT Search Engine. Having a dependency towards Eclipse isn't a problem in my case. Performance are however really poor, I'll have to dig a bit into scopes and participants.

Thanks again!
Previous Topic:[xText] Unable to Generate xText Artifacts
Next Topic:Validation in Xtext
Goto Forum:
  


Current Time: Wed Apr 24 19:58:17 GMT 2024

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

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

Back to the top