Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » working with text positions
working with text positions [message #336830] Mon, 06 July 2009 11:32 Go to next message
Christoph Höger is currently offline Christoph HögerFriend
Messages: 40
Registered: July 2009
Member
Hi,

for the next big features in my plugin (e.g. hover support, semantic
syntax highlighting), I need to add properties (e.g. "this is identifier
foo which maps to this AST node") to my editors content.

Is there any API for that already in eclipse? Any articles you could
point me to? Or do I have to do that all by myself?

thanks,

christoph
Re: working with text positions [message #336842 is a reply to message #336830] Tue, 07 July 2009 11:01 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Christoph Höger wrote:
> Hi,
>
> for the next big features in my plugin (e.g. hover support, semantic
> syntax highlighting), I need to add properties (e.g. "this is
> identifier foo which maps to this AST node") to my editors content.
>
> Is there any API for that already in eclipse?
In JDT we did not annotate the document but rather compute the visual
information (e.g. syntax highlighting out of the Java model. If you
don't want to do that you could use
org.eclipse.jface.text.source.Annotation.

Dani
> Any articles you could point me to? Or do I have to do that all by
> myself?
>
> thanks,
>
> christoph
Re: working with text positions [message #336925 is a reply to message #336842] Tue, 14 July 2009 11:07 Go to previous messageGo to next message
Christoph Höger is currently offline Christoph HögerFriend
Messages: 40
Registered: July 2009
Member
Am 07.07.2009 13:01, schrieb Daniel Megert:
> Christoph Höger wrote:
>> Hi,
>>
>> for the next big features in my plugin (e.g. hover support, semantic
>> syntax highlighting), I need to add properties (e.g. "this is
>> identifier foo which maps to this AST node") to my editors content.
>>
>> Is there any API for that already in eclipse?
> In JDT we did not annotate the document but rather compute the visual
> information (e.g. syntax highlighting out of the Java model.

That sounds interesting. So after each reconciling you do some
repainting? How is that done?
Re: working with text positions [message #336926 is a reply to message #336925] Tue, 14 July 2009 11:14 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Christoph Höger wrote:
> Am 07.07.2009 13:01, schrieb Daniel Megert:
>> Christoph Höger wrote:
>>> Hi,
>>>
>>> for the next big features in my plugin (e.g. hover support, semantic
>>> syntax highlighting), I need to add properties (e.g. "this is
>>> identifier foo which maps to this AST node") to my editors content.
>>>
>>> Is there any API for that already in eclipse?
>> In JDT we did not annotate the document but rather compute the visual
>> information (e.g. syntax highlighting out of the Java model.
>
> That sounds interesting. So after each reconciling you do some
> repainting? How is that done?
Take a look at org.eclipse.jface.text.presentation.IPresentationReconciler.

Dani
Re: working with text positions [message #336927 is a reply to message #336926] Tue, 14 July 2009 12:01 Go to previous messageGo to next message
Christoph Höger is currently offline Christoph HögerFriend
Messages: 40
Registered: July 2009
Member
> Take a look at org.eclipse.jface.text.presentation.IPresentationReconciler.

So all I have to do is create some TextPresentation objects and invoke
changeTextPresentation()? Are those presentations persistent during
non-reconciling changes (aka: do they shift if I insert text, so I can
use my incremental parser to take care of changed nodes or do I have to
reapply all presentations)?
Re: working with text positions [message #336928 is a reply to message #336927] Tue, 14 July 2009 12:16 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Christoph Höger wrote:
>> Take a look at
>> org.eclipse.jface.text.presentation.IPresentationReconciler.
>
> So all I have to do is create some TextPresentation objects and invoke
> changeTextPresentation()?
It would probably be simpler to use the default presentation reconciler
along with a org.eclipse.jface.text.rules.DefaultDamagerRepairer.
> Are those presentations persistent during non-reconciling changes
> (aka: do they shift if I insert text, so I can use my incremental
> parser to take care of changed nodes or do I have to reapply all
> presentations)?
By default the presentation will be redone but that doesn't mean you
have to rebuild/update your model. Normally, updating the model is done
by an org.eclipse.jface.text.reconciler.IReconciler because often
updating the model is much more expensive than using a scanner for
syntax coloring.

This might help to clarify things:
http://www.eclipse.org/eclipse/platform-text/eclipseCon/2006 /texteditorrecipes.pdf

Dani
>
>
>
>
Re: working with text positions [message #336930 is a reply to message #336928] Tue, 14 July 2009 13:53 Go to previous messageGo to next message
Christoph Höger is currently offline Christoph HögerFriend
Messages: 40
Registered: July 2009
Member
Huh, now I am confused.
Does jdt use a own PresentationReconciler for semantic highlighting (the
stuff that cannot be done using the simple rules, e.g. identifiers)?
If so, how do you make sure it's invoked only after model reconciling?

thanks,

christoph
Re: working with text positions [message #336933 is a reply to message #336930] Tue, 14 July 2009 15:39 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Christoph Höger wrote:
> Huh, now I am confused.
> Does jdt use a own PresentationReconciler for semantic highlighting
> (the stuff that cannot be done using the simple rules, e.g. identifiers)?
The PresentationReconciler is for syntax highlighting which is done on
typing and hence needs to be fast. Semantic coloring is done after the
model has been computed.
> If so, how do you make sure it's invoked only after model reconciling?
With a listener
(org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrate gy.reconciled())

Dani
>
> thanks,
>
> christoph
Previous Topic:Problem view grouped by type by default
Next Topic:how to display multiple instances of same form?
Goto Forum:
  


Current Time: Tue Apr 23 09:00:53 GMT 2024

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

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

Back to the top