return findElement(type, position, mapper);
return findElement(type, position, mapper);
return findElement(type, position, mapper);
return findElement(type, position, mapper);
/** * Finds the deepest <code>IJavaElement</code> in the hierarchy of * <code>elt</elt>'s children (including <code>elt</code> itself) * which has a source range that encloses <code>position</code> * according to <code>mapper</code>. */ protected IJavaElement findElement(IJavaElement elt, int position, SourceMapper mapper) { SourceRange range = mapper.getSourceRange(elt); if (range == null || position < range.getOffset() || range.getOffset() + range.getLength() - 1 < position) { return null; } if (elt instanceof IParent) { try { IJavaElement[] children = ((IParent) elt).getChildren(); for (int i = 0; i < children.length; i++) { IJavaElement match = findElement(children[i], position, mapper); if (match != null) { return match; } } } catch (JavaModelException npe) { // elt doesn't exist: return the element } } return elt; } /**
/** * Finds the deepest <code>IJavaElement</code> in the hierarchy of * <code>elt</elt>'s children (including <code>elt</code> itself) * which has a source range that encloses <code>position</code> * according to <code>mapper</code>. */ protected IJavaElement findElement(IJavaElement elt, int position, SourceMapper mapper) { SourceRange range = mapper.getSourceRange(elt); if (range == null || position < range.getOffset() || range.getOffset() + range.getLength() - 1 < position) { return null; } if (elt instanceof IParent) { try { IJavaElement[] children = ((IParent) elt).getChildren(); for (int i = 0; i < children.length; i++) { IJavaElement match = findElement(children[i], position, mapper); if (match != null) { return match; } } } catch (JavaModelException npe) { // elt doesn't exist: return the element } } return elt; } /**
/** * @see IClassFile */ public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IType type = getType(); return findElement(type, position, mapper); } }
/** * @see IClassFile */ public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IType type = getType(); return findElement(type, position, mapper); } } public IJavaElement getElementAtConsideringSibling(int position) throws JavaModelException {
/** * Finds the deepest <code>IJavaElement</code> in the hierarchy of * <code>elt</elt>'s children (including <code>elt</code> itself) * which has a source range that encloses <code>position</code> * according to <code>mapper</code>. */ protected IJavaElement findElement(IJavaElement elt, int position, SourceMapper mapper) { SourceRange range = mapper.getSourceRange(elt); if (range == null || position < range.getOffset() || range.getOffset() + range.getLength() - 1 < position) { return null; } if (elt instanceof IParent) { try { IJavaElement[] children = ((IParent) elt).getChildren(); for (int i = 0; i < children.length; i++) { IJavaElement match = findElement(children[i], position, mapper); if (match != null) { return match; } } } catch (JavaModelException npe) { // elt doesn't exist: return the element } } return elt; } /**
/** * Finds the deepest <code>IJavaElement</code> in the hierarchy of * <code>elt</elt>'s children (including <code>elt</code> itself) * which has a source range that encloses <code>position</code> * according to <code>mapper</code>. */ protected IJavaElement findElement(IJavaElement elt, int position, SourceMapper mapper) { SourceRange range = mapper.getSourceRange(elt); if (range == null || position < range.getOffset() || range.getOffset() + range.getLength() - 1 < position) { return null; } if (elt instanceof IParent) { try { IJavaElement[] children = ((IParent) elt).getChildren(); for (int i = 0; i < children.length; i++) { IJavaElement match = findElement(children[i], position, mapper); if (match != null) { return match; } } } catch (JavaModelException npe) { // elt doesn't exist: return the element } } return elt; } /**
/** * @see IClassFile */ @Override public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IType type = getType(); return findElement(type, position, mapper); } }
/** * @see IClassFile */ public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IType type = getType(); return findElement(type, position, mapper); } } public IJavaElement getElementAtConsideringSibling(int position) throws JavaModelException {
/** * @see IClassFile */ public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IType type = getType(); return findElement(type, position, mapper); } } public IJavaElement getElementAtConsideringSibling(int position) throws JavaModelException {
/** * @see IClassFile */ public IJavaElement getElementAt(int position) throws JavaModelException { IJavaElement parentElement = getParent(); while (parentElement.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) { parentElement = parentElement.getParent(); } PackageFragmentRoot root = (PackageFragmentRoot) parentElement; SourceMapper mapper = root.getSourceMapper(); if (mapper == null) { return null; } else { // ensure this class file's buffer is open so that source ranges are computed getBuffer(); IType type = getType(); return findElement(type, position, mapper); } } public IJavaElement getElementAtConsideringSibling(int position) throws JavaModelException {