Skip to main content

How call Eclipse Quick Fix programmatically

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2014-06-30

I am writing an eclipse pulugin to use eclipse quick fix. My aim is to print list of all suggestions
proposed by eclipse quick fix in order to fix compiler errors in an active project. Note that I do not
want to fix compiler errors. In fact, I only want to print compiler errors with their eclipse quick fix
suggestions. For example, if the error is "Dublicate Method", then my program only prints the suggestion
that is "Rename the method".

To do that I extend "org.eclipse.jdt.ui.quickFixProcessors" and also extend class "QuickFixProcessor" class.
In addition, I add below code to new defined class to print proposed correction.

public class MyQuickFixProcessor extends QuickFixProcessor {

public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException {

IJavaCompletionProposal[] corrections = super.getCorrections(context, locations)
for (IJavaCompletionProposal correction : corrections) {

The code works fine and it prints quick fix suggestions when I move mouse on a compiler error in the editor.

However, I want to know how can I call quick fix programmatically without moving mouse on the compiler error?
In fact, call quick fix for all compiler errors programmatically. Note that I have the compiler error and all
its detailed information such as its location.