SourceFolder (@NotNull ModuleRootModel moduleRootManager, @NotNull String sourcePath) { ContentEntry[] contentRoots = moduleRootManager.getContentEntries(); Module module = moduleRootManager.getModule(); String rootUrl = getAbsolutePath(ExternalSystemApiUtil.getExternalProjectPath(module)); for (ContentEntry contentRoot : contentRoots) { for (SourceFolder f : contentRoot.getSourceFolders()) { String folderPath = getAbsolutePath(f.getUrl()); String rootPath = getAbsolutePath(rootUrl + "/" + sourcePath); if (folderPath.equals(rootPath)) return f; } } return null; }