java 自定义警告,如何在Eclipse中为Java文件添加自定义警告?

I'd like to add a custom warning message (i.e. add an entry to the Warnings section of the Problems tab) for .java files in Eclipse.

While I've found information (here and elsewhere) on creating plugins and using markers, I haven't yet found anything which talks about extending the "problem-finding" process. Most of the articles I've found don't discuss when to create markers, only how, and those that do assume that I'm interested in attaching them to a custom build step or custom editor, neither of which seems appropriate for what I'm trying to do.

How can I create a warning which functions like those available via Window > Preferences > Java > Compiler > Errors/Warnings?

解决方案

I think that a builder might be appropriate for what you want to do. There's a template in the new plugin wizard that creates everything you need for a builder (ex. business logic). Since the builder runs every time the file is modified, you can clear the old warning (code generated for you) and add a new warning (code generated for you) if applicable. This also applies when the file is first created.

You could even look through the code and find hard-coded strings and flag them with warnings if you want.

As for the comments marking translation keys in the code today, those are there to guide NLS tools (you probably already knew that). The idea was to write the code first and then go back later and translate. If a change is made to the code later, the tools can run again and only act on new strings added by the delta.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值