SourceFolder (@NotNull VirtualFile fileOrDir) { WorkspaceFileSetWithCustomData<ModuleSourceRootData> fileSet = myWorkspaceFileIndex.findFileSetWithCustomData(fileOrDir, true, true, false, false, false, ModuleSourceRootData.class); if (fileSet == null) return null; for (ContentEntry contentEntry : ModuleRootManager.getInstance(fileSet.getData().getModule()).getContentEntries()) { for (SourceFolder folder : contentEntry.getSourceFolders()) { if (fileSet.getRoot().equals(folder.getFile())) { return folder; } } } return null; }