简体   繁体   中英

Eclipse QuickFix for multiple problems

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?

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

I think its a missing thing ( or as they say feature not a bug) in eclipse. I never rely on quickfix to correct code.

My suggestion: It will be better to fix it individually rather then in bulk to avoid any runtime issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM