@Override protected IJavaElement getElementAt(int offset) { if (getEditorInput() instanceof IClassFileEditorInput) { try { IClassFileEditorInput input= (IClassFileEditorInput) getEditorInput(); return input.getClassFile().getElementAt(offset); } catch (JavaModelException x) { } } return null; }
protected IJavaElement getElementAt(int offset) { if (getEditorInput() instanceof IClassFileEditorInput) { try { IClassFileEditorInput input= (IClassFileEditorInput) getEditorInput(); return input.getClassFile().getElementAt(offset); } catch (JavaModelException x) { } } return null; }
@Override protected IJavaElement getElementAt(int offset) { if (getEditorInput() instanceof IClassFileEditorInput) { try { IClassFileEditorInput input= (IClassFileEditorInput) getEditorInput(); return input.getClassFile().getElementAt(offset); } catch (JavaModelException x) { } } return null; }
/** * Returns the element at the given position in the given type */ protected static IJavaElement getElementAt(IType type, int pos) throws JavaModelException { if (type.isBinary()) { return type.getClassFile().getElementAt(pos); } return type.getCompilationUnit().getElementAt(pos); }
public static IJavaElement getElementAtOffset(IJavaElement input, ITextSelection selection) throws JavaModelException { if (input instanceof ICompilationUnit) { ICompilationUnit cunit= (ICompilationUnit) input; JavaModelUtil.reconcile(cunit); IJavaElement ref= cunit.getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } else if (input instanceof IClassFile) { IJavaElement ref= ((IClassFile)input).getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } return null; }
private static IJavaElement getElementAtOffset(IJavaElement input, ITextSelection selection) throws JavaModelException { if (input instanceof ICompilationUnit) { ICompilationUnit cunit= (ICompilationUnit)input; if (cunit.isWorkingCopy()) JavaModelUtil.reconcile(cunit); IJavaElement ref= cunit.getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } else if (input instanceof IClassFile) { IJavaElement ref= ((IClassFile)input).getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } return null; } }
private static IJavaElement getElementAtOffset(IJavaElement input, ITextSelection selection) throws JavaModelException { if (input instanceof ICompilationUnit) { ICompilationUnit cunit= (ICompilationUnit)input; if (cunit.isWorkingCopy()) JavaModelUtil.reconcile(cunit); IJavaElement ref= cunit.getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } else if (input instanceof IClassFile) { IJavaElement ref= ((IClassFile)input).getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } return null; } }
private static IJavaElement getElementAtOffset(IJavaElement input, ITextSelection selection) throws JavaModelException { if (input instanceof ICompilationUnit) { ICompilationUnit cunit= (ICompilationUnit)input; if (cunit.isWorkingCopy()) JavaModelUtil.reconcile(cunit); IJavaElement ref= cunit.getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } else if (input instanceof IClassFile) { IJavaElement ref= ((IClassFile)input).getElementAt(selection.getOffset()); if (ref == null) return input; else return ref; } return null; } }
if (input instanceof IClassFileEditorInput) { try { return ((IClassFileEditorInput)input).getClassFile().getElementAt(offset); } catch (JavaModelException ex) { return null;
if (input instanceof IClassFileEditorInput) { try { return ((IClassFileEditorInput)input).getClassFile().getElementAt(offset); } catch (JavaModelException ex) { return null;
if (input instanceof IClassFileEditorInput) { try { return ((IClassFileEditorInput)input).getClassFile().getElementAt(offset); } catch (JavaModelException ex) { return null;
/** * Returns if the text selection is a valid method or not * @param selection the text selection * @param part the associated workbench part * @return true if the selection is a valid method, false otherwise */ private boolean isMethod(ITextSelection selection, IWorkbenchPart part) { ITextEditor editor = getTextEditor(part); if(editor != null) { IJavaElement element = getJavaElement(editor.getEditorInput()); if(element != null) { try { if(element instanceof ICompilationUnit) { element = ((ICompilationUnit) element).getElementAt(selection.getOffset()); } else if(element instanceof IClassFile) { element = ((IClassFile) element).getElementAt(selection.getOffset()); } return element != null && element.getElementType() == IJavaElement.METHOD; } catch (JavaModelException e) {return false;} } } return false; }
/** * Returns if the text selection is a field selection or not * @param selection the text selection * @param part the associated workbench part * @return true if the text selection is a valid field for a watchpoint, false otherwise * @since 3.3 */ private boolean isField(ITextSelection selection, IWorkbenchPart part) { ITextEditor editor = getTextEditor(part); if(editor != null) { IJavaElement element = getJavaElement(editor.getEditorInput()); if(element != null) { try { if(element instanceof ICompilationUnit) { element = ((ICompilationUnit) element).getElementAt(selection.getOffset()); } else if(element instanceof IClassFile) { element = ((IClassFile) element).getElementAt(selection.getOffset()); } return element != null && element.getElementType() == IJavaElement.FIELD; } catch (JavaModelException e) {return false;} } } return false; }
private IJavaElement getEnclosingMethod(IJavaElement input, ITextSelection selection) { IJavaElement enclosingElement= null; try { switch (input.getElementType()) { case IJavaElement.CLASS_FILE : IClassFile classFile= (IClassFile) input.getAncestor(IJavaElement.CLASS_FILE); if (classFile != null) { enclosingElement= classFile.getElementAt(selection.getOffset()); } break; case IJavaElement.COMPILATION_UNIT : ICompilationUnit cu= (ICompilationUnit) input.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) { enclosingElement= cu.getElementAt(selection.getOffset()); } break; } if (enclosingElement != null && enclosingElement.getElementType() == IJavaElement.METHOD) { return enclosingElement; } } catch (JavaModelException e) { JavaPlugin.log(e); } return null; }
} else if (input instanceof IClassFile) { IClassFile cfile= (IClassFile)input; atOffset= cfile.getElementAt(selection.getOffset()); } else { return null;
} else if (input instanceof IClassFile) { IClassFile cfile= (IClassFile)input; atOffset= cfile.getElementAt(selection.getOffset()); } else { return null;
} else if (input instanceof IClassFile) { IClassFile cfile= (IClassFile)input; atOffset= cfile.getElementAt(selection.getOffset()); } else { return null;
IClassFile classFile = (IClassFile) editorInput.getAdapter(IClassFile.class); if (classFile != null) { IJavaElement e = classFile.getElementAt(offset); if (e instanceof IMember) { m = (IMember) e;
IClassFile classFile= (IClassFile)editorInput.getAdapter(IClassFile.class); if (classFile != null) { IJavaElement e= classFile.getElementAt(currentSelection.getOffset()); if (e instanceof IMember) { m= (IMember)e;