生成与用户定义的注释编译器警告 [英] Generate compiler warning with user defined annotation
问题描述
是否有可能使编译器生成一个警告,当它遇到一个用户定义的annotaion?类似 @德precated
标注的东西吗?
Is it possible for make the compiler generate a warning when it encounters a user defined annotaion? Something similar to the @Deprecated
annotation?
感谢
推荐答案
根据你原来的问题和意见,我想你要做到以下几点:
Based on your original question and comments, I assume you're trying to do the following:
- 标记code作为完整的(用编译器警告),所以其他开发商不使用它。
- 标识不全code在你的IDE在稍后的时间点。
我不相信你可以标记code与编译器警告。 pcated的 @德$ P $
标签烘焙到编译器。表示方法的更常见的方式是不完全是抛出一个异常:
I don't believe you can mark the code with a compiler warning. The @Deprecated
tag is baked into the compiler. A more common way of indicating a method is incomplete is by throwing an exception:
抛出新UnsupportedOperationException异常(尚未实现);
效果不实现,直到运行,但其他开发商的应的进行单元测试他们的code。
The effect isn't realized until runtime, but the other developers should be unit testing their code.
作为识别不完整的code我还是指回到我原来的评论。使用 TODO
注释标记和Eclipse将建立一个任务列表为您服务。如果您的列表与尚未清理自动生成的code杂乱,您可以使用 FIXME
, XXX
,也可以定义自己。然后,您应该能够过滤列表中。
As for identifying the incomplete code I would still refer back to my original comment. Use the TODO
comment tag and Eclipse will build a task list for you. If your list is cluttered with auto-generated code that hasn't been cleaned up, you can use FIXME
, XXX
, or define your own. You should then be able to filter your list.
这篇关于生成与用户定义的注释编译器警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!