I am learning Plug-in development and code manipulation using Abstract Syntax Tree and DOM.
I want to code a plug-in which will display a warning (see image) on the left hand side of the Eclipse Java code editor based on some condition in the testing code.
example scenario :
Right now warning message is displayed in eclipse when we do not use any declared variable in Java. I want to display warning message when (Just for example) any variable is assigned value 10 (lets say).
I know how to create Plug-In, Extract variables, expressions and declaration using AST. But I have no idea about how to display warning message.
which API or package is used for it?
Can someone please show me the path for this?
You can achieve the same using eclipse markers (
IMarker
).Refer below link for more details on how to create an eclipse marker.
https://www.eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html
The
MarkerUtilities
class provides methods to create markers easily.You need to add the
org.eclipse.ui.editors
plug-in to the dependencies.For showing the same in editor use
markerAnnotationSpecification
extension point. This is used to define a mapping between markers and editor annotations automatically, with specified formatting.Refer: http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/