Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [xtext] propagate model changes to editor
[xtext] propagate model changes to editor [message #28469] Mon, 09 February 2009 06:34 Go to next message
Eclipse UserFriend
Originally posted by: knut.wannheden.gmail.com

Hi all,

I'd like to programmatically change the model instance (using the EMF
API) as loaded by the Xtext editor. Once my changes have been applied
I'd like to see the corresponding changes in the open editor. This
feature doesn't seem to be implemented yet (as also hinted by the TODO
comment in XtextDocument#modify).

Is this something that you plan to get into the Galileo release? And
will this be supported by an API like JDT's ASTRewrite (maybe EMF.Edit
based?) or will direct model modifications (using EMF API) be the basis?

As a workaround I now save the modified resource to a
ByteArrayOutputStream and then call XtextDocument#set with that inside
my UnitOfWork. That seems to work for now.

Cheers,

--knut
Re: [xtext] propagate model changes to editor [message #29015 is a reply to message #28469] Tue, 10 February 2009 04:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi Knut,

yes we want to fix the TODO in XtextDocument#modify for Galileo.
Patches are welcome ;-)

We don't have plans for any special modification API yet.
That doesn't mean that it's not a good idea, we're just focussing on
other things at this time. Feel free to come up with suggestions.

Cheers,
Sven


Knut Wannheden schrieb:
> Hi all,
>
> I'd like to programmatically change the model instance (using the EMF
> API) as loaded by the Xtext editor. Once my changes have been applied
> I'd like to see the corresponding changes in the open editor. This
> feature doesn't seem to be implemented yet (as also hinted by the TODO
> comment in XtextDocument#modify).
>
> Is this something that you plan to get into the Galileo release? And
> will this be supported by an API like JDT's ASTRewrite (maybe EMF.Edit
> based?) or will direct model modifications (using EMF API) be the basis?
>
> As a workaround I now save the modified resource to a
> ByteArrayOutputStream and then call XtextDocument#set with that inside
> my UnitOfWork. That seems to work for now.
>
> Cheers,
>
> --knut
Re: [xtext] propagate model changes to editor [message #43712 is a reply to message #28469] Mon, 11 May 2009 10:29 Go to previous messageGo to next message
Eclipse UserFriend
Hello Knut,

I'm confronted with the same problem.

Does that mean you are getting the XtextDocument via get() then parsing it
by hand, inserting your model element at the appropriate place and then
calling set() -> Urrgh!

Could you briefly explain your workaround a bit more in detail. A code
example would be very nice.

Ciao, Michael


"Knut Wannheden" <knut.wannheden@gmail.com> wrote in message
news:gmp4bm$jrs$1@build.eclipse.org...
> Hi all,
>
> I'd like to programmatically change the model instance (using the EMF API)
> as loaded by the Xtext editor. Once my changes have been applied I'd like
> to see the corresponding changes in the open editor. This feature doesn't
> seem to be implemented yet (as also hinted by the TODO comment in
> XtextDocument#modify).
>
> Is this something that you plan to get into the Galileo release? And will
> this be supported by an API like JDT's ASTRewrite (maybe EMF.Edit based?)
> or will direct model modifications (using EMF API) be the basis?
>
> As a workaround I now save the modified resource to a
> ByteArrayOutputStream and then call XtextDocument#set with that inside my
> UnitOfWork. That seems to work for now.
>
> Cheers,
>
> --knut
Re: [xtext] propagate model changes to editor [message #43770 is a reply to message #43712] Mon, 11 May 2009 10:57 Go to previous message
Eclipse UserFriend
Originally posted by: knut.wannheden.gmail.com

Hi Michael,

Yes, except for the parsing step that's what I did. The UnitOfWork is
given the model as it is parsed, so it can be directly modified. Then it
can be saved and set(). Unfortunately I don't have an example at hand
anymore but it should be something like this:

final XtextDocument doc = ...;
doc.modify(new UnitOfWork<Void>() {
Void exec(XtextResource resource) throws Exception {
MyModel model = resource.getContents().get(0);
// modification goes here
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
resource.save(out, null);
doc.set(out.toString());
}
};

Of course that's still just a workaround. I reported the following issue
for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=265097.

Cheers,

--knut

Michael Mühlberg wrote:
> Hello Knut,
>
> I'm confronted with the same problem.
>
> Does that mean you are getting the XtextDocument via get() then parsing it
> by hand, inserting your model element at the appropriate place and then
> calling set() -> Urrgh!
>
> Could you briefly explain your workaround a bit more in detail. A code
> example would be very nice.
>
> Ciao, Michael
>
>
> "Knut Wannheden" <knut.wannheden@gmail.com> wrote in message
> news:gmp4bm$jrs$1@build.eclipse.org...
>> Hi all,
>>
>> I'd like to programmatically change the model instance (using the EMF API)
>> as loaded by the Xtext editor. Once my changes have been applied I'd like
>> to see the corresponding changes in the open editor. This feature doesn't
>> seem to be implemented yet (as also hinted by the TODO comment in
>> XtextDocument#modify).
>>
>> Is this something that you plan to get into the Galileo release? And will
>> this be supported by an API like JDT's ASTRewrite (maybe EMF.Edit based?)
>> or will direct model modifications (using EMF API) be the basis?
>>
>> As a workaround I now save the modified resource to a
>> ByteArrayOutputStream and then call XtextDocument#set with that inside my
>> UnitOfWork. That seems to work for now.
>>
>> Cheers,
>>
>> --knut
>
>
Previous Topic:Embedding xtext editors
Next Topic:[xtext] content assist for first token assignments
Goto Forum:
  


Current Time: Thu Jul 17 01:41:18 EDT 2025

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

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

Back to the top