如何在 eclipse checkstyle 插件中使用我自己的自定义 checkstyle 检查

问题描述 投票:0回答:1

我想要自己的检查“检查类 X 的方法标识符不超过 18 个字符”。我希望 Eclipse 在 IDE 中将违反我的自定义规则的行为显示为警告或错误。

但是我似乎无法再安装自定义 Eclipse 插件了...

我首先检查了 net.sf.eclipsecs.sample 项目,该项目使用 eclipse 扩展点“net.sf.eclipsecs.core.checkstyleAddonProvider”,以便它可以为 eclipse checkstyle 插件提供检查。

在不更改任何内容的情况下,我将其导出为deployabe插件,并将生成的jar放入我的eclipse的dropins文件夹中。该插件工作了,我在 eclipse checkstyle 插件首选项页面的 UI 中看到了 MethodLimitCheck (来自示例项目)。

但是我想让自己的规则处于活动状态,因此我决定添加自己的 AbstractCheck 子类并对配置文件进行必要的更改。但一切都没有改变。我决定删除已安装的插件并再次安装新的导出,从那时起我无法再安装任何自定义检查。我将示例项目恢复到原始状态并尝试再次安装,但在 eclipse checkstyle 插件的 UI 中看不到任何变化。

如何调试为什么 eclipse 不再安装我的插件?我在错误日志或 /.metadata/.log 中看不到任何内容

当我尝试通过 osgi 主机控制台通过“install file:///plugin.jar”和“start”安装插件时,它的状态为“ACTIVE”,但我想一旦加载它就无法更改 UI 。我总是使用“-clean -debug”启动 Eclipse,并在 .options 文件中设置调试选项

[p2] Fri Mar 22 11:09:41 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] Adding IU: net.sf.eclipsecs.sample 10.14.1.202403211910-unmodified
[p2] Fri Mar 22 11:09:41 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] Adding IU property: net.sf.eclipsecs.sample 10.14.1.202403211910-unmodified->{org.eclipse.equinox.p2.type.lock=1, org.eclipse.equinox.p2.internal.inclusion.rules=OPTIONAL, org.eclipse.equinox.p2.reconciler.dropins=true}
[p2] Fri Mar 22 11:09:41 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] No installable units to remove.
[p2] Fri Mar 22 11:09:41 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] No IU properties to remove.
[p2] Fri Mar 22 11:09:41 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] No installable units to move.
[p2] Fri Mar 22 11:09:41 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] No extra requirements.
[p2] Fri Mar 22 11:09:42 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] [plan] [R]net.sf.eclipsecs.sample 10.14.1.202403212020 will be removed
[p2] Fri Mar 22 11:09:42 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] [plan] [R]net.sf.eclipsecs.sample 10.14.1.202403212020 will be added
[p2] Fri Mar 22 11:09:42 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] [plan] Some units will not be installed, because they are already installed or there are dependency issues:
[p2] Fri Mar 22 11:09:42 CET 2024 - [Start Level: Equinox Container: 35fb4e67-0f72-47e8-81fe-24cd62603c7f] [reconciler] [plan] net.sf.eclipsecs.sample 10.14.1.202403211910-unmodified

帮助,编写自定义检查不应该这么难:(

日食 2024-03 (4.31.0) Eclipse Checkstyle 项目 10.14.1.202403151842(通过 Marketplace 安装) Mac 操作系统 14.4

eclipse eclipse-plugin checkstyle
1个回答
0
投票

我感谢您的工作并为我们寻找解决方案。我很高兴您提供此类信息。谢谢

© www.soinside.com 2019 - 2024. All rights reserved.