VirtualFile (String fqn, Project project) { for (VirtualFile root : ProjectRootManager.getInstance(project).getContentSourceRoots()) { VirtualFile rel = root.findFileByRelativePath(fqn); if (rel != null) { return rel; } } for (VirtualFile root : ProjectRootManager.getInstance(project).getContentRoots()) { VirtualFile rel = root.findFileByRelativePath(fqn); if (rel != null) { return rel; } } VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fqn); if (file != null) return file; PsiFile[] files = PsiShortNamesCache.getInstance(project).getFilesByName(fqn); for (PsiFile psiFile : files) { VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile != null) return virtualFile; } return null; }