展开全部
1. 从版本3.8 M6开始,Eclipse的(准确的说:JDT的)有内置32313133353236313431303231363533e58685e5aeb931333337613262的函数,这。它是可配置的,通过一个项目的构建路径:项目属性> Java构建路径>编译器>来源 在这里宣布:Eclipse的3.8和4.2的M6-新的和值得注意的是,所谓的选择性忽略源文件夹中的错误/警告。这也是那里的截图是从。这是链接错误220928开发新的函数。
2. 有这个一票,臭虫220928,具有自为Eclipse 3.8。请参考这个答案的细节。 上创建(或至少指向)一个名为“warningcleaner”在35插件票“马克”:如果你坚持使用Eclipse 3.7或更低。我认为有很多在等待这个函数被集成到Eclipse中。 这真的很简单: 安装插件。 右键单击项目并选择“添加/删除生成的代码自然”。 打开项目设置(右键单击并选择“属性”)。 打开选项卡“警告清洁'。 选择您想从忽略警告的源文件夹。
3. 我解决了这个maven的正则表达式替换插件-它并没有解决 CodeGo.net,但治愈的痛苦:
com.google.code.maven-replacer-plugin
maven-replacer-plugin
1.3.2
prepare-package
replace
target/generated-sources/antlr/**/*.java
true
MULTILINE
^public class
@SuppressWarnings("all") public class
请注意,我没能拿到**符号来工作,所以你可能需要准确地指定路径。 参见下面的如何不产生重复@SupressWarnings
4. 我认为最好的你能做的就是使项目的具体设置用于显示警告。 窗口->设定-> Java的->编译器->错误/警告 在窗体的顶部是一个链接,用于配置项目的具体设置。
5. 网友@乔恩暗示ant代码来做到这一点。下面是我的Adding @SuppressWarnings("all") to ANTLR generated parser/lexer *.java
in ${project.build.directory}/generated-sources/antlr/
summary="true"
includes="**/*.java"
token="public class"
value='@SuppressWarnings("all") public class' />
需要注意的是Ant的中并没有文本的正则表达式 所以它的令牌相匹配行的开始如maven的正则表达式替换插件一样。 我跑了Antlr从Maven的antrun-插件在我的Maven POM,ANTLR的maven插件没有用的Cobertura Maven插件踢好我这样做的。 (我知道这不是一个答案,原来的问题,但我不能在一个格式化的Ant代码到另一个答案,只在一个答案)
6. 我不认为Eclipse的本质提供了一种在目录级做到这一点(但我不知道)。 你可以有生成的文件去到一个单独的Java项目,并控制该特定项目的警告。 我一般喜欢把自动生成的代码在一个单独的项目呢。
7. 您只能抑制警告在项目级别。但是,您可以配置你的问题选项卡从文件或软件包抑制警告。进入配置,并与“关于工作组:”工作范围。
8. 我做这几个ANTLR的语法,它生成一个Javaant。 Ant构建脚本添加@SuppressWarnings("all")一个Java文件,并@Override到另一个。 我可以看看它是如何准确地做,如果你有兴趣。
9. 在ANTLR 2的情况下,有可能通过appenidng抑制在生成的代码中的警告@SuppressWarnings在类声明中的语法文件之前,例如:{@SuppressWarnings("all")} class MyBaseParser extends Parser;
10. 这可以通过从构建路径中排除特定的目录来完成(下面的例子就是Eclipse 3.5) [1]调出Java构建路径 点击projectin包资源管理器 右击,属性 选择Java Build Path [2]将目录添加到排除 来源标签应包含项目源文件夹的详细信息 展开源文件夹,并找到了“排除:'属性 选择“排除:”,然后单击编辑 添加文件夹到添加/添加多个选项 单击Finish(完成),然后确定为Eclipse重建。
11. 该M2E生成这个小python脚本“补丁”.classpath文件并添加所需的XML标记开始与所有的源文件夹target/generated-sources。你可以从你的项目的根文件夹中运行它。你需要重新运行它时,在Eclipse从M2E重新生成。和所有风险自负,;-)#!/usr/bin/env python
from xml.dom.minidom import parse
import glob
import os
print('Reading .classpath files...')
for root, dirs, files in os.walk('.'):
for name in files:
if (name == '.classpath'):
classpathFile = os.path.join(root, name)
print('Patching file:' + classpathFile)
classpathDOM = parse(classpathFile)
classPathEntries = classpathDOM.getElementsByTagName('classpathentry')
for classPathEntry in classPathEntries:
if classPathEntry.attributes["path"].value.startswith('target/generated-sources'):
# ensure that the tag exists
attributesNode = None;
for attributes in classPathEntry.childNodes:
if (attributes.nodeName == 'attributes'):
attributesNode = attributes
if (attributesNode == None):
attributesNode = classpathDOM.createElement('attributes')
classPathEntry.appendChild(attributesNode)
# search if the 'ignore_optional_problems' entry exists
hasBeenSet = 0
for node in attributesNode.childNodes:
if (node.nodeName == 'attribute' and node.getAttribute('name') == 'ignore_optional_problems'):
# it exists, make sure its value is true
node.setAttribute('value','true')
#print(node.getAttribute('name'))
hasBeenSet = 1
if (not(hasBeenSet)):
# it does not exist, add it
x = classpathDOM.createElement("attribute")
x.setAttribute('name','ignore_optional_problems')
x.setAttribute('value','true')
attributesNode.appendChild(x)
try:
f = open(classpathFile, "w")
classpathDOM.writexml(f)
print('Writing file:' + classpathFile)
finally:
f.close()
print('Done.')
已赞过
已踩过<
你对这个回答的评价是?
评论
收起