JvmType content proposal [message #1758929] |
Tue, 04 April 2017 16:54  |
Daniel Cardin Messages: 109 Registered: July 2009 |
Senior Member |
|
|
Hello there,
I need a part of my dsl to refer to a subclass of a certain type. So I followed the content proposal method described on Karsten's blog
override public void completeJvmParameterizedTypeReference_Type(EObject model, Assignment assignment,
ContentAssistContext context, ICompletionProposalAcceptor acceptor)
{
if (EcoreUtil2.getContainerOfType(model, Input) !== null || EcoreUtil2.getContainerOfType(model, Rule) !== null)
{
val jvmTypeProvider = jvmTypeProviderFactory.createTypeProvider(model.eResource().getResourceSet());
val interfaceToImplement = jvmTypeProvider.findTypeByName("com.pc360.configurator.interfaces.Configurable")
typeProposalProvider.createSubTypeProposals(interfaceToImplement, this, context,
RuleDslPackage.Literals.INPUT__CONFIGURABLE, TypeMatchFilters.canInstantiate(), acceptor);
}
else
{
super.completeJvmParameterizedTypeReference_Type(model, assignment, context, acceptor);
}
}
This works exactly as assumed. The list of subclasses appears in the proposal popup. But, I have two problems:
1- If I select any value, it's not output in the editor. I don't see any errors. Just nothing happens.
2- If I input anything (as a prefix), I would expect it to be applied as an added filter. But it doesn't return anything anymore.
Thanks for your suggestions,
[Updated on: Tue, 04 April 2017 16:56] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: JvmType content proposal [message #1758955 is a reply to message #1758953] |
Tue, 04 April 2017 19:20   |
|
in the log you can find this error message
8939 [main] ERROR org.eclipse.xtext.xbase.ui.contentassist.ImportingTypesProposalProvider$FQNImporter - Could not find unique type named 'a.b.c.Test' in scope
there is actually no entry inside scope.
this is caused by your faulty impl of the proposal provider (you use the wrong reference, well it actually is not a cross ref at all but a containment ref.
typeProposalProvider.createSubTypeProposals(interfaceToImplement, this, context,
TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, TypeMatchFilters.canInstantiate(), acceptor);
Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.02058 seconds