Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Text Editor Question
Text Editor Question [message #437264] Mon, 26 September 2005 14:29 Go to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Hello All,

I am creating a custom text editor for an industrial programming language
that we are using.

When compiled an Abstract Syntax Tree (AST) is created.
We also hold on to the source code so the line numbers and offsets are
important.

One requirement that we have is that the language of the comments should be
changed at the click of a button.

The problem here is that the number of lines spanned by the comments will
most likely change as they change language.
This will mean that most likely the line numbers of the code are now out of
sync with the AST.
So a recompile is required to get them back in sync.

What we were hoping to do was prevent this having to occur.

Is it somehow possible to use the document partitions to prevent the line
numbers of the code from changing ?
Or maybe we should have two Documents - one that contains code only and one
with comments only ?
Or maybe there's something more obvious that I am missing ?

Any help would be greatly appreciated.

Thanks.
Re: Text Editor Question [message #437317 is a reply to message #437264] Tue, 27 September 2005 08:52 Go to previous messageGo to next message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
Frank,

from what you tell I don't think you can avoid the recompile when
changing the comments - If the comments you replace with another
language version do not have the same lenght, all offset information in
your AST will be invalid.

Frank Abercorn wrote:
> Or maybe we should have two Documents - one that contains code only and one
> with comments only ?

This may be something you could do - have an editor input consisting of
the program code, annotated with the comments. Note that there is no
framework support for this, and you would have to implement much of the
reconciling, model updating, dirty state triggering etc. yourself.

-tom
Re: Text Editor Question [message #437328 is a reply to message #437317] Tue, 27 September 2005 13:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Tom,

Thanks for your reply.
What about using a ProjectionDocument to do it ?
This works for Folding so why not what I am talking about ?

I had a look at it this morning based on this article
http://www.eclipse.org/articles/Article-Folding-in-Eclipse-T ext-Editors/folding.html
but so far I have been unable to figure out a way to make it work.

For example I am using a FileDocumentProvider as an IDocumentProvider.
But which document should I return the Master or the Slave ?
It feels like there should be a way to have Viewer show parts of two
diffferent Documents - the Comment Document and the Code Document, and then
have some kind of mapping from View line to Model line (
ITextViewerExtension5 has something similar to this).

I'm not sure if this will work for me and to be honest I'm a little stuck as
to how to proceed.
Any help again would be great.

Thanks.



"Tom Eicher" <eclipse@tom.eicher.name> wrote in message
news:dhb17k$n3g$1@news.eclipse.org...
> Frank,
>
> from what you tell I don't think you can avoid the recompile when changing
> the comments - If the comments you replace with another language version
> do not have the same lenght, all offset information in your AST will be
> invalid.
>
> Frank Abercorn wrote:
>> Or maybe we should have two Documents - one that contains code only and
>> one with comments only ?
>
> This may be something you could do - have an editor input consisting of
> the program code, annotated with the comments. Note that there is no
> framework support for this, and you would have to implement much of the
> reconciling, model updating, dirty state triggering etc. yourself.
>
> -tom
Re: Text Editor Question [message #437329 is a reply to message #437328] Tue, 27 September 2005 13:59 Go to previous messageGo to next message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
Frank Abercorn wrote:
> What about using a ProjectionDocument to do it ?
> This works for Folding so why not what I am talking about ?
>
> I had a look at it this morning based on this article
> http://www.eclipse.org/articles/Article-Folding-in-Eclipse-T ext-Editors/folding.html
> but so far I have been unable to figure out a way to make it work.

Creating a IDocumentInformationMapping that does this may be possible.
However, projection is currently only used to show a subset of the
original document in the editor; you want to use it the other way
around: merge two documents into one visual document. Projection does
not currently support this.

What you want is certainly possible, but I don't think projection will
take you very far. Just a guess, though.

-tom
Re: Text Editor Question [message #437336 is a reply to message #437329] Tue, 27 September 2005 14:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Tom,

You're probably correct thinking about it, that a Projection will not do me.
IDocumentInformationMapping looks interesting. You ever seen an example
where it is used ?

Thanks again,
Alan.



"Tom Eicher" <eclipse@tom.eicher.name> wrote in message
news:dhbj7v$kng$1@news.eclipse.org...
> Frank Abercorn wrote:
>> What about using a ProjectionDocument to do it ?
>> This works for Folding so why not what I am talking about ?
>>
>> I had a look at it this morning based on this article
>> http://www.eclipse.org/articles/Article-Folding-in-Eclipse-T ext-Editors/folding.html
>> but so far I have been unable to figure out a way to make it work.
>
> Creating a IDocumentInformationMapping that does this may be possible.
> However, projection is currently only used to show a subset of the
> original document in the editor; you want to use it the other way around:
> merge two documents into one visual document. Projection does not
> currently support this.
>
> What you want is certainly possible, but I don't think projection will
> take you very far. Just a guess, though.
>
> -tom
Re: Text Editor Question [message #437339 is a reply to message #437336] Tue, 27 September 2005 15:22 Go to previous messageGo to next message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
Frank Abercorn wrote:
> IDocumentInformationMapping looks interesting. You ever seen an example
> where it is used ?

Currently the only implementation of the interface in the eclipse SDK is
ProjectionMapping (in the org.eclipse.text project), implementing
projection.

-t
Re: Text Editor Question [message #437438 is a reply to message #437339] Wed, 28 September 2005 11:03 Go to previous message
Eclipse UserFriend
Originally posted by: a.morgan.pilz.ie

Tom,

Thanks again for the help so far.
I reckon IDocumentInformationMapping might work for me.

Just as a test there I added an IDocumentListener to my original document.
On documentAboutToBeChanged I can do the following:
1. Figure out which partition the change is occuring in
2. The offset and length of change.
3. Got a collection of partitions (ITypedRegion) and use these regions to
create two Documents - one for code and one for comments.

So in short I was able to create a code document and a seperate comment
document.
The ability to do this together with an IDocumentInformationMapping may
enough to give me what I need.

I still have a lot to work through but I'm more hopeful than before.

Thanks again


"Tom Eicher" <eclipse@tom.eicher.name> wrote in message
news:dhbo2u$tdi$1@news.eclipse.org...
> Frank Abercorn wrote:
>> IDocumentInformationMapping looks interesting. You ever seen an example
>> where it is used ?
>
> Currently the only implementation of the interface in the eclipse SDK is
> ProjectionMapping (in the org.eclipse.text project), implementing
> projection.
>
> -t
Previous Topic:rcpapplication: creating menu in menubar by plugin?
Next Topic:Editor parts are shared between two different perspectives
Goto Forum:
  


Current Time: Mon Dec 09 04:25:32 GMT 2024

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

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

Back to the top