protected boolean isReferenceAtCaret(PsiElement selectedElement, PsiReference ref) {
    TextRange textRange = ref.getRangeInElement().shiftRight(ref.getElement().getTextRange().getStartOffset());
    if (selectedElement != null){
      TextRange selectedElementRange = selectedElement.getTextRange();
      LOG.assertTrue(selectedElementRange != null, selectedElement);
      if (selectedElementRange.contains(textRange)) return true;
    }
    return false;
  }
protected boolean isReferenceAtCaret(PsiElement selectedElement, PsiReference ref)