在Eclipse中获取Checkstyle插件以使用您的自定义检查 [英] Getting the Checkstyle plug-in in Eclipse to use your custom check

查看:446
本文介绍了在Eclipse中获取Checkstyle插件以使用您的自定义检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个自定义检查 MethodLimitCheck.java 。我还有一个自定义配置文件 myconfigurationfile.xml ,其中包含以下内容:

I've written a custom check MethodLimitCheck.java. I also have a custom configuration file myconfigurationfile.xml which contains the following:

module name="Checker">

    <!-- interfaces are limited to 10 methods -->
    <module name="com.mycompany.checks.MethodLimitCheck">
      <property name="tokens" value="INTERFACE_DEF"/>
      <property name="max" value="10"/>
    </module>

    <!-- normal classes are limited to 25 methods -->
    <module name="com.mycompany.checks.MethodLimitCheck">
      <property name="tokens" value="CLASS_DEF"/>
      <property name="max" value="15"/>
    </module>

  </module>
</module>

如何获取checkstyle eclipse插件以使用此自定义检查?如果我在Eclipse - >窗口 - >首选项 - > Checkstyle中引用 myconfigurationfile.xml ,则会显示错误:

How do I get the checkstyle eclipse plugin to use this custom check? If I reference the myconfigurationfile.xml in Eclipse -> window -> preferences -> Checkstyle it displays the error:

cannot initialize module TreeWalker - Unable to instantiate   
com.mycompany.checks.MethodLimitCheck
cannot initialize module TreeWalker - Unable to instantiate       
com.mycompany.checks.MethodLimitCheck

所以插件无法使用我给它的配置文件运行我的自定义检查。我不知道放置配置文件或我写的java检查的位置。程序文件中有三个不同的checkstyle文件夹 - > Eclipse - >插件。

So the plugin is not able to run my custom check using the configuration file that I give it. I don't know where to place the configuration file or the java check that I wrote. There are three different checkstyle folders inside program files -> Eclipse -> plugins.

推荐答案

这很难,恐怕。您需要编写一个小Eclipse插件,用于使检查可用于Eclipse,如在此解释。然后可以将打包的插件JAR放入dropins文件夹。如果你做的一切正常,你可以在Checkstyle选项中选择你的新支票。

This is quite difficult, I'm afraid. You need to write a small Eclipse plugin which is used to make the check available to Eclipse as explained here. The packaged plugin JAR can then be placed into the dropins folder. If you did everything right, you will be able to select your new check in the Checkstyle options.

准备好花费几天时间,或者找到一个已经有编写Eclipse插件的经验。

Be prepared to spend a few days on this though, or find someone who already has experience writing Eclipse plugins.

这篇关于在Eclipse中获取Checkstyle插件以使用您的自定义检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆