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/LinkedUIControl.java
/**
		 * Checks whether the linked mode should be left after receiving the
		 * given <code>VerifyEvent</code> and selection. Note that the event
		 * carries widget coordinates as opposed to <code>offset</code> and 
		 * <code>length</code> which are document coordinates.
		 * 
		 * @param environment the linked environment
		 * @param event the verify event
		 * @param offset the offset of the current selection
		 * @param length the length of the current selection
		 * @return valid exit flags or <code>null</code> if no special action
		 *         should be taken
		 */
		ExitFlags doExit(LinkedEnvironment environment, VerifyEvent event, int offset, int length);
	}
	/**
	 * A NullObject implementation of <code>IExitPolicy</code>.
	 */
	private static class NullExitPolicy implements IExitPolicy {
		/*
		 * @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.IExitPolicy#doExit(org.eclipse.swt.events.VerifyEvent, int, int)
		 */
		public ExitFlags doExit(LinkedEnvironment environment, VerifyEvent event, int offset, int length) {
			return null;
		}
	}
	/**
	 * Listens for shell events and acts upon them.
	 */
	private class LinkedUICloser implements ShellListener {