VirtualFile[] (Project project, VirtualFile[] files) { if (files == null || files.length == 0) { return VirtualFile.EMPTY_ARRAY; } final PsiManager psiManager = PsiManager.getInstance(project); final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(project); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final CompilerManager compilerManager = CompilerManager.getInstance(project); final List<VirtualFile> filesToCompile = new ArrayList<>(); for (final VirtualFile file : files) { if (!fileIndex.isInSourceContent(file)) { continue; } if (!file.isInLocalFileSystem()) { continue; } if (file.isDirectory()) { final PsiDirectory directory = psiManager.findDirectory(file); if (directory == null || JavaDirectoryService.getInstance().getPackage(directory) == null) { continue; } } else { FileType fileType = file.getFileType(); if (!(compilerManager.isCompilableFileType(fileType) || compilerConfiguration.isCompilableResourceFile(project, file))) { continue; } } filesToCompile.add(file); } return VfsUtilCore.toVirtualFileArray(filesToCompile); }