/** * Computes the regions that must be collapsed when the given position is * the position of an expanded projection annotation. * * @param position the position * @return the ranges that must be collapsed, or <code>null</code> if * there are none * @since 3.1 */ IRegion[] computeCollapsedRegions(Position position) { try { IDocument document= getDocument(); if (document == null) return null; if (position instanceof IProjectionPosition) { IProjectionPosition projPosition= (IProjectionPosition) position; return projPosition.computeProjectionRegions(document); } int line= document.getLineOfOffset(position.getOffset()); int offset= document.getLineOffset(line + 1); int length= position.getLength() - (offset - position.getOffset()); if (length > 0) return new IRegion[] {new Region(offset, length)}; return null; } catch (BadLocationException x) { return null; } }
/** * Computes the regions that must be collapsed when the given position is * the position of an expanded projection annotation. * * @param position the position * @return the ranges that must be collapsed, or <code>null</code> if * there are none * @since 3.1 */ IRegion[] computeCollapsedRegions(Position position) { try { IDocument document= getDocument(); if (document == null) return null; if (position instanceof IProjectionPosition) { IProjectionPosition projPosition= (IProjectionPosition) position; return projPosition.computeProjectionRegions(document); } int line= document.getLineOfOffset(position.getOffset()); int offset= document.getLineOffset(line + 1); int length= position.getLength() - (offset - position.getOffset()); if (length > 0) return new IRegion[] {new Region(offset, length)}; return null; } catch (BadLocationException x) { return null; } }