|
Re: what is the Xtext 2.0 replacement for DefaultDocumentEditor? [message #662595 is a reply to message #662554] |
Thu, 31 March 2011 09:08 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Henrik,
please use IXtextDocument.modify(IUnitOfWork). It encapsulates the
modification.
Just as a sidenote: It's almost never necessary to obtain an injector.
One would usually inject the required dependencies directly and create
the instances itself by Guice. When this rule is transitively applied,
nobody except the ExectuableExtensionFactory needs access to the
injector. E.g. in your code, you could use
@Inject
Provider<DefaultDocumentEditor> editorProvider;
editorProvider.get().process(unitOfWork, document);
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 31.03.11 07:51, schrieb Henrik Rentz-Reichert:
> Hi,
>
> I used a piece of code to make a change to the EMF model and readily reconcile it in the Xtext editor:
>
> IXtextDocument document = ...
> final String fragment = ...
> DefaultDocumentEditor edit = new DefaultDocumentEditor();
> Injector injector = ...
> injector.injectMembers(edit);
> edit.process(new IUnitOfWork.Void<XtextResource>() {
> @Override
> public void process(XtextResource resource) throws Exception {
> if (resource != null) {
> EObject object = resource.getEObject(fragment);
> // do something useful...
> }
> }
> }, document);
>
> What is the replacement for this in Xtext 2.0?
>
> Thanks,
> Henrik
|
|
|
|
Powered by
FUDForum. Page generated in 0.02313 seconds