41

Is it possible to quick fix all errors in a class opened in Eclipse?

I have 71 errors that are pretty much the same, I would rather not do it one-by-one.

(Note: I am quick fixing a Java file)

Lii
  • 11,553
  • 8
  • 64
  • 88
Tiago Veloso
  • 8,513
  • 17
  • 64
  • 85

6 Answers6

26

Often, you can fix errors en masse. There are several ways. I recommend going to your Problems view, selecting one of the errors, and hitting 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 mouse over the error in the text editor and wait for a popup; it should say "fix 70 other errors of this type". Doing it this way applies only to the specific file.

Ladlestein
  • 6,100
  • 2
  • 37
  • 49
  • 8
    Did they take out the "Fix 70 other errors of this type" function. I stumbled upon this answer and was super excited but I don't see it. The Markers show the errors and we can fix that too, but it doesn't work because it limits us to 100 errors and there are 2600 of 'em! (doing a little refactoring....) – Peter Turner Oct 21 '14 at 15:25
  • Not sure about that feature disappearing. As for the limit, can you modify the view to show more than 100 errors? – Ladlestein Oct 25 '14 at 01:59
  • yeah, found it eventually! – Peter Turner Oct 25 '14 at 18:09
  • 1
    @PeterTurner Where is it? I'm trying to do the same thing. – Joehot200 May 04 '15 at 06:44
  • 10
    I used to have "fix N other errors" as well. After my upgrade to Luna it's gone. In the Problems view I can select two identical error messages for instance `nnn cannot be resolved or is not a field` (need to change to getter). Two identical errors for the same variable in the same source, if I select both and quick-fix it tells me `the selected problems do not have a common applicable quick fix` ??? – geert3 Jun 23 '15 at 07:26
17

It depends on type of errors.If error are there because of missing imports then you can solve it by pressing CTRL + SHIFT + O. For other errors you have to solve one by one [AFAIK].

Harry Joy
  • 58,650
  • 30
  • 162
  • 207
1

As far as I know, there's no way to do this. Sorry!

Benjamin Tan Wei Hao
  • 9,621
  • 3
  • 30
  • 56
1

You would get better answers if you would specify the error type. And if errors are too similar -hopefully identical-, you can always use find&replace tool.

besamelsosu
  • 461
  • 3
  • 11
  • For what it helps you: `The constructor BinaryContractInfo(VarInfo, VarInfo, Class, Object, Object, String) is undefined DaikonConversionUtils.java` – Tiago Veloso Jul 20 '11 at 12:19
  • I'm guessing problem is caused by either number of or types of parameters is not matching. In that case unless you are going to construct with same parameters all the time -which is unlikely-, you have to go through them one by one. This can only be made easier with methods mentioned in Ladlestein's answers, if that's not the exact answer you need. – besamelsosu Jul 21 '11 at 09:09
0

All imports fix as CTRL + SHIFT + M

lauralacarra
  • 580
  • 7
  • 10
0

There are certain errors/warnings which you can fix in one go in a file e.g. missing NON-NLS tags. When you hover on an error, the quick fix list will show something like 'Fix n problems of same kind'.

In other cases you could use a cleanup, e.g. for missing @Override annotation.

Deepak Azad
  • 7,903
  • 2
  • 34
  • 49