private IJavaElement elementAtOffset() { try { return SelectionConverter.getElementAtOffset(fEditor); } catch(JavaModelException e) { } return null; }
private IMember getSelectedMemberFromEditor() throws JavaModelException{ IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null || ! (element instanceof IMember)) return null; return (IMember)element; } }
private IJavaElement elementAtOffset() { try { return SelectionConverter.getElementAtOffset(fEditor); } catch(JavaModelException e) { } return null; }
private static IMethod getMethod(ICompilationUnit cu, ITextSelection selection) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(cu, selection); if (element instanceof IMethod) return (IMethod) element; return null; } }
private static IMethod getMethod(ICompilationUnit cu, ITextSelection selection) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(cu, selection); if (element instanceof IMethod) return (IMethod) element; return null; } }
private IMember getSelectedMemberFromEditor() throws JavaModelException{ IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null || ! (element instanceof IMember)) return null; return (IMember)element; } }
private IJavaElement elementAtOffset() { try { return SelectionConverter.getElementAtOffset(fEditor); } catch(JavaModelException e) { } return null; }
/** * Returns the element surrounding the selection of the given editor. * * @param editor the editor * @return the element surrounding the current selection (only from primary working copies), or <code>null</code> if none * @throws JavaModelException if the Java type root does not exist or if an exception occurs * while accessing its corresponding resource */ public static IJavaElement getElementAtOffset(JavaEditor editor) throws JavaModelException { return getElementAtOffset(editor, true); }
/** * Returns the element surrounding the selection of the given editor. * * @param editor the editor * @return the element surrounding the current selection (only from primary working copies), or <code>null</code> if none * @throws JavaModelException if the Java type root does not exist or if an exception occurs * while accessing its corresponding resource */ public static IJavaElement getElementAtOffset(JavaEditor editor) throws JavaModelException { return getElementAtOffset(editor, true); }
private IMember getSelectedMemberFromEditor() throws JavaModelException{ IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null || ! (element instanceof IMember)) return null; return (IMember)element; } }
private boolean tryMoveInstanceMethod(ITextSelection selection) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null || !(element instanceof IMethod)) return false; IMethod method= (IMethod) element; if (!RefactoringAvailabilityTester.isMoveMethodAvailable(method)) return false; fMoveInstanceMethodAction.run(selection); return true; }
private boolean tryMoveStaticMembers(ITextSelection selection) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null || !(element instanceof IMember)) return false; IMember[] array= new IMember[] { (IMember) element}; if (!RefactoringAvailabilityTester.isMoveStaticMembersAvailable(array)) return false; fMoveStaticMembersAction.run(selection); return true; }
private boolean tryMoveStaticMembers(ITextSelection selection) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null || !(element instanceof IMember)) return false; IMember[] array= new IMember[] { (IMember) element}; if (!RefactoringAvailabilityTester.isMoveStaticMembersAvailable(array)) return false; fMoveStaticMembersAction.run(selection); return true; }
private boolean tryMoveStaticMembers(ITextSelection selection) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null || !(element instanceof IMember)) return false; IMember[] array= new IMember[] { (IMember) element}; if (!RefactoringAvailabilityTester.isMoveStaticMembersAvailable(array)) return false; fMoveStaticMembersAction.run(selection); return true; }
public static IType getTypeAtOffset(JavaEditor editor) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(editor); IType type= (IType)element.getAncestor(IJavaElement.TYPE); if (type == null) { ICompilationUnit unit= SelectionConverter.getInputAsCompilationUnit(editor); if (unit != null) type= unit.findPrimaryType(); } return type; }
/** * @param primaryOnly if <code>true</code> only primary working copies will be returned * @since 3.2 */ private static IJavaElement getElementAtOffset(JavaEditor editor, boolean primaryOnly) throws JavaModelException { return getElementAtOffset(getInput(editor, primaryOnly), (ITextSelection)editor.getSelectionProvider().getSelection()); }
public static IType getTypeAtOffset(JavaEditor editor) throws JavaModelException { IJavaElement element= SelectionConverter.getElementAtOffset(editor); IType type= (IType)element.getAncestor(IJavaElement.TYPE); if (type == null) { ICompilationUnit unit= SelectionConverter.getInputAsCompilationUnit(editor); if (unit != null) type= unit.findPrimaryType(); } return type; }
private boolean tryReorgMove(ITextSelection selection) throws JavaModelException{ IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element == null) return false; StructuredSelection mockStructuredSelection= new StructuredSelection(element); fReorgMoveAction.selectionChanged(mockStructuredSelection); if (!fReorgMoveAction.isEnabled()) return false; fReorgMoveAction.run(mockStructuredSelection); return true; }
public void run(ITextSelection selection) { try { IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element != null) run(element); } catch (JavaModelException e) { JavaPlugin.log(e); String message= ActionMessages.ShowInPackageViewAction_error_message; ErrorDialog.openError(getShell(), getDialogTitle(), message, e.getStatus()); } }
@Override public void run(ITextSelection selection) { try { IJavaElement element= SelectionConverter.getElementAtOffset(fEditor); if (element != null) run(element); } catch (JavaModelException e) { JavaPlugin.log(e); String message= ActionMessages.ShowInPackageViewAction_error_message; ErrorDialog.openError(getShell(), getDialogTitle(), message, e.getStatus()); } }