在Eclipse中,如何在加载另一个插件时加载我的插件?

时间:2022-02-10 10:22:55

I want to register to get notified of all Java changes in Eclipse. I can do this by calling JavaCore.addElementChangedListener(). However, I don't want my plugin to be loaded until org.eclipse.jdt.core is loaded. My hack attempt to do this was declare a dummy extension to an org.eclipse.jdt.core extension point, but it doesn't work on all versions of Eclipse. Plus it's ugly. How can I cleanly ensure that my plugin is loaded when another plugin is loaded?

我想注册以获得有关Eclipse中所有Java更改的通知。我可以通过调用JavaCore.addElementChangedListener()来做到这一点。但是,我不希望在加载org.eclipse.jdt.core之前加载我的插件。我的hack尝试这样做是为了向org.eclipse.jdt.core扩展点声明一个虚拟扩展,但它不适用于所有版本的Eclipse。再加上它很难看。如何在加载另一个插件时干净利落地确保我的插件已加载?

1 个解决方案

#1


2  

It turns out there is no built-in way to load my plugin when another plugin is loaded. The most general way to solve the problem is to force my plugin to load on startup and setup a listener for other plugins getting loaded. Then, when jdt.core loads I can add my element changed listener. However, even though it seems theoretically possible I can't figure out how to force my plugin to load on startup. I went with the ugly hack.

事实证明,当加载另一个插件时,没有内置的方法来加载我的插件。解决问题的最常用方法是强制我的插件在启动时加载并设置一个监听器以便其他插件加载。然后,当jdt.core加载时,我可以添加我的元素更改的侦听器。然而,即使理论上似乎有可能我也无法弄清楚如何强制我的插件在启动时加载。我和丑陋的黑客一起去了。

#1


2  

It turns out there is no built-in way to load my plugin when another plugin is loaded. The most general way to solve the problem is to force my plugin to load on startup and setup a listener for other plugins getting loaded. Then, when jdt.core loads I can add my element changed listener. However, even though it seems theoretically possible I can't figure out how to force my plugin to load on startup. I went with the ugly hack.

事实证明,当加载另一个插件时,没有内置的方法来加载我的插件。解决问题的最常用方法是强制我的插件在启动时加载并设置一个监听器以便其他插件加载。然后,当jdt.core加载时,我可以添加我的元素更改的侦听器。然而,即使理论上似乎有可能我也无法弄清楚如何强制我的插件在启动时加载。我和丑陋的黑客一起去了。