boolean (PsiJavaFile file, PsiElement element) { if (element instanceof PsiClass && ((PsiClass)element).getContainingClass() == null) { final PsiFile containingFile = element.getContainingFile(); return containingFile instanceof PsiClassOwner && Comparing.strEqual(file.getPackageName(), ((PsiClassOwner)containingFile).getPackageName()); } return false; }