Eclipse Plug-in : Displaying warning message in Eclipse using AST , DOM - eclipse

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/

Related

How to persists image use for Eclipse Decorator

I'm creating a custom image decorator which will decorate project/file explore according to the several logic. For a example lets take Findbugs plugin it will scan the project and decorate project/files image which are having errors, even Eclipse IDE restarts it will maintain the FindBug image status of the project/file. Like that how can I maintain the persit state of the image decorator even Eclipse IDE restarted?
Is there any good tutorials for that? I found following link for decorators
https://www.eclipse.org/articles/Article-Decorators/decorators.html
Cheers!
There is no standard mechanism for persisting data for decorators.
Things like FindBugs are most likely using Markers defined using the org.eclipse.core.resources.markers extension point and created using the IResource.createMarker API. Markers are persisted.
Views such as Project Explorer have a standard decorator which shows decorations for markers which extend the org.eclipse.core.resources.problemmarker marker.

Need brief understanding on how eclipse autocomplete works

Hi I am interested in understanding how eclipse autocomplete works. I want to understand how eclipse distinguishes between local and global variables in a piece of Java code. I would also like to understand how eclipse stores method signatures for an infinite number of classes and how it associates a method to a given class. And is it possible for one person to develop an autocomplete feature for a language like JavaScript.
There is already an AutoComplete feature for Javascript. You just need to let Eclipse install the appropriate extensions.
Eclipse maintains a model of your program, including the project and all the dependencies. It's big, but it's not infinite. When you hit the dot, it figures out based on the variable type what the target type can be, and then displays the relevant methods based on its internal model.
This is easy for Java because you can usually know the static type. Much harder in other languages.
The Eclipse plug-in developer's guide discusses how different things, including the internal model and auto completion works. There are extension points to implement yiur own.

Customizing UI elements in Eclipse default Java Editor via plugin

I'm trying to develop a plugin for Eclipse that will allow me to modify various elements within the default java text editor. I've found lots of tutorials for creating my own text editor for a different language, but nothing for editing the default java editor. Specifically, I want to be able to run a command and highlight certain areas of the code based on a different program. How do I develop this?
Thanks
You will need to implement your own type of markers and maybe associate annotations with them. Then you can associate the java editor with the annotations to show them. Your application will generate the markers.
Specifically you might want to start to read about org.eclipse.core.resources.marker extension point and IResource.createMarker() to create the markers.
Its doable. You need to find the right extension point that allows you to add functionality to the java editor.
See IBM tutorial. The example with the heading "How do you analyze Java code to apply modifications" seems to be what you want to do.

Eclipse doclet plugin

I'm looking for an Eclipse javadoc doclet plugin that modifies the standard built in javadoc generation process. In other words, I would like to specify custom tags and maybe use wiki syntax or whatever in a normal javadoc comment and have the generated output show up in those popups that appear when hovering over a method or a class identifier.
To be clear, I am not looking for a way to specify a doclet when explicitly generating external javadoc.
It seems that Eclipse uses some internal mechanism to generate the popup javadoc and in the past hour of googling I wasn't able to find a plugin that modifies that behaviour.
Any ideas or pointers? Thanks!

Add functionality to all Eclipse TextEditors

I need to add some functionality to eclipse text editors. The goal is to get a Graphics Context or add a SWT Canvas to any and all Eclipse AbstractTextEditors and package these modifications within a plug-in (so by installing the plugin I provide, the editor modification will work for the Java Editor, XML Editor, plain text editor, etc.). Are there any extension points that would suffice for this purpose, or is my best bet with a fragment? Any help is appreciated.
I would recommend looking at the source code for AbstractTextEditor to see if an extension point exists for this purpose. If an extension point exists, it will be evident in that class source.
I would wager that such extension point does not exist. You are left with opening an enhancement request and in the meantime patching the plugin containing AbstractTextEditor plugin to alter the source of that file. A fragment isn't going to do the trick. Another alternative to consider is to learn and apply a bytecode weaving framework such as AspectJ (http://eclipse.org/ajdt/).