Bug 99325 [syntax highlighting] semantic highlighting broken when using "convert to new for loop"
I20050610-0010 (no regression, though - just exposed by the quick fix) - In the code below, execute the "convert to new for loop" quick fix - undo -> note that the 'for' keyword is wrongly colored. -> subsequent reconciles do not correct the failure -> only doing a major change (cutting and pasting entire method, closing editor..) corrects the problem class Test{ void m() { LinkedList<Number> list = null; for (Iterator it = list.iterator(); it.hasNext();) { Number num = (Number) it.next(); System.out.println(num.intValue()); } } } Code inspection revealed that SemanticHighlightingPresenter.contain() relies on positions being disjoint, which is not true in this case: the quick fix modifies the document in a way that produces many positions at the same offset/length. A fix would change indexOf() to check all positions at a certain offset instead of the index returned. Need to talk to Christof about whether the position updater might be doing the wrong thing...
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/SemanticHighlightingPresenter.java
}
	/**
	 * Returns index of the position in the positions, <code>-1</code> if not found.
	 * @param positions the positions, must be ordered by offset and must not overlap
	 * @param position the position
	 * @return the index
	 */
	private int indexOf(List positions, Position position) {
		int index= computeIndexAtOffset(positions, position.getOffset());
		return index < positions.size() && positions.get(index) == position ? index : -1;
	}
	/**
	 * Insert the given position in <code>fPositions</code>, s.t. the offsets remain in linear order.
	 *
	 * @param position The position for insertion
	 */
	private void insertPosition(Position position) {
		int i= computeIndexAfterOffset(fPositions, position.getOffset());
		fPositions.add(i, position);
	}
	/**
	 * Returns the index of the first position with an offset greater than the given offset.
	 *
	 * @param positions the positions, must be ordered by offset and must not overlap
	 * @param offset the offset
	 * @return the index of the last position with an offset greater than the given offset
	 */
	private int computeIndexAfterOffset(List positions, int offset) {
		int i= -1;
		int j= positions.size();