Creating multiple embedded editors with (slightly) specific content assist [message #1791617] |
Tue, 03 July 2018 05:00 |
Daniel Darvas Messages: 10 Registered: July 2014 |
Junior Member |
|
|
Hello,
I try to use Xtext-based embedded editors, created with my language's EmbeddedEditorFactory. However, I'd like to slightly specialise the content assist of the different editors, without breaking the behaviour of the non-embedded editor.
My idea was that I can add some fields that are optional to be injected:
class MyLangProposalProvider extends AbstractExprLangProposalProvider {
@Inject(optional=true)
public X x;
...
Then the proposal provider could take the content of x into account if present.
I made sure that X cannot be bound implicitly (doesn't have a parameterless public constructor nor a constructor with @Inject).
Then I create different child injectors for each embedded editor creation, whose module will bind X to specific instances:
Injector parentInjector = MylangActivator.getInstance().getInjector(MylangActivator.MY_LANG_FQN);
Injector injector = parentInjector.createChildInjector(new XModule(...));
EmbeddedEditorFactory editorFactory = injector.getInstance(MylangEmbeddedEditorFactory.class);
...
public static class XModule extends AbstractModule {
private final X xInstance;
public XModule(X xInstance) {
this.xInstance = xInstance;
}
@Override
public void configure() {
bind(X.class).toInstance(xInstance);
}
}
However, this does not work: the IContentProposalProvider is bound to MyLangProposalProvider already in the parentInjector, therefore the parent injector will be used to instantiate MyLangProposalProvider and the optional x will remain null.
Probably my whole direction is wrong and that's why I cannot make it working. Do you have any tips how to be able to provide some information to the embedded editors' content assist proposal providers, specific to each of them?
Thanks,
Daniel Darvas
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01925 seconds