return;
if (!validateEditorInputState())
return;
ISourceViewer viewer= ((AbstractTextEditor) editor).getSourceViewer();
if (viewer == null)
return;
IDocument document= viewer.getDocument();
if (document == null)
return;
StyledText st= viewer.getTextWidget();
if (st == null)
return;
Point sel= viewer.getSelectedRange();
if (sel == null)
return;
try {
// if the selection is empty, we select the word / string using the viewer's
// double-click strategy
if (sel.y == 0) {
// TODO find a better way to do this although there are multiple partitionings on a single document
// String partition= getContentType(viewer, document, sel.x);
// SourceViewerConfiguration svc= fEditor.getSourceViewerConfiguration(); // never null when viewer instantiated
// ITextDoubleClickStrategy dcs= svc.getDoubleClickStrategy(viewer, partition);
// if (dcs != null) {
// dcs.doubleClicked(viewer);
// sel= viewer.getSelectedRange();
// }
if (sel.y == 0)
return; // if the selection is still empty, we're done
}
String target= document.get(sel.x, sel.y);
String replacement= (fToUpper ? target.toUpperCase() : target.toLowerCase());
if (!target.equals(replacement)) {
document.replace(sel.x, target.length(), replacement);
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=145326: replacement might be larger than the original
int adjustment= replacement.length() - target.length();
if (adjustment > 0)
sel.y += adjustment;
}
} catch (BadLocationException x) {
// ignore and return
return;
}
// reinstall selection and move it into view
viewer.setSelectedRange(sel.x, sel.y);
// don't use the viewer's reveal feature in order to avoid jumping around
st.showSelection();
}