如何确定要使用的Eclipse依赖项 [英] How to determine which eclipse dependencies to use

查看:115
本文介绍了如何确定要使用的Eclipse依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Eclipse PDE中,当我从互联网上复制一个片段并且缺少依赖关系时,如何确定需要导入哪些依赖关系?
说我有以下代码段:

In the eclipse PDE, when I copy a snippet from the internet and I'm lacking dependencies, how do I figure out which dependencies I need to import? Say that I have this snippet:

public static IMethod getSelectedMethod() throws JavaModelException {
    IWorkbenchPage page = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow().getActivePage();
    ITextEditor editor = (ITextEditor) page.getActiveEditor();
    IJavaElement elem = JavaUI.getEditorInputJavaElement(editor
            .getEditorInput());
    if (elem instanceof ICompilationUnit) {
        ITextSelection sel = (ITextSelection) editor.getSelectionProvider()
                .getSelection();
        IJavaElement selected = ((ICompilationUnit) elem).getElementAt(sel
                .getOffset());
        if (selected != null
                && selected.getElementType() == IJavaElement.METHOD) {
            return (IMethod) selected;
        }
    }

    return null;
}

我在IMethod,JavaModelException,IJavaElement,JavaUI,ICompulationUnit, IJavaElement和IMethod。我碰巧从头开始知道我需要依赖项 org.eclipse.jdt.core org.eclipse.jdt.ui 。但是说我不知道​​我需要这些。我该如何找出正确的依赖项?

And I get syntax errors on IMethod, JavaModelException, IJavaElement, JavaUI, ICompulationUnit, IJavaElement and IMethod. I happen to know from the top of my head that I need the dependencies org.eclipse.jdt.core and org.eclipse.jdt.ui. But say that I didn't know that I needed these. How could I figure out what the right dependencies are?

推荐答案

最简单的方法是仅使用打开类型对话框打开您缺少的类型,然后使用上下文菜单中的显示在>包资源管理器中选项。这应该向您显示该类在外部插件中的Eclipse插件项目中的位置。

The simplest way is to just use the 'Open Type' dialog to open the type you are missing and then use the 'Show In > Package Explorer' option in the context menu. This should show you the location of the class in an Eclipse plugin project in the 'External Plug-ins'.

要使其正常运行,您需要具有Eclipse源代码已安装(已从您的发行版的 Eclipse项目更新站点的安装新软件中安装 Eclipse SDK(例如 http://download.eclipse.org/eclipse/updates/4.9 for 2018-09)。某些Eclipse下载可能已经安装了此程序。

To make this work well you need to have the Eclipse source installed (install the 'Eclipse SDK' in Install New Software from the 'Eclipse Project Updates' site for your release (for example http://download.eclipse.org/eclipse/updates/4.9 for 2018-09). Some Eclipse downloads may already have this installed.

要使 Open Type包括Eclipse插件,请选择 Include all plug偏好设置的插件开发页面中的从Java搜索中的目标输入插件选项。

To make 'Open Type' include the Eclipse plugins select the 'Include all plug-ins from target in Java search' option in the 'Plug-in Development' page of the Preferences.

这篇关于如何确定要使用的Eclipse依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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