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;
}
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?