Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content assist in embedded editor
Content assist in embedded editor [message #1698291] Fri, 12 June 2015 22:32 Go to next message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi guys,

I am migrating my application to use embedded editors but I am having some issues with the content assist for a reason which I do not able to figure out yet, the embedded editor generates different content assist context for the same grammar.

Do you have any idea about this? Possible reason or entry point to start my debugging?

Thanks in advance.

Regards,
Luis

[Updated on: Fri, 12 June 2015 22:33]

Report message to a moderator

Re: Content assist in embedded editor [message #1698297 is a reply to message #1698291] Sat, 13 June 2015 00:32 Go to previous messageGo to next message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
I did more analysis on the issue and I realised that the issue is because I am changing the injector before creating the embedded editors

// Here I am using the same logic of getInjector method but adding a module which bind the metadata provider to one specific object
Injector injector = MyDSLExtendedActivator.getInstance().createMetadataInjector(new MessageTransformerModule(metadataProvider));

// If I use the injector as it is it works great
// Injector injector = MyDSLExtendedActivator.getInstance().getInjector(MyDSLActivator.COM_MYDSL_PLUGIN_ID);

CustomEmbeddedEditorResourceProvider resourceProvider = injector.getInstance(CustomEmbeddedEditorResourceProvider.class);
EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);

EmbeddedEditor editor = factory.newEditor(resourceProvider).showErrorAndWarningAnnotations().withParent(top);
try (Scanner scanner = new Scanner(source.getFile().getContents())) {
String content = scanner.useDelimiter("\\A").next();
EmbeddedEditorModelAccess editorModelAccess = editor.createPartialEditor("", content, "", false);
}

Maybe If I explain how I am trying to do some one can give some tip.

Case 1:
I have the XtextEditor but if the user double click the file I want to open my editor but the proposal provider is inject with a dummy metadata provider I did this in the UiModule with bindings

Case 2:
If the user open one specific view I want to show multiples embedded editor each of one in a different tab but now each proposal provider for each editor is binding with one specific instance different for each tab.

Regards,
Luis
Re: Content assist in embedded editor [message #1698366 is a reply to message #1698297] Mon, 15 June 2015 06:51 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hey Luis,

you may not instantiate an injector twice from the runtime / ui module
in Eclipse. The injector creation performs side effects on global
registries. These will be overridden by subsequent #createInjector
operations. You may want to try Injector.createChildInjector instead,
with the original injector from the activator as the host.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Content assist in embedded editor [message #1698424 is a reply to message #1698366] Mon, 15 June 2015 13:56 Go to previous message
Luis De Bello is currently offline Luis De BelloFriend
Messages: 95
Registered: January 2015
Member
Hi Sebastian,

Thanks for your answer , I was trying to use the childInjector but it does not work either.

At the beginning I had the binding in my UiModule and then execute

Injector injector = MyDSLExtendedActivator.getInstance().getInjector(MyDSLActivator.COM_MYDSL_PLUGIN_ID);
injector = injector.createChildInjector(new MessageTransformerModule(metadataProvider));

but using this code I got the exception "binding is already define"

So I removed the bind from my UiModule in this case I got a different exception because my proposal provider had

@Inject
private IMetaDataProvider dataSenseProvider;

In the first line when guide try to build the injector this fail because there is no bind for IMetaDataProvider, to solve this I used @Inject(optional=true)

After doing these two changes the code run without exception however the injector is not setting my metadata provider

I debugged the constructor of my proposal provider and I checked the members injector attribute and the inject was not created for my field then I tried to inject something different for instance

@Inject
protected IPreferenceStoreAccess preferenceStoreAccess;

That works ok , so I think that my bind in the child injector cannot be used for the parent.

this is the code in my module

public class MessageTransformerModule implements Module {

private IMetaDataProvider metaDataProvider;

public MessageTransformerModule(IMetaDataProvider metaDataProvider) {
super();
this.metaDataProvider = metaDataProvider;
}

@Override
public void configure(Binder binder) {
binder.bind(IMetaDataProvider.class).toInstance(metaDataProvider);
}
}



Best regards,
Luis
Previous Topic:Left recursive type declarations in Xtext
Next Topic:Creating Annotations with params in JvmModelInferrer
Goto Forum:
  


Current Time: Tue Mar 19 07:41:57 GMT 2024

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

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

Back to the top