if (index != -1) {
if (index != -1 && index + 1 == fCursorPosition) {
	public void apply(IDocument document, char trigger, int offset) {		try {			// patch replacement length			int delta= offset - (fReplacementOffset + fReplacementLength);			if (delta > 0)				fReplacementLength += delta;						String string;			if (trigger == (char) 0) {				string= fReplacementString;			} else {				StringBuffer buffer= new StringBuffer(fReplacementString);				// fix for PR #5533. Assumes that no eating takes place.				if ((fCursorPosition > 0 && fCursorPosition <= buffer.length() && buffer.charAt(fCursorPosition - 1) != trigger)) {					buffer.insert(fCursorPosition, trigger);					++fCursorPosition;				}								string= buffer.toString();			}			replace(document, fReplacementOffset, fReplacementLength, string);			if (fTextViewer != null && string != null) {				int index= string.indexOf("()"); //$NON-NLS-1$				if (index != -1) {										IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();					if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACKETS)) {							int newOffset= fReplacementOffset + index;								LinkedPositionManager manager= new LinkedPositionManager(document);						manager.addPosition(newOffset + 1, 0);								LinkedPositionUI editor= new LinkedPositionUI(fTextViewer, manager);						editor.setExitPolicy(new ExitPolicy(')'));						editor.setFinalCaretOffset(newOffset + 2);						editor.enter();												}				}			}		} catch (BadLocationException x) {			// ignore		}			}