Bug 52361 [templates] linked mode not exited / annotations not redrawn when inserting anonymous completion
M7 0. Auto-closed parenthesis on 1. Insert this code: import java.lang.Runnable; void m() { method(<caret> } -> closing parenthesis gets inserted -> linked mode entered 2. type "new Runnable(" -> nested linked mode is entered for second parenthesis, also autoclosed 3. use code completion to complete the anonymous type -> you end up with this code: void m() { method(new Runnable() { public void run() { } }) } -> Linked mode is still drawn 4. Press <Tab> or <Enter> -> linked mode is not exited -> annotations keep being drawn The only way to get away with the annotations is to open a new parenthesis somewhere outside the initial code.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/link/LinkedPositionAnnotations.java
targets.remove(exit);
		}
		
		group.removeAll(targets);
		targets.remove(position);
		group.remove(position);
		prune(targets);
		prune(group);
		
		try {
			setFocusPosition(position);
			setExitPosition(exit);
			setGroupPositions(group);
			setTargetPositions(targets);
		} catch (BadLocationException e) {
			
			JavaPlugin.log(e);
		}
		fireModelChanged();
		
	}
	
	/**
	 * Prune <code>list</code> of all <code>LinkedPosition</code>s that 
	 * do not belong to this model's <code>IDocument</code>.
	 * 
	 * @param list the list of positions to prune
	 */
	private void prune(List list) {
		for (Iterator iter= list.iterator(); iter.hasNext();) {