Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Adding annotations to the existing Java Editor
Adding annotations to the existing Java Editor [message #754980] Sun, 06 November 2011 10:47 Go to next message
Phil  is currently offline Phil Friend
Messages: 3
Registered: November 2011
Junior Member
I am something of a newbie to the Eclipse programming world. I have played with the tutorials around adding annotations using the annotationModelCreation extension point for editors that I have made myself.

I would like now to add my own annotations to the existing Java Editor. Just to clarify what I mean by that: there is a default java editor for editing *.java files, that already has annotations: problems / search results / breakpoints... I would like to add my own annotations to this.

Eclipse is very nicely decoupled, but this can make it very challenging to work out how it all ties together. Could some one point me to a code sample that does already does this, or simply identify the critical extension points?

Thanks very much.

Phil
Re: Adding annotations to the existing Java Editor [message #755129 is a reply to message #754980] Mon, 07 November 2011 13:28 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 06.11.2011 11:47, Phil wrote:
> I am something of a newbie to the Eclipse programming world. I have
> played with the tutorials around adding annotations using the
> annotationModelCreation extension point for editors that I have made
> myself.
>
> I would like now to add my own annotations to the existing Java
> Editor. Just to clarify what I mean by that: there is a default java
> editor for editing *.java files, that already has annotations:
> problems / search results / breakpoints... I would like to add my own
> annotations to this.
You can search the news archive. This has been answered many times in
the past.

Dani
>
> Eclipse is very nicely decoupled, but this can make it very
> challenging to work out how it all ties together. Could some one point
> me to a code sample that does already does this, or simply identify
> the critical extension points?
>
> Thanks very much.
>
> Phil
Re: Adding annotations to the existing Java Editor [message #755357 is a reply to message #754980] Tue, 08 November 2011 09:01 Go to previous messageGo to next message
Phil  is currently offline Phil Friend
Messages: 3
Registered: November 2011
Junior Member
Edit: I should have added this as an answer to the previous post http : //www.eclipse.org/forums/index.php/t/261603/



I have of course already searched the forums. And google. And stack overflow.

Sadly my search-fu was inadequate.

I have tried the following queries:
* annotation java editor
* extending java editor annotations
* adding my own annotation to the existing java editor
* annotationmodel existing java editor
* java editor annotations
* extending java editor annotation

As the number of queries returned from the search of the forums were quite low, I was able to look at most in some detail (a number wouldn't show just giving me 'loading...')

I am happy to do further leg work, but as is often the case with a massively decoupled system you have to know what keywords to search for.

[Updated on: Tue, 08 November 2011 10:03]

Report message to a moderator

Re: Adding annotations to the existing Java Editor [message #755628 is a reply to message #755357] Wed, 09 November 2011 05:45 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
you need to look for 'eclipse editor annotations' as the annotation
support is not Java editor specific.

As a starting point..
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_editors_annotationTypes.html
Re: Adding annotations to the existing Java Editor [message #755705 is a reply to message #755628] Wed, 09 November 2011 10:47 Go to previous messageGo to next message
Phil  is currently offline Phil Friend
Messages: 3
Registered: November 2011
Junior Member
Thanks!
Re: Adding annotations to the existing Java Editor [message #1063864 is a reply to message #755705] Fri, 14 June 2013 15:01 Go to previous messageGo to next message
katie evans is currently offline katie evansFriend
Messages: 28
Registered: July 2012
Location: brisbane queensland austr...
Junior Member
Hi,
I am struggling with same issue could someone point me to sample code, for an exiting editor.
I need to highlight certain code patterns, when user opens/changes and saves file.
Re: Adding annotations to the existing Java Editor [message #1065410 is a reply to message #1063864] Tue, 25 June 2013 15:33 Go to previous messageGo to next message
Kevin Regan is currently offline Kevin ReganFriend
Messages: 33
Registered: May 2013
Member
I think the trick is that we want to somehow hook into default java editor and modify/add to the "scanner" code that runs when the text in the editor is "damaged" and within that code call "createMarker". I am not yet sure if it is possible to hook into or add new scanners for the built-in Java Editor so that we can add additional rules with which to identify certain patterns in the code and then associate these patters with markers.

Example of the reconciler/damager/scanner stuff can be found here: http://www.linuxtopia.org/online_books/eclipse_documentation/eclipse_platform_plug-in_developer_guide/topic/org.eclipse.platform.doc.isv/guide/eclipse_platform_plugin_editors_highlighting.htm

I just don't know how to hook into the default java editor to modify it's reconciler or if that is even possible. Most of the marker examples I've found are triggered by explicit events instead of based on syntax in the editor.
Re: Adding annotations to the existing Java Editor [message #1065466 is a reply to message #1065410] Tue, 25 June 2013 19:49 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Kevin Regan wrote on Tue, 25 June 2013 17:33

I just don't know how to hook into the default java editor to modify it's reconciler or if that is even possible.


I don't think you want to *modify* the reconciler. Did you see this exension point:
http://help.eclipse.org/topic/org.eclipse.jdt.doc.isv/reference/extension-points/org_eclipse_jdt_core_compilationParticipant.html
Re: Adding annotations to the existing Java Editor [message #1065473 is a reply to message #1065466] Tue, 25 June 2013 20:55 Go to previous messageGo to next message
Kevin Regan is currently offline Kevin ReganFriend
Messages: 33
Registered: May 2013
Member
Well I thought I wanted to modify the editor's SourceViewerConfiguration PresentationReconciler to add new partitions that identify the source code pattern I'm looking for and then add damager/repairer for that partition to "highlight" it. However, I think I need markers which may be a different path since I need to have access to the markers in a separate view in addition to being highlighted within the editor. I'm not really sure how the compilation participant would help me with this really. It's very possible I'm just not understanding though....
Re: Adding annotations to the existing Java Editor [message #1065476 is a reply to message #1065473] Tue, 25 June 2013 21:06 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Maybe I didn't understand the context of your question.
Maybe that's because you jumped on an existing thread that doesn't perfectly match your question? Wink
Re: Adding annotations to the existing Java Editor [message #1065603 is a reply to message #1065476] Wed, 26 June 2013 15:49 Go to previous messageGo to next message
Kevin Regan is currently offline Kevin ReganFriend
Messages: 33
Registered: May 2013
Member
I guess I should have quoted Silvan to make it clear I was replying to him as I have the same issue. However, the topic has to do with making visual modifications to the existing editor which is what I'm trying to do. I do see how the original post specifically mentions annotations specific to problems and therefore see how you got to the compilation extension and actually I will need to get there eventually myself. I also have a completely separate topic in this forum with my specific use case - I'm just getting desperate here because I feel like I'm not getting anywhere at the moment. Thanks for your replies Smile
Re: Adding annotations to the existing Java Editor [message #1065981 is a reply to message #1065476] Fri, 28 June 2013 16:21 Go to previous message
Kevin Regan is currently offline Kevin ReganFriend
Messages: 33
Registered: May 2013
Member
Stephan Herrmann wrote on Tue, 25 June 2013 17:06
Maybe I didn't understand the context of your question.
Maybe that's because you jumped on an existing thread that doesn't perfectly match your question? Wink


Hi, just wanted to follow up and say that you were 100% correct and I was just stuck in the wrong way of thinking about the problem. The compilation unit extension gives me exactly what I need through the reconcile function that you can override and add markers on the fly. Works perfectly. Thanks for putting me on the right path.
Previous Topic:Include my code formatter in the plugin package
Next Topic:"File does not exist" error on Java editor
Goto Forum:
  


Current Time: Fri Mar 29 13:36:31 GMT 2024

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

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

Back to the top