Bug 11882 structured selection: remembering history should stop on 'whole-cu-selected' case
credit goes to Erich for finding this one when you press alt+up many times you select the whole cu when you press it again a couple of times then it takes the same number of times to bring it down again with alt+down it should stop stacking ranges when the range covers the full cu
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/structureselection/StructureSelectionAction.java
}
	
	protected final ITextSelection getTextSelection() {
		return (ITextSelection)fEditor.getSelectionProvider().getSelection();
	}
	
	protected static ISourceRange getLastCoveringNodeRange(ISourceRange oldSourceRange, ICompilationUnit cu, StructureSelectionAnalyzer selAnalyzer) throws JavaModelException {
		if (selAnalyzer.getLastCoveringNode() == null)
			return oldSourceRange;		
		else	
			return getSelectedNodeSourceRange(cu, selAnalyzer.getLastCoveringNode());
	}
	
	protected static ISourceRange getSelectedNodeSourceRange(ICompilationUnit cu, ASTNode nodeToSelect) throws JavaModelException {
		int offset= nodeToSelect.getStartPosition();
		int end= Math.min(cu.getSourceRange().getLength(), nodeToSelect.getStartPosition() + nodeToSelect.getLength() - 1);
		return createSourceRange(offset, end);
	}
	
	
	
	private static ISourceRange createSourceRange(ITextSelection ts){
		if (ts.getLength() == 0) 
			return new SourceRange(ts.getOffset(), 1);
		else	
			return new SourceRange(ts.getOffset(), ts.getLength());
	}