VirtualFile (final String resourceName, final Project project, final GlobalSearchScope scope) { int index = resourceName.lastIndexOf('/'); String packageName = index >= 0 ? resourceName.substring(0, index).replace('/', '.') : ""; final String fileName = index >= 0 ? resourceName.substring(index+1) : resourceName; final VirtualFile dir = new FilteredQuery<>( PackageIndex.getInstance(project).getDirsByPackageName(packageName, false), file -> { final VirtualFile child = file.findChild(fileName); return child != null && scope.contains(child); }).findFirst(); return dir != null ? dir.findChild(fileName) : null; }