Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext] Update highlighting after document change
[Xtext] Update highlighting after document change [message #59719] Thu, 16 July 2009 16:46 Go to next message
Eclipse UserFriend
Originally posted by: c.krause.cwi.nl

Hi,

in my application I have an action that appends additional text at the
end of a document in an open Xtext editor. I do this simply by:

doc.modify(new IUnitOfWork<Void,XtextResource>() {
public Void exec(XtextResource resource) throws Exception {
doc.set(doc.get() + newText);
return null;
}
});

Then I do this to move the selection to the end of the file, which seems
to work:

editor.selectAndReveal(doc.getLength(), 0);

My problem is that keywords and integers are not highlighted in the
added text. If I edit the added text the highlighting is updated,
but only where I edit it. Strangely, a comment /* ... */ that I also add
is correctly highlighted.

I tried to call editor.resetHighlightRange() to somehow trigger a
rehighlighting but it didn't change anything. Is there anything else I
could try?

Cheers,
Christian
Re: [Xtext] Update highlighting after document change [message #59741 is a reply to message #59719] Thu, 16 July 2009 16:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: c.krause.cwi.nl

Ok, it seems now that also the comments are not highlighted. I don't
know what happened there before..

Christian Krause wrote:
> Hi,
>
> in my application I have an action that appends additional text at the
> end of a document in an open Xtext editor. I do this simply by:
>
> doc.modify(new IUnitOfWork<Void,XtextResource>() {
> public Void exec(XtextResource resource) throws Exception {
> doc.set(doc.get() + newText);
> return null;
> }
> });
>
> Then I do this to move the selection to the end of the file, which seems
> to work:
>
> editor.selectAndReveal(doc.getLength(), 0);
>
> My problem is that keywords and integers are not highlighted in the
> added text. If I edit the added text the highlighting is updated,
> but only where I edit it. Strangely, a comment /* ... */ that I also add
> is correctly highlighted.
>
> I tried to call editor.resetHighlightRange() to somehow trigger a
> rehighlighting but it didn't change anything. Is there anything else I
> could try?
>
> Cheers,
> Christian
Re: [Xtext] Update highlighting after document change [message #59885 is a reply to message #59741] Fri, 17 July 2009 04:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

that's kind of irritating as I've something like this before and it
worked as expected.
However, you should try to create an InsertEdit and call apply(Document)
instead of modifying the content brute force via document.set(). If this
does not work, please file a bug and describe the steps to reproduce it.

Regards,
Sebastian

--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 16.07.2009 22:49 Uhr, schrieb Christian Krause:
> Ok, it seems now that also the comments are not highlighted. I don't
> know what happened there before..
>
> Christian Krause wrote:
>> Hi,
>>
>> in my application I have an action that appends additional text at the
>> end of a document in an open Xtext editor. I do this simply by:
>>
>> doc.modify(new IUnitOfWork<Void,XtextResource>() {
>> public Void exec(XtextResource resource) throws Exception {
>> doc.set(doc.get() + newText);
>> return null;
>> }
>> });
>>
>> Then I do this to move the selection to the end of the file, which
>> seems to work:
>>
>> editor.selectAndReveal(doc.getLength(), 0);
>>
>> My problem is that keywords and integers are not highlighted in the
>> added text. If I edit the added text the highlighting is updated,
>> but only where I edit it. Strangely, a comment /* ... */ that I also
>> add is correctly highlighted.
>>
>> I tried to call editor.resetHighlightRange() to somehow trigger a
>> rehighlighting but it didn't change anything. Is there anything else I
>> could try?
>>
>> Cheers,
>> Christian
Re: [Xtext] Update highlighting after document change [message #59958 is a reply to message #59885] Fri, 17 July 2009 05:04 Go to previous message
Eclipse UserFriend
Originally posted by: c.krause.cwi.nl

Dear Sebastian,
that works like a charm :). Thanks a lot.

Cheers,
Christian

> Hi Christian,
>
> that's kind of irritating as I've something like this before and it
> worked as expected.
> However, you should try to create an InsertEdit and call
> apply(Document) instead of modifying the content brute force via
> document.set(). If this does not work, please file a bug and describe
> the steps to reproduce it.
>
> Regards,
> Sebastian
>
Previous Topic:Generation oddity with imported grammar
Next Topic:Content assist context
Goto Forum:
  


Current Time: Sun Jun 08 12:12:29 EDT 2025

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

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

Back to the top