public static boolean canOperateOn(JavaEditor editor) { if (editor == null) return false; return getInput(editor) != null; }
public static ICompilationUnit getInputAsCompilationUnit(JavaEditor editor) { Object editorInput= SelectionConverter.getInput(editor); if (editorInput instanceof ICompilationUnit) return (ICompilationUnit)editorInput; return null; }
public static IClassFile getInputAsClassFile(JavaEditor editor) { Object editorInput= SelectionConverter.getInput(editor); if (editorInput instanceof IClassFile) return (IClassFile)editorInput; return null; }
public static ICompilationUnit getInputAsCompilationUnit(JavaEditor editor) { Object editorInput= SelectionConverter.getInput(editor); if (editorInput instanceof ICompilationUnit) return (ICompilationUnit)editorInput; return null; }
public static IClassFile getInputAsClassFile(JavaEditor editor) { Object editorInput= SelectionConverter.getInput(editor); if (editorInput instanceof IClassFile) return (IClassFile)editorInput; return null; }
/** * Returns the input element of the given editor. * * @param editor the Java editor * @return the type root which is the editor input (only primary working copies), or <code>null</code> if none */ public static ITypeRoot getInput(JavaEditor editor) { return getInput(editor, true); }
public static boolean canOperateOn(JavaEditor editor) { if (editor == null) return false; return getInput(editor) != null; }
public static ICompilationUnit getInputAsCompilationUnit(JavaEditor editor) { Object editorInput= SelectionConverter.getInput(editor); if (editorInput instanceof ICompilationUnit) return (ICompilationUnit)editorInput; return null; }
@Override public void run(ITextSelection selection) { IJavaElement element= SelectionConverter.getInput(fEditor); if (!(element instanceof ICompilationUnit)) return; run((ICompilationUnit)element); }
public static IJavaElement resolveEnclosingElement(JavaEditor editor, ITextSelection selection) throws JavaModelException { ITypeRoot input= getInput(editor); if (input != null) return resolveEnclosingElement(input, selection); return null; }
public static IJavaElement[] codeResolveOrInputForked(JavaEditor editor) throws InvocationTargetException, InterruptedException { ITypeRoot input= getInput(editor); if (input == null) return EMPTY_RESULT; ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection(); IJavaElement[] result= performForkedCodeResolve(input, selection); if (result.length == 0) { result= new IJavaElement[] {input}; } return result; }
public static IJavaElement[] codeResolveOrInputForked(JavaEditor editor) throws InvocationTargetException, InterruptedException { IJavaElement input= getInput(editor); ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection(); IJavaElement[] result= performForkedCodeResolve(input, selection); if (result.length == 0) { result= new IJavaElement[] {input}; } return result; }
/** * @param primaryOnly if <code>true</code> only primary working copies will be returned * @since 3.2 */ public static IJavaElement[] codeResolve(JavaEditor editor, boolean primaryOnly) throws JavaModelException { return codeResolve(getInput(editor, primaryOnly), (ITextSelection)editor.getSelectionProvider().getSelection()); }
/** * @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()); }
@Override public void run(ITextSelection selection) { ITypeRoot typeRoot= SelectionConverter.getInput(fEditor); if (typeRoot == null) return; if (! JavaElementUtil.isSourceAvailable(typeRoot)) return; run(selection.getOffset(), selection.getLength(), typeRoot); }
@Override public void run(ITextSelection selection) { ITypeRoot typeRoot= SelectionConverter.getInput(fEditor); if (ActionUtil.isProcessable(getShell(), typeRoot)) { RefactoringExecutionStarter.startReplaceInvocationsRefactoring(typeRoot, selection.getOffset(), selection.getLength(), getShell()); } } }
@Override public void run(ITextSelection selection) { ITypeRoot typeRoot= SelectionConverter.getInput(fEditor); if (ActionUtil.isProcessable(getShell(), typeRoot)) { RefactoringExecutionStarter.startReplaceInvocationsRefactoring(typeRoot, selection.getOffset(), selection.getLength(), getShell()); } } }
public void run(ITextSelection selection) { try { IJavaElement editorInput= SelectionConverter.getInput(fEditor); if ((editorInput instanceof ITypeRoot) && ActionUtil.isProcessable(getShell(), editorInput)) { ITypeRoot typeRoot= (ITypeRoot) editorInput; RefactoringExecutionStarter.startReplaceInvocationsRefactoring(typeRoot, selection.getOffset(), selection.getLength(), getShell()); } } catch (JavaModelException e) { handleException(e); } } }
private ISelection getEditorSelection(JavaEditor editor) { ITypeRoot element= SelectionConverter.getInput(editor); if (element == null) return null; if (editor.isBreadcrumbActive()) return editor.getBreadcrumb().getSelectionProvider().getSelection(); else { ITextSelection textSelection= (ITextSelection) editor.getSelectionProvider().getSelection(); IDocument document= JavaUI.getDocumentProvider().getDocument(editor.getEditorInput()); return new JavaTextSelection(element, document, textSelection.getOffset(), textSelection.getLength()); } }
private ISelection getEditorSelection(JavaEditor editor) { ITypeRoot element= SelectionConverter.getInput(editor); if (element == null) return null; if (editor.isBreadcrumbActive()) return editor.getBreadcrumb().getSelectionProvider().getSelection(); else { ITextSelection textSelection= (ITextSelection) editor.getSelectionProvider().getSelection(); IDocument document= JavaUI.getDocumentProvider().getDocument(editor.getEditorInput()); return new JavaTextSelection(element, document, textSelection.getOffset(), textSelection.getLength()); } }