boolean (PsiJavaCodeReferenceElement ref, String... classNames) { if(ref == null) return false; String name = ref.getReferenceName(); if (name == null) return false; String qualifiedName = null; for (String className : classNames) { if(StringUtil.getShortName(className).equals(name)) { if (qualifiedName == null) { // Defer resolution if possible qualifiedName = ref.getQualifiedName(); } if (className.equals(qualifiedName)) return true; } } return false; }