PsiFile[] (final Project project, final Collection<? extends VirtualFile> selectedFiles) { ArrayList<PsiFile> result = new ArrayList<>(); PsiManager psiManager = PsiManager.getInstance(project); IProjectStore projectStore = ProjectKt.getStateStore(project); for (VirtualFile file : selectedFiles) { if (file.isValid()) { if (projectStore.isProjectFile(file) || !isFileUnderSourceRoot(project, file) || isOutOfSources(project, file)) { continue; } PsiFile psiFile = psiManager.findFile(file); if (psiFile != null) result.add(psiFile); } } return PsiUtilCore.toPsiFileArray(result); }