sourceViewer.setSelectedRange(targetOffset, selectionLength); sourceViewer.revealRange(targetOffset, selectionLength);
if (selection.getLength() < 0) targetOffset -= selection.getLength();  sourceViewer.setSelectedRange(targetOffset, selection.getLength()); sourceViewer.revealRange(targetOffset, selection.getLength());
	public void gotoMatchingBracket() {		if (fBracketMatcher == null)			fBracketMatcher= new JavaPairMatcher(new char[] { '{', '}', '(', ')', '[', ']' });		ISourceViewer sourceViewer= getSourceViewer();		IDocument document= sourceViewer.getDocument();		if (document == null)			return;				ISelectionProvider provider= getSelectionProvider();		ITextSelection selection= (ITextSelection) provider.getSelection();		int selectionLength= Math.abs(selection.getLength());		if (selectionLength > 1) {			setStatusLineErrorMessage(JavaEditorMessages.getString("GotoMatchingBracket.error.invalidSelection"));	//$NON-NLS-1$					sourceViewer.getTextWidget().getDisplay().beep();			return;		}		IRegion region= fBracketMatcher.match(document, selection.getOffset());		if (region == null) {			setStatusLineErrorMessage(JavaEditorMessages.getString("GotoMatchingBracket.error.noMatchingBracket"));	//$NON-NLS-1$					sourceViewer.getTextWidget().getDisplay().beep();			return;				}				int offset= region.getOffset();		int length= region.getLength();				if (length < 1)			return;					int anchor= fBracketMatcher.getAnchor();		int targetOffset= (JavaPairMatcher.RIGHT == anchor) ? offset : offset + length - 1;		IRegion visibleRegion= sourceViewer.getVisibleRegion();		if (targetOffset < visibleRegion.getOffset() || targetOffset >= visibleRegion.getOffset() + visibleRegion.getLength()) {			setStatusLineErrorMessage(JavaEditorMessages.getString("GotoMatchingBracket.error.bracketOutsideSelectedElement"));	//$NON-NLS-1$					sourceViewer.getTextWidget().getDisplay().beep();			return;		}		sourceViewer.setSelectedRange(targetOffset, selectionLength);		sourceViewer.revealRange(targetOffset, selectionLength);	}