Chr*_*way 110 java eclipse suppress-warnings generated-code
我正在使用一个解析器生成器,它创建了一些丑陋的代码.因此,我的Eclipse项目有几十个警告来自生成的源文件.我知道我可以使用@SuppressWarning注释来抑制特定元素中的特定警告,但是当解析器生成器再次运行时,我手动添加的任何注释都将丢失.有没有办法配置Eclipse来禁止特定文件或目录的警告?
Hen*_*ger 90
从版本3.8 M6开始,Eclipse(确切地说:JDT)具有内置功能.它可以通过项目的构建路径进行配置:项目属性> Java构建路径>编译器>源

宣布在这里:Eclipse 3.8和4.2 M6 - 新的和值得注意的,称为选择性地忽略源文件夹中的错误/警告.这也是屏幕截图的来源.这是之前链接的Bug 220928开发的新功能.
Hen*_*ger 20
有一个这样的票,Bug 220928,已经为Eclipse 3.8完成了.有关详细信息,请参阅此答案.
如果您坚持使用Eclipse 3.7或更低版本:用户"Marc"评论该票证在评论35中创建(或至少链接)名为"warningcleaner"的插件.在等待将此功能集成到Eclipse中时,我正在使用它取得了很大的成功.
这真的很简单:

Knu*_*ubo 17
我通过使用maven regexp replace插件解决了这个问题 - 它没有解决原因,但治愈痛苦:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>target/generated-sources/antlr/**/*.java</include>
</includes>
<regex>true</regex>
<regexFlags>
<regexFlag>MULTILINE</regexFlag>
</regexFlags>
<replacements>
<replacement>
<token>^public class</token>
<value>@SuppressWarnings("all") public class</value>
</replacement>
</replacements>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
请注意,我没有设法使**符号起作用,因此您可能必须准确指定路径.
请参阅下面的评论,了解如何不生成重复的@SupressWarnings
| 归档时间: |
|
| 查看次数: |
31933 次 |
| 最近记录: |