Eclipse 可以配置为禁用派生源文件的警告吗?
我正在使用 ANTLR 生成 Java 源文件。我可以让 Eclipse 了解生成的文件是派生的,但它仍然向我发出有关无害事物的警告(例如不必要的导入等)。我想将 Eclipse 配置为在显示警告时忽略派生文件。这可能吗?
I am using ANTLR to generate Java source files. I can make Eclipse understand the generated files are derived, but it still gives me warnings about harmless things (e.g. unnecessary imports and so on). I would like to configure Eclipse to ignore derived files when showing warnings. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
恐怕您(在首选项中)看到的就是您得到的。
然而,如果您无论如何都要让 ANTLR 为您生成代码,为什么不更进一步,让您的构建脚本(ant、Maven 等)将该代码包装到 Jar 中呢?将该 Jar 文件设置为 Eclipse 中的依赖项,Eclipse 就不必查看难看的自动生成的代码并对此大发雷霆。
I'm afraid that what you see (in the Preferences) is what you get.
However, if you're going to have ANTLR producing code for you anyway, why not go one step further and have your build script (ant, Maven, ...) wrap that code into a Jar for you? Set up that Jar file as your dependency in Eclipse and Eclipse won't have to look at the ugly auto-generated code and throw a fit about it.
您可以将派生或自动生成的文件放入单独的 Eclipse 项目中,并将特殊的项目属性应用于该“派生文件”项目,例如不显示未使用的导入的警告。
据我所知,同一项目中不同包或源文件夹的不同设置是不可能的。
You could put the derived or autogenerated files into a separate eclipse project and apply special project properties to that 'derived files' project, like to not show Warnings for unused imports.
Different settings in the same project for different packages or source folders are not possible, as far as I know.
这是最近的答案。从 Eclipse 3.8 开始,我们可以忽略特定源文件夹上的警告。
Here's a more recent answer. Since Eclipse 3.8 we can ignore warnings on specific source folders.