public static boolean acceptName(GrReferenceElement ref, String expected) {
    final String actual = ref.getReferenceName();
    if (expected.equals(actual)) {
      return true;
    }
    if (ref.getQualifier() != null) {
      return false;
    }
    final PsiFile file = ref.getContainingFile();
    if (!(file instanceof GroovyFile)) {
      return false;
    }
    MultiMap<String, String> data = getAliases((GroovyFile)file);
    Collection<String> aliases = data.get(expected);
    return aliases.contains(actual);
  }
public static boolean acceptName(GrReferenceElement ref, String expected)