Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse QuickFix for multiple problems

Tags:

java

eclipse

In Eclipse there is the option to quick fix problems by clicking on one of them, and selecting QuickFix.

It now happens that I have over one hundred entries with the same problem.

'<>' operator is not allowed for source level below 1.7

Because I changed the target level of a project from 1.7 to 1.6

I tried to select all of them in the Problems view and then tried Quick Fix, but it fails with the following error message:

The selected problems do not have a common applicable quick fix.

This message is obviously wrong, as there exists at least one such common quick fix:

Insert inferred type arguments.

Which is the one I would like to use.

My question is: Did I do anything wrong because the QuickFixes could not be applied, or is this a bug in Eclipse?

like image 822
Oliver Hoffmann Avatar asked Jul 17 '13 14:07

Oliver Hoffmann


People also ask

How do I use quick fix in eclipse?

Moving the mouse over the underlined code or the marker will indicate the error. The marker can be selected with the left mouse to activate the Quick Fix pop-up, indicating actions that can be undertaken to repair the error. Alternatively, pressing Ctrl+1 will activate Quick Fix from the keyboard.

How do I fix eclipse problems?

The Quick Fix dialog can also be displayed by right clicking on the error item in the Problems view and selecting the Quick Fix menu item.

How can I see errors in eclipse?

From the main menu, select Window > Show view > Other. Then select General > Error Log. The error log is displayed, showing the following information for each error: The status of the error (for example, error or warning)

Why is Eclipse not opening?

If you've "installed" Eclipse but are having trouble getting it to run, the most likely cause is that you have not correctly specified the JVM for it to run under. You may need to edit the eclipse. ini file. Another common mistake on Microsoft Windows is a mismatch between the "bittedness" of Eclipse and the JVM/JDK.


1 Answers

The problem is that the implementation of the specific Quick Fix has to explicitly support the bulk operation by implementing org.eclipse.ui.views.markers.WorkbenchMarkerResolution and registering using the extension point org.eclipse.ui.ide.markerResolution. The InsertTypeArgumentsOperation unfortunately does not support bulk operations.

If the Quick Fix type supports bulk operations you can go to your Problems view, select one of the errors, and hit Ctrl-1 (quick fix). It should offer you the chance to fix all the errors of the selected type, in all files. You can also hover over the error with the mouse pointer and wait for the tooltip that says "fix xx other errors of this type". That will only fix the error in the specified file.

If the Quick Fix does not support bulk operations you will get the error message you stated:

The selected problems do not have a common applicable quick fix.

In my experience, most of the Quick Fixes I need don't support bulk operations, which can be pretty frustrating to say the least.

In a lot of cases you can fall back to

  • other operations (such as organise imports)
  • refactoring code (such as renaming, extracting, ..)
  • find and replace all, the poor man's refactoring
like image 193
Nick Vanderhoven Avatar answered Nov 15 '22 19:11

Nick Vanderhoven