ITextSelection sel = (ITextSelection) editor.getSelectionProvider().getSelection();
if (sel.getLength() > 0) {
query = sel.getText();
} else {
PartitionHelper ph = new PartitionHelper((ICFDocument) doc, sel.getOffset());
query = ph.getTagName();
}
if (query == null) {
editor.getSelectionProvider().setSelection(CFDocUtils.selectWord(doc, sel.getOffset()));
sel = (ITextSelection) editor.getSelectionProvider().getSelection();
query = sel.getText();