Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Proposal for Jvm subtypes
Proposal for Jvm subtypes [message #955630] Tue, 23 October 2012 23:40 Go to next message
Edwin Park is currently offline Edwin ParkFriend
Messages: 124
Registered: July 2009
Senior Member
Hi,

I have an Xtext language where I'd like to use references to JvmTypes, but I'd like to specifically restrict the content proposal to only show types that implement a particular interface. What's the best way to do this?

Thanks,
Edwin
Re: Proposal for Jvm subtypes [message #955937 is a reply to message #955630] Wed, 24 October 2012 05:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi you may have a look/change what xbase does with
completeJvmParameyrizedTypeReference / completeJavaTypes with a
restricted filter (not the all filter) in xbaseproposalprovider
Regards, Christian

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Proposal for Jvm subtypes [message #961560 is a reply to message #955630] Sun, 28 October 2012 11:26 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1813
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

in your content proposals class you can inject

@Inject
private ITypesProposalProvider typeProposalProvider;
@Inject
private JvmTypesBuilder typesBuilder;

and then do something like

@Override
public void completeXXXX_YYYY(EObject model,
Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
// we show only subtypes of AbstractDeclarativeValidator
showOnlySubtypesOf(model, context, acceptor,
AbstractDeclarativeValidator.class,
<The EStructuralFeature you want to create proposals for, e.g., YYYY>);
}

protected void showOnlySubtypesOf(EObject model,
ContentAssistContext context,
ICompletionProposalAcceptor acceptor,
Class<?> superType, EReference reference) {
typeProposalProvider.createSubTypeProposals(
typesBuilder.newTypeRef(model, superType).getType(), this,
context, reference, acceptor);
}

hope this helps
Lorenzo

On 10/24/2012 01:40 AM, Edwin Park wrote:
> Hi,
>
> I have an Xtext language where I'd like to use references to JvmTypes,
> but I'd like to specifically restrict the content proposal to only show
> types that implement a particular interface. What's the best way to do
> this?
>
> Thanks,
> Edwin
>


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Previous Topic:Could I create jdt projects in the workspace as result of a xtext generator ?
Next Topic:Generating Objects
Goto Forum:
  


Current Time: Wed Sep 25 12:28:54 GMT 2024

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

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

Back to the top