0

I am a bit new to eclipse plugin development. My requirement:

I want to show warning signs(like screenshot attached) in the import statements Java files and effective pom files of Java projects based on some parameters.

Assuming eclipse already has some classes and functions for this, I would like to know what dependencies I could add in my Manifest file of my Eclipse Plugin and which class I could extend and functions I could use to implement my requirement?

Any help would be very much appreciated. Thank you.

enter image description here

Ron777
  • 11
  • 1
  • 2
  • Which bit of that image are you asking about? To extend the Java editor there are numerous extension points documented in the Eclipse help in the 'JDT Plug-in Developer Guide' – greg-449 Jan 10 '20 at 08:09
  • Hello Greg. Didn't get your question. Anyway, my requirement is to display the warning icon alongside import statements based on some parameters. And upon hovering over that icon, some text will be displayed which I shall pass as parameter. Could you direct me to the class/functions I should be extending and the dependencies needed for that? I have searching for too long. – Ron777 Jan 10 '20 at 08:34

1 Answers1

0

If you're willing this to happen at same time as compilation, you can add an extension to the org.eclipse.jdt.core.compilationParticipant extension point ( https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_jdt_core_compilationParticipant.html ) and implement the CompilationParticipant.reconcile() method to look at the content of the file and use putProblems() to add problems.

You can also put it in a separate builder ( https://help.eclipse.org/2019-12/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-5.htm ), or resource listener, or document listener, that would invoke file.createMarker(...) to add the error markers.

All that depends on which layer you prefer to hook onto.

Mickael
  • 3,506
  • 1
  • 21
  • 33
  • Hello Mickael. Actually I don't want it to happen at compilation. I want the process to happen on a custom menu option(right click on the project) click. That click would call my service which would return some data. I want that data to be displayed when users hover over that warning sign placed aside import statements. – Ron777 Jan 10 '20 at 09:07
  • I was wondering if there are JDT classes that I could extend to accomplish the task... – Ron777 Jan 10 '20 at 09:38
  • @Ron777 When working with existing editors such as the Java editor you will need to use the extension points provided by that editor. You usually can't just extend classes. This is all pretty complex, you will need a good understanding of how Eclipse editors work in general, the Java editor in particular and how Eclipse JDT represents Java code internally (the 'Abstract Syntax Tree') – greg-449 Jan 11 '20 at 10:38
  • Hello Greg : https://www.cct.lsu.edu/~rguidry/ecl31docs/api/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.html Will this class be any good? I am trying to extend it but I am unable to access it's functions. I am getting a warning "Discouraged access: The type 'CompilationUnitEditor' is not API (restriction on required library org.eclipse.jdt.ui_3.13.51.v20171122-0652.jar) – Ron777 Jan 12 '20 at 07:01