Home » Modeling » TMF (Xtext) » Proposal for Jvm subtypes
Proposal for Jvm subtypes [message #955630] |
Tue, 23 October 2012 19:40  |
Eclipse User |
|
|
|
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 #961560 is a reply to message #955630] |
Sun, 28 October 2012 07:26  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Fri Jul 04 21:32:01 EDT 2025
Powered by FUDForum. Page generated in 0.04439 seconds
|