String (@NotNull PsiClass aClass) { PsiClass topClass = getTopLevelClass(aClass); if (topClass != null) { String fqName = topClass.getQualifiedName(); if (fqName != null) { return StringUtil.getPackageName(fqName); } } PsiFile file = aClass.getContainingFile(); if (file instanceof PsiClassOwner) { return ((PsiClassOwner)file).getPackageName(); } return null; }