Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Java Proposal
Java Proposal [message #818628] Sun, 11 March 2012 23:31 Go to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
Hi all,
I'm new on the forum and xtext... I have to simulate the Java import for my DSL, this is the code:

ImportDeclaration: 
'import' ('static')? import = QualifiedNameWithWildcard ';'

QualifiedNameWithWildcard:
  QualifiedName '.*'?
;

QualifiedName:
  ID ('.' ID)*
;


now I want suggest the package and classes like Eclipse. How can I retrieve some classes or package on the classpath and add this on the MYDSLProposalProvider?
Re: Java Proposal [message #818853 is a reply to message #818628] Mon, 12 March 2012 07:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
Hi,

you can ask the "index" for its elements.
some code for starting can be found here:
http://www.eclipse.org/forums/index.php/mv/msg/261440/754503/#msg_754503
http://www.eclipse.org/forums/index.php/m/767941/#msg_767941

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #818926 is a reply to message #818853] Mon, 12 March 2012 09:35 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
Hi Christian!
Thanks for your reply, my DSL also support the Java classes how can I add also the Java classes?
Re: Java Proposal [message #819291 is a reply to message #818926] Mon, 12 March 2012 18:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
Is your java stuff custom build or based on Xbase?
Never the less a look at ITypesProposalProvider might it be worth

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #819780 is a reply to message #819291] Tue, 13 March 2012 10:17 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
It's a custom build... Thanks, do you know where I can find some documentation about the use of the ITypesProposalProvider ?
Re: Java Proposal [message #819791 is a reply to message #819780] Tue, 13 March 2012 10:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
Hi I fear there is no docs and you have to look at the usages in
Xbase/Xtend


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #819832 is a reply to message #819791] Tue, 13 March 2012 11:26 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
@Inject
ITypesProposalProvider javaProposal;
@Inject
ITypeProvider.Factory typeProviderFactory;
...
ResourceSet set = model.eResource().getResourceSet();
ITypeProvider tp = typeProviderFactory.findTypeProvider(set);
if (tp == null) {
     tp = typeProviderFactory.createTypeProvider(set);
}
if (tp == null) {
     return;
}try {
  JvmType t = tp.findTypeByName(java.util.Iterator.class.getName());
  Filter filter = TypeMatchFilters.and(TypeMatchFilters.isPublic(), TypeMatchFilters.canInstantiate());
  javaProposal.createSubTypeProposals(t, this, context, filter, acceptor);
} catch (TypeNotFoundException e) {}


with this code I retrieve some classes like Iterator, how can I retrieve more classes on classpath? How can I use findTypeByName to have more JvmType?
Re: Java Proposal [message #820082 is a reply to message #819832] Tue, 13 March 2012 17:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
Hi,

are you sure there is anything else than default java classes on the classpath? and why do you call createSubTypeProposals and not createTypeProposals
as XbaseProposalProvider does.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #820153 is a reply to message #820082] Tue, 13 March 2012 19:57 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
Hi, I need just the default java classes but with tp.findTypeByName(java.util.Iterator.class.getName()) i retrieve only the classes with the name similar to java.util.Iterator.
Re: Java Proposal [message #820161 is a reply to message #820153] Tue, 13 March 2012 20:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
and what is the problem?

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #820244 is a reply to message #820161] Tue, 13 March 2012 22:29 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
Hi Christian, sorry but I'm new on XText...
How can I have more classes and not only the classes with the name similar to java.utili.Iterator? Is there a method different from fyndTypeByName to retrieve classes? I need a proposal like this:

ImportDeclaration:
'import' import= [jvmTypes::JvmType|Name] ';';

but with this grammar I can't have import with wildcard
Re: Java Proposal [message #820460 is a reply to message #820244] Wed, 14 March 2012 06:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
Hi,

although you are a newbie you are trying advanced things. And what i still do not understand is why you dont call org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider.createTypeProposals(ICompletionProposalFactory, ContentAssistContext, EReference, ICompletionProposalAcceptor) as i told you.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #820570 is a reply to message #820460] Wed, 14 March 2012 09:43 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
You're right sorry, but how can I get the ICompletionProposalFactory
Re: Java Proposal [message #820582 is a reply to message #820570] Wed, 14 March 2012 09:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
same as before: look into the spurcecode what base does. I'd have to
do this too.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #820627 is a reply to message #820582] Wed, 14 March 2012 11:09 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
sorry I cannot figure out how I can get an instance of ICompletionProposalFactory
Re: Java Proposal [message #820639 is a reply to message #820627] Wed, 14 March 2012 11:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
Hi, your proposal provider is a ICompketionProposalFactory so what
about imply passing this as xBase does?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Java Proposal [message #820652 is a reply to message #820639] Wed, 14 March 2012 11:47 Go to previous messageGo to next message
Antonio Metallo is currently offline Antonio MetalloFriend
Messages: 24
Registered: March 2012
Junior Member
OK, thanks a lot Christian and sorry but I'm still learning how to use xtext...
Re: Java Proposal [message #821641 is a reply to message #820652] Thu, 15 March 2012 16:29 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
No Problem Wink but doing advanced stuff in Xtext implies reading Xtext sourcecode.
not everything can be documented in reasonable time - sadly.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Formatting for Python-like languages
Next Topic:[Xtend] Xtend 2.3 maven compiler build
Goto Forum:
  


Current Time: Thu Apr 02 17:05:03 GMT 2020

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

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

Back to the top