Eclipse 3.8 to 4.6 Migration Platform.getPlugin() returns null

我的梦境 提交于 2019-12-12 01:27:59

问题


I have to migrate from Eclipse 3.8 to 4.6. My problem is that in 4.6 (or earlier) Platform.getPlugin() got deprecated and will always return null. Using the Bundles in place of plugins doesn't help me beacuse in that case we will have to break our public API. Do you know if there is a way from the bundle to get the plugin ?

/**
 * As the org.eclipse.core.runtime.compatibility plug-in has been removed in
 * Eclipse 4.6 this method is not supported anymore.
 *
 */
@Deprecated
public static Plugin getPlugin(String id) {
    return null;
}

回答1:


The question I have to ask is what were you using it for, and then point out that while Platform#getPlugin(String) is deprecated, Plugin itself is not. If your Bundle-Activator class extends Plugin, just have it save a reference to itself in its constructor, ala http://git.eclipse.org/c/sourceediting/webtools.sourceediting.git/tree/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/JSPCorePlugin.java#n54 . Then it's just a matter of accessing it when you need it.



来源:https://stackoverflow.com/questions/41747468/eclipse-3-8-to-4-6-migration-platform-getplugin-returns-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!