Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Java Proposal
Java Proposal [message #818628] Sun, 11 March 2012 19:31 Go to next message
Eclipse UserFriend
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 03:40 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Java Proposal [message #818926 is a reply to message #818853] Mon, 12 March 2012 05:35 Go to previous messageGo to next message
Eclipse UserFriend
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 14:24 Go to previous messageGo to next message
Eclipse UserFriend
Is your java stuff custom build or based on Xbase?
Never the less a look at ITypesProposalProvider might it be worth

~Christian
Re: Java Proposal [message #819780 is a reply to message #819291] Tue, 13 March 2012 06:17 Go to previous messageGo to next message
Eclipse UserFriend
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 06:26 Go to previous messageGo to next message
Eclipse UserFriend
Hi I fear there is no docs and you have to look at the usages in
Xbase/Xtend
Re: Java Proposal [message #819832 is a reply to message #819791] Tue, 13 March 2012 07:26 Go to previous messageGo to next message
Eclipse UserFriend
@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 13:53 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Java Proposal [message #820153 is a reply to message #820082] Tue, 13 March 2012 15:57 Go to previous messageGo to next message
Eclipse UserFriend
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 16:08 Go to previous messageGo to next message
Eclipse UserFriend
and what is the problem?
Re: Java Proposal [message #820244 is a reply to message #820161] Tue, 13 March 2012 18:29 Go to previous messageGo to next message
Eclipse UserFriend
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 02:36 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Java Proposal [message #820570 is a reply to message #820460] Wed, 14 March 2012 05:43 Go to previous messageGo to next message
Eclipse UserFriend
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 05:53 Go to previous messageGo to next message
Eclipse UserFriend
same as before: look into the spurcecode what base does. I'd have to
do this too.
Re: Java Proposal [message #820627 is a reply to message #820582] Wed, 14 March 2012 07:09 Go to previous messageGo to next message
Eclipse UserFriend
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 07:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi, your proposal provider is a ICompketionProposalFactory so what
about imply passing this as xBase does?
Re: Java Proposal [message #820652 is a reply to message #820639] Wed, 14 March 2012 07:47 Go to previous messageGo to next message
Eclipse UserFriend
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 12:29 Go to previous message
Eclipse UserFriend
No Problem Wink but doing advanced stuff in Xtext implies reading Xtext sourcecode.
not everything can be documented in reasonable time - sadly.

~Christian
Previous Topic:Formatting for Python-like languages
Next Topic:[Xtend] Xtend 2.3 maven compiler build
Goto Forum:
  


Current Time: Sat Jul 05 07:57:44 EDT 2025

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

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

Back to the top