Home » Modeling » TMF (Xtext) » Proposal for Jvm subtypes
| |
Re: Proposal for Jvm subtypes [message #961560 is a reply to message #955630] |
Sun, 28 October 2012 11:26 |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Goto Forum:
Current Time: Wed Sep 25 12:28:54 GMT 2024
Powered by FUDForum. Page generated in 0.03302 seconds
|