boolean (PsiReference reference, boolean unresolvedOnly) { if (!(reference instanceof PsiJavaReference)) return false; JavaResolveResult[] results = ((PsiJavaReference)reference).multiResolve(false); if(results.length == 0) return false; if (!unresolvedOnly) { for (JavaResolveResult result : results) { if (!result.isValidResult()) return false; if (result.getElement() instanceof PsiPackage) return false; } } return true; }