InputFilter (@NotNull InputFilter filter, @NotNull BiPredicate<? super VirtualFile, ? super Project> condition) { return new ProjectSpecificInputFilter() { @Override public boolean acceptInput(@NotNull IndexedFile file) { boolean doesMainFilterAccept = filter instanceof ProjectSpecificInputFilter ? ((ProjectSpecificInputFilter)filter).acceptInput(file) : filter.acceptInput(file.getFile()); return doesMainFilterAccept && condition.test(file.getFile(), file.getProject()); } }; }