PsiPackage (@NotNull PsiDirectory dir) { PsiPackage aPackage = getPackage(dir); if (aPackage != null) { ProjectFileIndex fileIndex = ProjectRootManager.getInstance(dir.getProject()).getFileIndex(); VirtualFile virtualFile = dir.getVirtualFile(); if (fileIndex.isInSourceContent(virtualFile) && !fileIndex.isUnderSourceRootOfType(virtualFile, JavaModuleSourceRootTypes.RESOURCES)) { return aPackage; } } return null; }