Set<VirtualFile> (final VirtualFile... filesToDeny) { final Set<VirtualFile> requested = new LinkedHashSet<>(); ServiceContainerUtil.registerExtension(getProject(), WritingAccessProvider.EP, new WritingAccessProvider() { @NotNull @Override public Collection<VirtualFile> requestWriting(@NotNull Collection<? extends VirtualFile> files) { requested.addAll(files); Set<VirtualFile> denied = ContainerUtil.newHashSet(filesToDeny); denied.retainAll(files); return denied; } }, getProject()); return requested; }