/** * Finds and returns the Java elements for the given editor selection. * * @param editor the Java editor * @param selection the text selection * @return the Java elements for the given editor selection * @throws JavaModelException if accessing the type root fails */ public static IJavaElement[] codeResolve(JavaEditor editor, ITextSelection selection) throws JavaModelException { return codeResolve(getInput(editor), selection); }
/** * Finds and returns the Java elements for the given editor selection. * * @param editor the Java editor * @param selection the text selection * @return the Java elements for the given editor selection * @throws JavaModelException */ public static IJavaElement[] codeResolve(JavaEditor editor, ITextSelection selection) throws JavaModelException { return codeResolve(getInput(editor), selection); }
/** * Finds and returns the Java elements for the given editor selection. * * @param editor the Java editor * @param selection the text selection * @return the Java elements for the given editor selection * @throws JavaModelException if accessing the type root fails */ public static IJavaElement[] codeResolve(JavaEditor editor, ITextSelection selection) throws JavaModelException { return codeResolve(getInput(editor), selection); }
/** * Finds and returns the Java element selected in the given part. * * @param part the workbench part for which to find the selected Java element * @param selection the selection * @return the selected Java element */ protected IJavaElement findSelectedJavaElement(IWorkbenchPart part, ISelection selection) { Object element; try { if (part instanceof JavaEditor && selection instanceof ITextSelection) { IJavaElement[] elements= TextSelectionConverter.codeResolve((JavaEditor)part, (ITextSelection)selection); if (elements != null && elements.length > 0) return elements[0]; else return null; } else if (selection instanceof IStructuredSelection) { element= SelectionUtil.getSingleElement(selection); } else { return null; } } catch (JavaModelException e) { return null; } return findJavaElement(element); }
if (part instanceof JavaEditor && selection instanceof ITextSelection) { JavaEditor editor = (JavaEditor)part; IJavaElement[] elements= TextSelectionConverter.codeResolve(editor, (ITextSelection)selection); if (elements != null && elements.length > 0) { return elements[0];
if (part instanceof JavaEditor && selection instanceof ITextSelection) { JavaEditor editor = (JavaEditor)part; IJavaElement[] elements= TextSelectionConverter.codeResolve(editor, (ITextSelection)selection); if (elements != null && elements.length > 0) { return elements[0];