eclipse 一次快速解决许多问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6761639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Quick fix many problems at once
提问by Tiago Veloso
Is it possible to quick fix all errors in a class opened in Eclipse?
是否可以快速修复在 Eclipse 中打开的类中的所有错误?
I have 71 errors that are pretty much the same, I would rather not do it one-by-one.
我有 71 个几乎相同的错误,我宁愿不一一进行。
(Note: I am quick fixing a Java file)
(注意:我正在快速修复 Java 文件)
采纳答案by Ladlestein
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.
通常,您可以批量修复错误。有几种方法。我建议转到您的问题视图,选择其中一个错误,然后按 Ctrl-1(快速修复)。它应该为您提供修复所有文件中所选类型的所有错误的机会。
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.
您也可以将鼠标悬停在文本编辑器中的错误上并等待弹出窗口;它应该说“修复 70 个其他此类错误”。这样做仅适用于特定文件。
回答by Harry Joy
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].
这取决于错误的类型。如果由于缺少导入而导致错误,那么您可以按 解决它CTRL + SHIFT + O
。对于其他错误,您必须一一解决[AFAIK]。
回答by besamelsosu
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.
如果您指定错误类型,您会得到更好的答案。如果错误太相似——希望是相同的——,你总是可以使用查找和替换工具。
回答by Benjamin Tan Wei Hao
As far as I know, there's no way to do this. Sorry!
据我所知,没有办法做到这一点。对不起!
回答by Deepak Azad
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'.
有一些错误/警告可以一次性修复到文件中,例如缺少 NON-NLS 标签。当您将鼠标悬停在错误上时,快速修复列表将显示类似“修复 n 个同类问题”之类的内容。
In other cases you could use a cleanup, e.g. for missing @Override annotation.
在其他情况下,您可以使用清理,例如丢失 @Override 注释。
回答by lauralacarra
All imports fix as CTRL + SHIFT + M
所有导入都修复为 CTRL + SHIFT + M