public static PsiQualifiedReferenceElement removeFromReferenceList(PsiReferenceList refList, PsiClass aClass) throws IncorrectOperationException {
    PsiQualifiedReferenceElement[] refs =
      refList instanceof GrReferenceList ? ((GrReferenceList)refList).getReferenceElementsGroovy() : refList.getReferenceElements();

    for (PsiQualifiedReferenceElement ref : refs) {
      if (ref.isReferenceTo(aClass)) {
        PsiQualifiedReferenceElement refCopy = (PsiQualifiedReferenceElement)ref.copy();
        ref.delete();
        return refCopy;
      }
    }
    return null;
  }
public static PsiQualifiedReferenceElement removeFromReferenceList(PsiReferenceList refList, PsiClass aClass)