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
static ISourceRange createSourceRange(int offset, int end){
		int length= end - offset + 1;
		if (length == 0) 
			length= 1;
		return new SourceRange(Math.max(0, offset), length);
	}
	
	static ASTNode[] getChildNodes(ASTNode node){
		if (node instanceof Block)
			return convertToNodeArray(((Block)node).statements());	
		if (node instanceof TypeDeclaration)
			return convertToNodeArray(((TypeDeclaration)node).bodyDeclarations());	
		if (node instanceof CompilationUnit)
			return convertToNodeArray(((CompilationUnit)node).types());	
		return null;	
	}
	
	private static ASTNode[] convertToNodeArray(Collection statements){
		return (ASTNode[]) statements.toArray(new ASTNode[statements.size()]);
	}
	static int findIndex(Object[] array, Object o){
		for (int i= 0; i < array.length; i++) {
			Object object= array[i];
			if (object == o)
				return i;
		}
		return -1;
	}	
}